Service Accounts
api/admin/service_accounts
Nearest release: v2.1.245, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
api/admin/service_accounts Changed · +125 / -176 lines
### Headers ### Body parameters #### Response (200) ### Path parameters ### Headers #### Response (200) ### Query parameters ### Headers #### Response (200) ### Path parameters ### Headers ### Body parameters #### Response (200) ### Path parameters ### Headers #### Response (200) ## Domain types ## Service Accounts › Workspaces ### Add Workspace To Service Account #### Path parameters #### Headers #### Body parameters #### Returns #### Example ##### Response (200) ### List Workspaces For Service Account #### Path parameters #### Query parameters #### Headers #### Returns #### Example ##### Response (200) ### Remove Workspace From Service Account #### Path parameters #### Headers #### Returns #### Example ##### Response (200) ### Header Parameters ### Body Parameters #### Response ### Path Parameters ### Header Parameters #### Response ### Query Parameters ### Header Parameters #### Response ### Path Parameters ### Header Parameters ### Body Parameters #### Response ### Path Parameters ### Header Parameters #### Response ## Domain Types # Workspaces ## Add Workspace To Service Account ### Path Parameters ### Header Parameters ### Body Parameters #### Response ## List Workspaces For Service Account ### Path Parameters ### Query Parameters ### Header Parameters #### Response ## Remove Workspace From Service Account ### Path Parameters ### Header Parameters #### Response ## Domain Types ### Workspace Create Response ### Workspace List Response ### Workspace Delete Response
---- -title: Service Accounts -url: https://platform.claude.com/docs/en/api/admin/service_accounts ---- - # Service Accounts ## Create Service Account -**post** `/v1/organizations/service_accounts` +**POST** `/v1/organizations/service_accounts` Create a service account.
an interactive credential (a user OAuth token or a Console session) — a workload may only create `developer`-role service accounts. -### Header Parameters +### Headers - `"anthropic-beta": optional array of string`
To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta. -### Body Parameters +### Body parameters - `name: string` Slug identifier (lowercase, digits, hyphens). Unique within the organization; a duplicate name returns 409. + maxLength: 255, minLength: 1 + - `description: optional string or null` Optional free-text description. + maxLength: 2000 + - `organization_role: optional "admin" or "developer"` Org-level role. Defaults to `developer`.
### Returns -- `ServiceAccount object { id, archived_at, archived_by_actor_id, 8 more }` +- `ServiceAccount object` Named non-human identity within the caller's organization.
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account.
### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
}' ``` -#### Response +#### Response (200) ```json {
## Get Service Account -**get** `/v1/organizations/service_accounts/{service_account_id}` +**GET** `/v1/organizations/service_accounts/{service_account_id}` Retrieve a service account by its ID (`svac_...`). -### Path Parameters +### Path parameters - `service_account_id: string` ID of the service account. -### Header Parameters +### Headers - `"anthropic-beta": optional array of string`
### Returns -- `ServiceAccount object { id, archived_at, archived_by_actor_id, 8 more }` +- `ServiceAccount object` Named non-human identity within the caller's organization.
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account.
### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID \ -H 'anthropic-version: 2023-06-01' \ -H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" ``` -#### Response +#### Response (200) ```json {
## List Service Accounts -**get** `/v1/organizations/service_accounts` +**GET** `/v1/organizations/service_accounts` List service accounts in the caller's organization.
`next_page` cursor to paginate; set `include_archived=true` to include archived service accounts. -### Query Parameters +### Query parameters - `include_archived: optional boolean` Include archived resources. Defaults to false. + default: false + - `limit: optional number` Number of results per page. + default: 20, maximum: 100, minimum: 1 + - `page: optional string` Opaque cursor from a previous response's `next_page`. -### Header Parameters +### Headers - `"anthropic-beta": optional array of string`
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account.
### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts \ -H 'anthropic-version: 2023-06-01' \ -H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" ``` -#### Response +#### Response (200) ```json {
## Update Service Account -**post** `/v1/organizations/service_accounts/{service_account_id}` +**POST** `/v1/organizations/service_accounts/{service_account_id}` Update a service account.
interactive credential (a user OAuth token or a Console session). Admin API keys are not accepted. -### Path Parameters +### Path parameters - `service_account_id: string` ID of the service account to update. -### Header Parameters +### Headers - `"anthropic-beta": optional array of string`
To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta. -### Body Parameters +### Body parameters - `description: optional string or null` Replaces the description. Omit to leave unchanged; send `null` to clear (the field is stored as an empty string). + maxLength: 2000 + - `organization_role: optional "admin" or "developer" or null` Replaces the org-level role. Omit or send `null` to leave unchanged.
### Returns -- `ServiceAccount object { id, archived_at, archived_by_actor_id, 8 more }` +- `ServiceAccount object` Named non-human identity within the caller's organization.
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account.
### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
-d '{}' ``` -#### Response +#### Response (200) ```json {
## Archive Service Account -**post** `/v1/organizations/service_accounts/{service_account_id}/archive` +**POST** `/v1/organizations/service_accounts/{service_account_id}/archive` Archive a service account.
Requires an OAuth bearer or Console session; Admin API keys are not accepted. -### Path Parameters +### Path parameters - `service_account_id: string` ID of the service account to archive. -### Header Parameters +### Headers - `"anthropic-beta": optional array of string`
### Returns -- `ServiceAccount object { id, archived_at, archived_by_actor_id, 8 more }` +- `ServiceAccount object` Named non-human identity within the caller's organization.
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account.
### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID/archive \ -X POST \ -H 'anthropic-version: 2023-06-01' \
-H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" ``` -#### Response +#### Response (200) ```json {
} ``` -## Domain Types +## Domain types ### Service Account -- `ServiceAccount object { id, archived_at, archived_by_actor_id, 8 more }` +- `ServiceAccount object` Named non-human identity within the caller's organization.
If set, this service account is archived. + format: date-time + - `archived_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that archived this service account.
When this service account was created. + format: date-time + - `created_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that created this service account.
- `type: "service_account"` - - `"service_account"` + default: service_account - `updated_at: string` When this service account was last updated. + format: date-time + - `updated_by_actor_id: string or null` Tagged ID (`user_`/`svac_`) of the actor that last updated this service account. -# Workspaces +## Service Accounts › Workspaces -## Add Workspace To Service Account +### Add Workspace To Service Account -**post** `/v1/organizations/service_accounts/{service_account_id}/workspaces` +**POST** `/v1/organizations/service_accounts/{service_account_id}/workspaces` Add a service account to a workspace with the given `workspace_role`.
rejected. Requires an OAuth bearer or Console session; Admin API keys are not accepted. -### Path Parameters +#### Path parameters - `service_account_id: string` ID of the service account. -### Header Parameters +#### Headers - `"anthropic-beta": optional array of string`
To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta. -### Body Parameters +#### Body parameters - `workspace_id: string`
- `"workspace_user"` -### Returns +#### Returns - `created_by_actor_id: string or null`
- `type: "service_account_workspace_member"` - - `"service_account_workspace_member"` + default: service_account_workspace_member - `workspace_id: string`
- `"workspace_user"` -### Example +#### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID/workspaces \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
}' ``` -#### Response +##### Response (200) ```json {
} ``` -## List Workspaces For Service Account +### List Workspaces For Service Account -**get** `/v1/organizations/service_accounts/{service_account_id}/workspaces` +**GET** `/v1/organizations/service_accounts/{service_account_id}/workspaces` List the workspaces a service account is a member of.
the service account is active; an archived service account returns an empty list. -### Path Parameters +#### Path parameters - `service_account_id: string` ID of the service account. -### Query Parameters +#### Query parameters - `limit: optional number` Number of results per page. + default: 20, maximum: 100, minimum: 1 + - `page: optional string` Opaque cursor from a previous response's `next_page`. -### Header Parameters +#### Headers - `"anthropic-beta": optional array of string`
To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta. -### Returns +#### Returns -- `data: array of object { created_by_actor_id, implicit, service_account_id, 3 more }` +- `data: array of object` - `created_by_actor_id: string or null`
- `type: "service_account_workspace_member"` - - `"service_account_workspace_member"` + default: service_account_workspace_member - `workspace_id: string`
Opaque cursor for the next page, or null if no more results. -### Example +#### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID/workspaces \ -H 'anthropic-version: 2023-06-01' \ -H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" ``` -#### Response +##### Response (200) ```json {
} ``` -## Remove Workspace From Service Account +### Remove Workspace From Service Account -**delete** `/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}` +**DELETE** `/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}` Remove a service account from a workspace.
400. Requires an OAuth bearer or Console session; Admin API keys are not accepted. -### Path Parameters +#### Path parameters - `service_account_id: string`
ID of the workspace. -### Header Parameters +#### Headers - `"anthropic-beta": optional array of string`
To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta. -### Returns +#### Returns - `service_account_id: string`
- `type: "service_account_workspace_member_deleted"` - - `"service_account_workspace_member_deleted"` + default: service_account_workspace_member_deleted - `workspace_id: string` Tagged workspace ID (`wrkspc_...`) named in the delete request. -### Example +#### Example -```http +```bash curl https://api.anthropic.com/v1/organizations/service_accounts/$SERVICE_ACCOUNT_ID/workspaces/$WORKSPACE_ID \ -X DELETE \ -H 'anthropic-version: 2023-06-01' \
-H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" ``` -#### Response +##### Response (200) ```json {
"workspace_id": "workspace_id" } ``` - -## Domain Types - -### Workspace Create Response - -- `WorkspaceCreateResponse object { created_by_actor_id, implicit, service_account_id, 3 more }` - - - `created_by_actor_id: string or null` - - Tagged ID (`user_...`/`svac_...`) of the actor who created this membership. - - - `implicit: boolean or null` - - True when this is the implicit default-workspace membership every service account has when no explicit membership exists. Implicit memberships have role workspace_user and cannot be removed. - - - `service_account_id: string` - - Tagged service account ID (`svac_...`). - - - `type: "service_account_workspace_member"` - - - `"service_account_workspace_member"` - - - `workspace_id: string` - - Tagged workspace ID (`wrkspc_...`). - - - `workspace_role: "workspace_admin" or "workspace_billing" or "workspace_developer" or 2 more` - - Role of the service account in this workspace. Service accounts cannot hold the `workspace_billing` role. - - - `"workspace_admin"` - - - `"workspace_billing"` - - - `"workspace_developer"` - - - `"workspace_restricted_developer"` - - - `"workspace_user"` - -### Workspace List Response - -- `WorkspaceListResponse object { created_by_actor_id, implicit, service_account_id, 3 more }` - - - `created_by_actor_id: string or null` - - Tagged ID (`user_...`/`svac_...`) of the actor who created this membership. - - - `implicit: boolean or null` - - True when this is the implicit default-workspace membership every service account has when no explicit membership exists. Implicit memberships have role workspace_user and cannot be removed. - - - `service_account_id: string` - - Tagged service account ID (`svac_...`). - - - `type: "service_account_workspace_member"` - - - `"service_account_workspace_member"` - - - `workspace_id: string` - - Tagged workspace ID (`wrkspc_...`). - - - `workspace_role: "workspace_admin" or "workspace_billing" or "workspace_developer" or 2 more` - - Role of the service account in this workspace. Service accounts cannot hold the `workspace_billing` role. - - - `"workspace_admin"` - - - `"workspace_billing"` - - - `"workspace_developer"` - - - `"workspace_restricted_developer"` - - - `"workspace_user"` - -### Workspace Delete Response - -- `WorkspaceDeleteResponse object { service_account_id, type, workspace_id }` - - - `service_account_id: string` - - Tagged service account ID (`svac_...`) named in the delete request. Removal is idempotent; see the endpoint description for the implicit-membership no-op. - - - `type: "service_account_workspace_member_deleted"` - - - `"service_account_workspace_member_deleted"` - - - `workspace_id: string` - - Tagged workspace ID (`wrkspc_...`) named in the delete request.