SPB Git

Repository Public

list-api-keys.md 5.5 KB 227 lines markdown

1---2title: List API Keys3url: https://platform.claude.com/docs/en/api/beta/organization/api_keys/list4---56# List API Keys78**GET** `/v1/organizations/api_keys`910List API Keys1112## Query parameters1314- `after_id: optional string`1516  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object.1718- `before_id: optional string`1920  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object.2122- `created_by_user_id: optional string`2324  Filter by the ID of the User who created the object.2526- `limit: optional number`2728  Number of items to return per page.2930  Defaults to `20`. Ranges from `1` to `1000`.3132  default: 20, maximum: 1000, minimum: 13334- `status: optional "active" or "archived" or "expired" or "inactive"`3536  Filter by API key status.3738  - `"active"`3940  - `"archived"`4142  - `"expired"`4344  - `"inactive"`4546- `workspace_id: optional string`4748  Filter by Workspace ID.4950## Returns5152- `data: array of BetaAPIKey`5354  - `type: "api_key"`5556    Object type.5758    For API Keys, this is always `"api_key"`.5960    default: api_key6162  - `id: string`6364    ID of the API key.6566  - `created_at: string`6768    RFC 3339 datetime string indicating when the API Key was created.6970    format: date-time7172  - `created_by: BetaAPIKeyCreatedBy or null`7374    The ID and type of the actor that created the API key, or `null` when the75    creator is not recorded (legacy, workload-identity-federated, or76    system-created keys).7778    - `type: "service_account" or "user"`7980      Type of the actor that created the object.8182      - `"service_account"`8384      - `"user"`8586    - `id: string`8788      ID of the actor that created the object.8990  - `expires_at: string or null`9192    RFC 3339 datetime string indicating when the API Key expires, or `null` if it never expires.9394    format: date-time9596  - `name: string`9798    Name of the API key.99100  - `partial_key_hint: string or null`101102    Partially redacted hint for the API key.103104  - `principal: BetaAPIKeyUserActor or BetaAPIKeyServiceAccountActor or null`105106    The principal the API key acts as (a User or a Service Account), or `null` if the API key is not bound to a principal.107108    - `BetaAPIKeyUserActor object`109110      - `type: "user_actor"`111112        Principal type. Always `"user_actor"` for a User.113114        default: user_actor115116      - `user_id: string`117118        ID of the User the API key acts as.119120    - `BetaAPIKeyServiceAccountActor object`121122      - `type: "service_account_actor"`123124        Principal type. Always `"service_account_actor"` for a Service Account.125126        default: service_account_actor127128      - `service_account_id: string`129130        ID of the Service Account the API key acts as.131132  - `scope: BetaAPIKeyOrganizationScope or BetaAPIKeyWorkspaceScope`133134    Where the API key belongs: its Workspace (`{"type": "workspace", "workspace_id": "wrkspc_..."}`, with the Workspace's real ID even when it is the organization's default Workspace), or the organization (`{"type": "organization"}`) for a principal-bound API key that has no Workspace.135136    - `BetaAPIKeyOrganizationScope object`137138      - `type: "organization"`139140        Scope type. Always `"organization"`: the API key has no Workspace. Only a principal-bound API key can have this scope.141142        default: organization143144    - `BetaAPIKeyWorkspaceScope object`145146      - `type: "workspace"`147148        Scope type. Always `"workspace"`: the API key belongs to one Workspace.149150        default: workspace151152      - `workspace_id: string`153154        ID of the Workspace the API key belongs to. Unlike the deprecated top-level `workspace_id`, this is the Workspace's real ID even for the organization's default Workspace.155156  - `status: "active" or "archived" or "expired" or "inactive"`157158    Status of the API key.159160    - `"active"`161162    - `"archived"`163164    - `"expired"`165166    - `"inactive"`167168  - `workspace_id: string or null`169170    **Deprecated**: Use `scope` instead. `workspace_id` is `null` both for an API key in the default Workspace and for a principal-bound API key that has no Workspace.171172    Deprecated: use `scope` instead. ID of the Workspace associated with the API key, or `null` if the API key belongs to the default Workspace. Also `null` for a principal-bound API key that has no Workspace; `scope` tells the two apart.173174- `first_id: string or null`175176  First ID in the `data` list. Can be used as the `before_id` for the previous page.177178- `has_more: boolean`179180  Indicates if there are more results in the requested page direction.181182- `last_id: string or null`183184  Last ID in the `data` list. Can be used as the `after_id` for the next page.185186## Example187188```bash189curl https://api.anthropic.com/v1/organizations/api_keys \190    -H 'anthropic-version: 2023-06-01' \191    -H "X-Api-Key: $ANTHROPIC_API_KEY"192```193194### Response (200)195196```json197{198  "data": [199    {200      "id": "apikey_01Rj2N8SVvo6BePZj99NhmiT",201      "created_at": "2024-10-30T23:58:27.427722Z",202      "created_by": {203        "id": "user_01WCz1FkmYMm4gnmykNKUu3Q",204        "type": "user"205      },206      "expires_at": "2024-10-30T23:58:27.427722Z",207      "name": "Developer Key",208      "partial_key_hint": "sk-ant-api03-R2D...igAA",209      "principal": {210        "type": "user_actor",211        "user_id": "user_01WCz1FkmYMm4gnmykNKUu3Q"212      },213      "scope": {214        "type": "workspace",215        "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"216      },217      "status": "active",218      "type": "api_key",219      "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"220    }221  ],222  "first_id": "first_id",223  "has_more": true,224  "last_id": "last_id"225}226```227
Files main
Menu

Theme