English ← MyDocs

列出 API 密钥

get /v1/organizations/api_keys

列出 API 密钥

查询参数

  • after_id: optional string

    用作分页游标的对象 ID。提供后,返回该对象之后的结果页。

  • before_id: optional string

    用作分页游标的对象 ID。提供后,返回该对象之前的结果页。

  • created_by_user_id: optional string

    按创建对象的用户 ID 进行筛选。

  • limit: optional number

    每页返回的项目数量。

    默认为 20。范围为 11000

  • status: optional "active" or "inactive" or "archived" or "expired"

    按 API 密钥状态进行筛选。

    • "active"

    • "inactive"

    • "archived"

    • "expired"

  • workspace_id: optional string

    按工作区 ID 进行筛选。

返回值

  • data: array of APIKey

    • id: string

      API 密钥的 ID。

    • created_at: string

      RFC 3339 日期时间字符串,表示 API 密钥的创建时间。

    • created_by: object { id, type }

      创建该 API 密钥的操作者的 ID 和类型。

      • id: string

        创建该对象的操作者的 ID。

      • type: string

        创建该对象的操作者的类型。

    • expires_at: string

      RFC 3339 日期时间字符串,表示 API 密钥的过期时间,如果永不过期则为 null

    • name: string

      API 密钥的名称。

    • partial_key_hint: string

      API 密钥的部分脱敏提示。

    • status: "active" or "inactive" or "archived" or "expired"

      API 密钥的状态。

      • "active"

      • "inactive"

      • "archived"

      • "expired"

    • type: "api_key"

      对象类型。

      对于 API 密钥,此值始终为 "api_key"

      • "api_key"
    • workspace_id: string

      与 API 密钥关联的工作区 ID,如果 API 密钥属于默认工作区则为 null

  • first_id: string

    data 列表中的第一个 ID。可用作上一页的 before_id

  • has_more: boolean

    指示在请求的页面方向上是否还有更多结果。

  • last_id: string

    data 列表中的最后一个 ID。可用作下一页的 after_id

示例

curl https://api.anthropic.com/v1/organizations/api_keys \
    -H 'anthropic-version: 2023-06-01' \
    -H "X-Api-Key: $ANTHROPIC_ADMIN_API_KEY"

响应

{
  "data": [
    {
      "id": "apikey_01Rj2N8SVvo6BePZj99NhmiT",
      "created_at": "2024-10-30T23:58:27.427722Z",
      "created_by": {
        "id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
        "type": "user"
      },
      "expires_at": "2024-10-30T23:58:27.427722Z",
      "name": "Developer Key",
      "partial_key_hint": "sk-ant-api03-R2D...igAA",
      "status": "active",
      "type": "api_key",
      "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id"
}