SPB Git

Repository Public

retrieve.md 4.7 KB 176 lines markdown

1---2title: Retrieve API Key (Admin API)3url: https://platform.claude.com/docs/en/api/beta/organization/api_keys/retrieve4---56# Retrieve API Key (Admin API)78**GET** `/v1/organizations/api_keys/{api_key_id}`910Retrieve information about a single API key in your organization, looked up by its ID. This Admin API endpoint requires an Admin API key, is intended for programmatic key management, and never returns the key's secret value. To view or create your own API keys, go to [API keys](https://platform.claude.com/settings/keys) in the Claude Console.1112## Path parameters1314- `api_key_id: string`1516  ID of the API key.1718## Returns1920- `BetaAPIKey object`2122  - `type: "api_key"`2324    Object type.2526    For API Keys, this is always `"api_key"`.2728    default: api_key2930  - `id: string`3132    ID of the API key.3334  - `created_at: string`3536    RFC 3339 datetime string indicating when the API Key was created.3738    format: date-time3940  - `created_by: BetaAPIKeyCreatedBy or null`4142    The ID and type of the actor that created the API key, or `null` when the43    creator is not recorded (legacy, workload-identity-federated, or44    system-created keys).4546    - `type: "service_account" or "user"`4748      Type of the actor that created the object.4950      - `"service_account"`5152      - `"user"`5354    - `id: string`5556      ID of the actor that created the object.5758  - `expires_at: string or null`5960    RFC 3339 datetime string indicating when the API Key expires, or `null` if it never expires.6162    format: date-time6364  - `name: string`6566    Name of the API key.6768  - `partial_key_hint: string or null`6970    Partially redacted hint for the API key.7172  - `principal: BetaAPIKeyUserActor or BetaAPIKeyServiceAccountActor or null`7374    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.7576    - `BetaAPIKeyUserActor object`7778      - `type: "user_actor"`7980        Principal type. Always `"user_actor"` for a User.8182        default: user_actor8384      - `user_id: string`8586        ID of the User the API key acts as.8788    - `BetaAPIKeyServiceAccountActor object`8990      - `type: "service_account_actor"`9192        Principal type. Always `"service_account_actor"` for a Service Account.9394        default: service_account_actor9596      - `service_account_id: string`9798        ID of the Service Account the API key acts as.99100  - `scope: BetaAPIKeyOrganizationScope or BetaAPIKeyWorkspaceScope`101102    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.103104    - `BetaAPIKeyOrganizationScope object`105106      - `type: "organization"`107108        Scope type. Always `"organization"`: the API key has no Workspace. Only a principal-bound API key can have this scope.109110        default: organization111112    - `BetaAPIKeyWorkspaceScope object`113114      - `type: "workspace"`115116        Scope type. Always `"workspace"`: the API key belongs to one Workspace.117118        default: workspace119120      - `workspace_id: string`121122        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.123124  - `status: "active" or "archived" or "expired" or "inactive"`125126    Status of the API key.127128    - `"active"`129130    - `"archived"`131132    - `"expired"`133134    - `"inactive"`135136  - `workspace_id: string or null`137138    **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.139140    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.141142## Example143144```bash145curl https://api.anthropic.com/v1/organizations/api_keys/$API_KEY_ID \146    -H 'anthropic-version: 2023-06-01' \147    -H "X-Api-Key: $ANTHROPIC_API_KEY"148```149150### Response (200)151152```json153{154  "id": "apikey_01Rj2N8SVvo6BePZj99NhmiT",155  "created_at": "2024-10-30T23:58:27.427722Z",156  "created_by": {157    "id": "user_01WCz1FkmYMm4gnmykNKUu3Q",158    "type": "user"159  },160  "expires_at": "2024-10-30T23:58:27.427722Z",161  "name": "Developer Key",162  "partial_key_hint": "sk-ant-api03-R2D...igAA",163  "principal": {164    "type": "user_actor",165    "user_id": "user_01WCz1FkmYMm4gnmykNKUu3Q"166  },167  "scope": {168    "type": "workspace",169    "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"170  },171  "status": "active",172  "type": "api_key",173  "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"174}175```176
Files main
Menu

Theme