Repository Public
1---2title: Admin API3url: https://platform.claude.com/docs/en/manage-claude/admin-api4description: Manage organization members, workspaces, invites, and API keys programmatically with the Admin API, using an Admin API key, an `org:admin` OAuth token, or a personal or service account key.5---67<Tip>8 **The Admin API is unavailable for individual accounts.** To collaborate with teammates and add members, set up your organization in **Console → Settings → Organization**.9</Tip>1011The [Admin API](https://platform.claude.com/docs/en/api/admin) lets you manage your organization's members, workspaces, invites, and API keys programmatically instead of by hand in the [Claude Console](https://platform.claude.com/).1213<Check>14 **The Admin API requires special access**1516 The Admin API accepts three credentials:1718 * An **Admin API key** (starting with `sk-ant-admin...`) sent in the `x-api-key` header. Only organization members with the admin role can provision one. See [Create an Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys).19 * An **OAuth bearer token** with the `org:admin` scope sent in the `authorization: Bearer` header. Only members with the admin, owner, or primary owner role can obtain one. See [Obtain an OAuth bearer token](https://platform.claude.com/docs/en/manage-claude/admin-api#oauth-bearer-token).20 * A **personal key** or **service account key** that isn't scoped to a specific workspace, sent in the `x-api-key` header. The key has the same permissions as the linked account. See [Key types](https://platform.claude.com/docs/en/manage-claude/authentication#key-types).21</Check>2223<Note>24 **Claude Enterprise:** Claude Enterprise (claude.ai) organizations call the Admin API with a scoped API key created in claude.ai. From this page, only the members and invites endpoints apply to them. They also get Enterprise-only endpoints: group and custom-role reads, and [spend limits](https://platform.claude.com/docs/en/manage-claude/spend-limits-api). See [User management](https://platform.claude.com/docs/en/manage-claude/user-management).25</Note>2627<Note>28 **Claude Platform on AWS:** Only the workspace endpoints (create, get, list, update, and archive on `/v1/organizations/workspaces`) and the external key endpoints (register, get, list, update, and delete on `/v1/organizations/external_keys`, for [CMEK](https://platform.claude.com/docs/en/manage-claude/cmek-aws-kms#claude-platform-on-aws); there is no validate endpoint, because keys are validated when attached to a workspace) are available on Claude Platform on AWS. Organization members, workspace members, invites, API keys, and the usage, cost, and rate limit reports aren't. See [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws).29</Note>3031## Authentication3233Authenticate with any of the three credentials. An Admin API key covers most endpoints. The service-account, federation-issuer, and federation-rule endpoints accept only an `org:admin` OAuth token. Send a personal key or service account key in the `x-api-key` header, as you would an Admin API key. The following examples call the [organization info endpoint](https://platform.claude.com/docs/en/manage-claude/admin-api#accessing-organization-info) with an OAuth token and with an Admin API key.3435The Python, TypeScript, C#, Go, Java, PHP, and Ruby SDKs expose the Admin API under `client.beta.organization`, and the `ant` CLI under `ant beta:organization`. The examples on this page use the default client, which reads an Admin API key from `ANTHROPIC_API_KEY` or an OAuth bearer token from `ANTHROPIC_AUTH_TOKEN`. SDK list methods in Python, TypeScript, C#, Go, and Java return an iterator that fetches more pages on demand, so `limit` sets the page size, not the total. The PHP, Ruby, and curl examples return one page. In the CLI, `--limit` caps the results on the member, invite, workspace, workspace-member, and API-key lists. For each endpoint's parameters and responses, see the [Admin API reference](https://platform.claude.com/docs/en/api/admin).3637### OAuth bearer token3839Log in with the [`ant` CLI](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart) under a dedicated profile with the `org:admin` scope (see [Admin access](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#admin-access)), then export the bearer token. `--profile admin` stores the `org:admin` credential under its own profile and makes it the CLI's active profile. The exported variable applies to every SDK and CLI call in that shell. Use a shell you reserve for administration, unset the variable when you're done, and switch the CLI back with `ant profile activate default`:4041```bash CLI42ant auth login --profile admin --scope "org:admin"43export ANTHROPIC_AUTH_TOKEN=$(ant auth print-credentials --profile admin --access-token)44```4546Interactive tokens are short-lived. If requests start returning 401, re-run the `export` command to refresh the token.4748The SDKs and the `ant` CLI read `ANTHROPIC_AUTH_TOKEN` automatically. Leave `ANTHROPIC_API_KEY` unset in the same shell so they send the bearer token. Automated workloads skip the login: they authenticate through workload identity federation, and the SDKs and CLI perform the token exchange from the federation environment variables. See [Bootstrap a workload to manage WIF](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#bootstrap-a-workload-to-manage-wif).4950Call the Admin API with the exported token:5152<CodeGroup>53 ```bash cURL54 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/me" \55 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \56 -H "anthropic-version: 2023-06-01"57 ```5859 ```bash CLI60 ant beta:organization retrieve61 ```6263 ```python Python64 client = anthropic.Anthropic()6566 organization = client.beta.organization.retrieve()6768 print(f"id: {organization.id}")69 print(f"name: {organization.name}")70 ```7172 ```typescript TypeScript73 const client = new Anthropic();7475 const organization = await client.beta.organization.retrieve();7677 console.log(`id: ${organization.id}`);78 console.log(`name: ${organization.name}`);79 ```8081 ```csharp C#82 AnthropicClient client = new();8384 var organization = await client.Beta.Organization.Retrieve();8586 Console.WriteLine($"id: {organization.ID}");87 Console.WriteLine($"name: {organization.Name}");88 ```8990 ```go Go91 client := anthropic.NewClient()9293 organization, err := client.Beta.Organization.Get(context.Background())94 if err != nil {95 log.Fatal(err)96 }9798 fmt.Printf("id: %s\n", organization.ID)99 fmt.Printf("name: %s\n", organization.Name)100 ```101102 ```java Java103 AnthropicClient client = AnthropicOkHttpClient.fromEnv();104105 var organization = client.beta().organization().retrieve();106107 IO.println("id: " + organization.id());108 IO.println("name: " + organization.name());109 ```110111 ```php PHP112 $client = new Client();113114 $organization = $client->beta->organization->retrieve();115116 echo "id: {$organization->id}\n";117 echo "name: {$organization->name}\n";118 ```119120 ```ruby Ruby121 client = Anthropic::Client.new122123 organization = client.beta.organization.retrieve124125 puts "id: #{organization.id}"126 puts "name: #{organization.name}"127 ```128</CodeGroup>129130An `org:admin` token grants access to the whole organization, regardless of the workspace the underlying profile or [federation rule](https://platform.claude.com/docs/en/manage-claude/admin-api#federation-rules) is bound to.131132For CI and other non-interactive workloads, mint the token with Workload Identity Federation instead of logging in interactively. See [Manage WIF with the Admin API](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#workload-ci-and-automation).133134### Admin API key135136To create an Admin API key for your organization type, see [Create an Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys).137138<CodeGroup>139 ```bash cURL140 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/me" \141 -H "x-api-key: $ANTHROPIC_API_KEY" \142 -H "anthropic-version: 2023-06-01"143 ```144145 ```bash CLI146 ant beta:organization retrieve147 ```148149 ```python Python150 client = anthropic.Anthropic()151152 organization = client.beta.organization.retrieve()153154 print(f"id: {organization.id}")155 print(f"name: {organization.name}")156 ```157158 ```typescript TypeScript159 const client = new Anthropic();160161 const organization = await client.beta.organization.retrieve();162163 console.log(`id: ${organization.id}`);164 console.log(`name: ${organization.name}`);165 ```166167 ```csharp C#168 AnthropicClient client = new();169170 var organization = await client.Beta.Organization.Retrieve();171172 Console.WriteLine($"id: {organization.ID}");173 Console.WriteLine($"name: {organization.Name}");174 ```175176 ```go Go177 client := anthropic.NewClient()178179 organization, err := client.Beta.Organization.Get(context.Background())180 if err != nil {181 log.Fatal(err)182 }183184 fmt.Printf("id: %s\n", organization.ID)185 fmt.Printf("name: %s\n", organization.Name)186 ```187188 ```java Java189 AnthropicClient client = AnthropicOkHttpClient.fromEnv();190191 var organization = client.beta().organization().retrieve();192193 IO.println("id: " + organization.id());194 IO.println("name: " + organization.name());195 ```196197 ```php PHP198 $client = new Client();199200 $organization = $client->beta->organization->retrieve();201202 echo "id: {$organization->id}\n";203 echo "name: {$organization->name}\n";204 ```205206 ```ruby Ruby207 client = Anthropic::Client.new208209 organization = client.beta.organization.retrieve210211 puts "id: #{organization.id}"212 puts "name: #{organization.name}"213 ```214</CodeGroup>215216## How the Admin API works217218Authenticate with any credential from [Authentication](https://platform.claude.com/docs/en/manage-claude/admin-api#authentication), then manage the following resources:219220* Organization members and their roles221* Organization invites222* Workspaces and their members223* API keys224* Service accounts, federation issuers, and federation rules (`org:admin` OAuth token only)225226Common uses include automating onboarding and offboarding, managing workspace access, and auditing API keys.227228## Organization roles and permissions229230There are five organization-level roles. For details, see [API Console roles and permissions](https://support.claude.com/en/articles/10186004-api-console-roles-and-permissions).231232| Role | Permissions |233| ------------------ | ------------------------------------------------------------------------------ |234| user | Can use playground |235| claude\_code\_user | Can use playground and [Claude Code](https://code.claude.com/docs/en/overview) |236| developer | Can use playground and manage API keys |237| billing | Can use playground and manage billing details |238| admin | Can do all of the preceding, plus manage users |239240Organization owners and primary owners have all admin permissions and can also manage admins. All references to the admin role on this page also apply to owners and primary owners.241242## Key concepts243244### Organization members245246List [organization members](https://platform.claude.com/docs/en/api/admin-api/users/get-user), update their roles, and remove them.247248List the members of your organization:249250<CodeGroup>251 ```bash cURL252 curl "https://api.anthropic.com/v1/organizations/users?limit=10" \253 -H "x-api-key: $ANTHROPIC_API_KEY" \254 -H "anthropic-version: 2023-06-01"255 ```256257 ```bash CLI258 ant beta:organization:users list --limit 10259 ```260261 ```python Python262 client = anthropic.Anthropic()263264 users = client.beta.organization.users.list(limit=10)265266 # Automatically fetches more pages as needed.267 for user in users:268 print(f"{user.id}: {user.email} ({user.role})")269 ```270271 ```typescript TypeScript272 const client = new Anthropic();273274 const users = await client.beta.organization.users.list({ limit: 10 });275276 for await (const user of users) {277 console.log(`${user.id}: ${user.email} (${user.role})`);278 }279 ```280281 ```csharp C#282 AnthropicClient client = new();283284 var page = await client.Beta.Organization.Users.List(new() { Limit = 10 });285286 await foreach (var user in page.Paginate())287 {288 Console.WriteLine($"{user.ID}: {user.Email} ({user.Role.Raw()})");289 }290 ```291292 ```go Go293 client := anthropic.NewClient()294295 users := client.Beta.Organization.Users.ListAutoPaging(context.Background(), anthropic.BetaOrganizationUserListParams{296 Limit: anthropic.Int(10),297 })298299 for users.Next() {300 user := users.Current()301 fmt.Printf("%s: %s (%s)\n", user.ID, user.Email, user.Role)302 }303 if err := users.Err(); err != nil {304 log.Fatal(err)305 }306 ```307308 ```java Java309 import com.anthropic.models.beta.organization.users.UserListParams;310311 void main() {312 AnthropicClient client = AnthropicOkHttpClient.fromEnv();313314 var params = UserListParams.builder()315 .limit(10)316 .build();317 var users = client.beta().organization().users().list(params);318319 for (var user : users.autoPager()) {320 IO.println(user.id() + ": " + user.email() + " (" + user.role().asString() + ")");321 }322 }323 ```324325 ```php PHP326 $client = new Client();327328 $users = $client->beta->organization->users->list(limit: 10);329330 foreach ($users->getItems() as $user) {331 echo "{$user->id}: {$user->email} ({$user->role})\n";332 }333 ```334335 ```ruby Ruby336 client = Anthropic::Client.new337338 users = client.beta.organization.users.list(limit: 10)339340 users.data.each do |user|341 puts "#{user.id}: #{user.email} (#{user.role})"342 end343 ```344</CodeGroup>345346Update a member's role:347348<CodeGroup>349 ```bash cURL350 curl "https://api.anthropic.com/v1/organizations/users/user_01XyDMpzjS89pFZXqSFUBDr6" \351 -H "x-api-key: $ANTHROPIC_API_KEY" \352 -H "anthropic-version: 2023-06-01" \353 -H "content-type: application/json" \354 -d '{"role": "developer"}'355 ```356357 ```bash CLI358 ant beta:organization:users update \359 --user-id user_01XyDMpzjS89pFZXqSFUBDr6 \360 --role developer361 ```362363 ```python Python364 client = anthropic.Anthropic()365366 user = client.beta.organization.users.update(367 "user_01XyDMpzjS89pFZXqSFUBDr6", role="developer"368 )369370 print(f"id: {user.id}")371 print(f"role: {user.role}")372 ```373374 ```typescript TypeScript375 const client = new Anthropic();376377 const user = await client.beta.organization.users.update("user_01XyDMpzjS89pFZXqSFUBDr6", {378 role: "developer"379 });380381 console.log(`id: ${user.id}`);382 console.log(`role: ${user.role}`);383 ```384385 ```csharp C#386 using Anthropic.Models.Beta.Organization.Users;387 // ...388389 AnthropicClient client = new();390391 var user = await client.Beta.Organization.Users.Update(392 "user_01XyDMpzjS89pFZXqSFUBDr6",393 new() { Role = Role.Developer }394 );395396 Console.WriteLine($"id: {user.ID}");397 Console.WriteLine($"role: {user.Role.Raw()}");398 ```399400 ```go Go401 client := anthropic.NewClient()402403 user, err := client.Beta.Organization.Users.Update(404 context.Background(),405 "user_01XyDMpzjS89pFZXqSFUBDr6",406 anthropic.BetaOrganizationUserUpdateParams{407 Role: anthropic.BetaOrganizationUserUpdateParamsRoleDeveloper,408 },409 )410 if err != nil {411 log.Fatal(err)412 }413414 fmt.Printf("id: %s\n", user.ID)415 fmt.Printf("role: %s\n", user.Role)416 ```417418 ```java Java419 import com.anthropic.models.beta.organization.users.UserUpdateParams;420421 void main() {422 AnthropicClient client = AnthropicOkHttpClient.fromEnv();423424 var params = UserUpdateParams.builder()425 .role(UserUpdateParams.Role.DEVELOPER)426 .build();427 var user = client.beta().organization().users()428 .update("user_01XyDMpzjS89pFZXqSFUBDr6", params);429430 IO.println("id: " + user.id());431 IO.println("role: " + user.role().asString());432 }433 ```434435 ```php PHP436 use Anthropic\Beta\Organization\Users\UserUpdateParams\Role;437 // ...438439 $client = new Client();440441 $user = $client->beta->organization->users->update(442 userID: 'user_01XyDMpzjS89pFZXqSFUBDr6',443 role: Role::DEVELOPER,444 );445446 echo "id: {$user->id}\n";447 echo "role: {$user->role}\n";448 ```449450 ```ruby Ruby451 client = Anthropic::Client.new452453 user_id = "user_01XyDMpzjS89pFZXqSFUBDr6"454 user = client.beta.organization.users.update(user_id, role: :developer)455456 puts "id: #{user.id}"457 puts "role: #{user.role}"458 ```459</CodeGroup>460461Remove a member from the organization:462463<CodeGroup>464 ```bash cURL465 curl -X DELETE "https://api.anthropic.com/v1/organizations/users/user_01XyDMpzjS89pFZXqSFUBDr6" \466 -H "x-api-key: $ANTHROPIC_API_KEY" \467 -H "anthropic-version: 2023-06-01"468 ```469470 ```bash CLI471 ant beta:organization:users remove --user-id user_01XyDMpzjS89pFZXqSFUBDr6472 ```473474 ```python Python475 client = anthropic.Anthropic()476477 removed_user = client.beta.organization.users.remove("user_01XyDMpzjS89pFZXqSFUBDr6")478479 print(f"id: {removed_user.id}")480 ```481482 ```typescript TypeScript483 const client = new Anthropic();484485 const removedUser = await client.beta.organization.users.remove(486 "user_01XyDMpzjS89pFZXqSFUBDr6"487 );488489 console.log(`id: ${removedUser.id}`);490 ```491492 ```csharp C#493 AnthropicClient client = new();494495 var removedUser = await client.Beta.Organization.Users.Remove("user_01XyDMpzjS89pFZXqSFUBDr6");496497 Console.WriteLine($"id: {removedUser.ID}");498 ```499500 ```go Go501 client := anthropic.NewClient()502503 removedUser, err := client.Beta.Organization.Users.Remove(context.Background(), "user_01XyDMpzjS89pFZXqSFUBDr6")504 if err != nil {505 log.Fatal(err)506 }507508 fmt.Printf("id: %s\n", removedUser.ID)509 ```510511 ```java Java512 AnthropicClient client = AnthropicOkHttpClient.fromEnv();513514 var removedUser = client.beta().organization().users()515 .remove("user_01XyDMpzjS89pFZXqSFUBDr6");516517 IO.println("id: " + removedUser.id());518 ```519520 ```php PHP521 $client = new Client();522523 $removedUser = $client->beta->organization->users->remove(524 userID: 'user_01XyDMpzjS89pFZXqSFUBDr6',525 );526527 echo "id: {$removedUser->id}\n";528 ```529530 ```ruby Ruby531 client = Anthropic::Client.new532533 user_id = "user_01XyDMpzjS89pFZXqSFUBDr6"534 removed_user = client.beta.organization.users.remove(user_id)535536 puts "id: #{removed_user.id}"537 ```538</CodeGroup>539540### Organization invites541542Invite users to your organization and manage pending [invites](https://platform.claude.com/docs/en/api/admin-api/invites/get-invite).543544Invite a user to your organization:545546<CodeGroup>547 ```bash cURL548 curl "https://api.anthropic.com/v1/organizations/invites" \549 -H "x-api-key: $ANTHROPIC_API_KEY" \550 -H "anthropic-version: 2023-06-01" \551 -H "content-type: application/json" \552 -d '{553 "email": "user@example.com",554 "role": "developer"555 }'556 ```557558 ```bash CLI559 ant beta:organization:invites create --email user@example.com --role developer560 ```561562 ```python Python563 client = anthropic.Anthropic()564565 invite = client.beta.organization.invites.create(566 email="user@example.com", role="developer"567 )568569 print(f"id: {invite.id}")570 print(f"email: {invite.email}")571 print(f"status: {invite.status}")572 print(f"expires_at: {invite.expires_at}")573 ```574575 ```typescript TypeScript576 const client = new Anthropic();577578 const invite = await client.beta.organization.invites.create({579 email: "user@example.com",580 role: "developer"581 });582583 console.log(`id: ${invite.id}`);584 console.log(`email: ${invite.email}`);585 console.log(`status: ${invite.status}`);586 console.log(`expires_at: ${invite.expires_at}`);587 ```588589 ```csharp C#590 using Anthropic.Models.Beta.Organization.Invites;591 // ...592593 AnthropicClient client = new();594595 var invite = await client.Beta.Organization.Invites.Create(new()596 {597 Email = "user@example.com",598 Role = Role.Developer599 });600601 Console.WriteLine($"id: {invite.ID}");602 Console.WriteLine($"email: {invite.Email}");603 Console.WriteLine($"status: {invite.Status.Raw()}");604 Console.WriteLine($"expires_at: {invite.ExpiresAt:O}");605 ```606607 ```go Go608 client := anthropic.NewClient()609610 invite, err := client.Beta.Organization.Invites.New(context.Background(), anthropic.BetaOrganizationInviteNewParams{611 Email: "user@example.com",612 Role: anthropic.BetaOrganizationInviteNewParamsRoleDeveloper,613 })614 if err != nil {615 log.Fatal(err)616 }617618 fmt.Printf("id: %s\n", invite.ID)619 fmt.Printf("email: %s\n", invite.Email)620 fmt.Printf("status: %s\n", invite.Status)621 fmt.Printf("expires_at: %s\n", invite.ExpiresAt.Format(time.RFC3339))622 ```623624 ```java Java625 import com.anthropic.models.beta.organization.invites.InviteCreateParams;626627 void main() {628 AnthropicClient client = AnthropicOkHttpClient.fromEnv();629630 var params = InviteCreateParams.builder()631 .email("user@example.com")632 .role(InviteCreateParams.Role.DEVELOPER)633 .build();634 var invite = client.beta().organization().invites().create(params);635636 IO.println("id: " + invite.id());637 IO.println("email: " + invite.email());638 IO.println("status: " + invite.status().asString());639 IO.println("expires_at: " + invite.expiresAt());640 }641 ```642643 ```php PHP644 use Anthropic\Beta\Organization\Invites\InviteCreateParams\Role;645 // ...646647 $client = new Client();648649 $invite = $client->beta->organization->invites->create(650 email: 'user@example.com',651 role: Role::DEVELOPER,652 );653654 echo "id: {$invite->id}\n";655 echo "email: {$invite->email}\n";656 echo "status: {$invite->status}\n";657 echo "expires_at: {$invite->expiresAt->format(DATE_ATOM)}\n";658 ```659660 ```ruby Ruby661 client = Anthropic::Client.new662663 invite = client.beta.organization.invites.create(email: "user@example.com", role: :developer)664665 puts "id: #{invite.id}"666 puts "email: #{invite.email}"667 puts "status: #{invite.status}"668 puts "expires_at: #{invite.expires_at.iso8601}"669 ```670</CodeGroup>671672List pending invites:673674<CodeGroup>675 ```bash cURL676 curl "https://api.anthropic.com/v1/organizations/invites?limit=10" \677 -H "x-api-key: $ANTHROPIC_API_KEY" \678 -H "anthropic-version: 2023-06-01"679 ```680681 ```bash CLI682 ant beta:organization:invites list --limit 10683 ```684685 ```python Python686 client = anthropic.Anthropic()687688 invites = client.beta.organization.invites.list(limit=10)689690 # Automatically fetches more pages as needed.691 for invite in invites:692 print(f"{invite.id}: {invite.email} ({invite.status})")693 ```694695 ```typescript TypeScript696 const client = new Anthropic();697698 const invites = await client.beta.organization.invites.list({ limit: 10 });699700 for await (const invite of invites) {701 console.log(`${invite.id}: ${invite.email} (${invite.status})`);702 }703 ```704705 ```csharp C#706 AnthropicClient client = new();707708 var page = await client.Beta.Organization.Invites.List(new() { Limit = 10 });709710 await foreach (var invite in page.Paginate())711 {712 Console.WriteLine($"{invite.ID}: {invite.Email} ({invite.Status.Raw()})");713 }714 ```715716 ```go Go717 client := anthropic.NewClient()718719 invites := client.Beta.Organization.Invites.ListAutoPaging(context.Background(), anthropic.BetaOrganizationInviteListParams{720 Limit: anthropic.Int(10),721 })722723 for invites.Next() {724 invite := invites.Current()725 fmt.Printf("%s: %s (%s)\n", invite.ID, invite.Email, invite.Status)726 }727 if err := invites.Err(); err != nil {728 log.Fatal(err)729 }730 ```731732 ```java Java733 import com.anthropic.models.beta.organization.invites.InviteListParams;734735 void main() {736 AnthropicClient client = AnthropicOkHttpClient.fromEnv();737738 var params = InviteListParams.builder()739 .limit(10)740 .build();741 var invites = client.beta().organization().invites().list(params);742743 for (var invite : invites.autoPager()) {744 IO.println(invite.id() + ": " + invite.email() + " (" + invite.status().asString() + ")");745 }746 }747 ```748749 ```php PHP750 $client = new Client();751752 $invites = $client->beta->organization->invites->list(limit: 10);753754 foreach ($invites->getItems() as $invite) {755 echo "{$invite->id}: {$invite->email} ({$invite->status})\n";756 }757 ```758759 ```ruby Ruby760 client = Anthropic::Client.new761762 invites = client.beta.organization.invites.list(limit: 10)763764 invites.data.each do |invite|765 puts "#{invite.id}: #{invite.email} (#{invite.status})"766 end767 ```768</CodeGroup>769770Delete an invite:771772<CodeGroup>773 ```bash cURL774 curl -X DELETE "https://api.anthropic.com/v1/organizations/invites/invite_015gWxHNr6h6TdRPZTmuCGnn" \775 -H "x-api-key: $ANTHROPIC_API_KEY" \776 -H "anthropic-version: 2023-06-01"777 ```778779 ```bash CLI780 ant beta:organization:invites delete --invite-id invite_015gWxHNr6h6TdRPZTmuCGnn781 ```782783 ```python Python784 client = anthropic.Anthropic()785786 deleted_invite = client.beta.organization.invites.delete(787 "invite_015gWxHNr6h6TdRPZTmuCGnn"788 )789790 print(f"id: {deleted_invite.id}")791 ```792793 ```typescript TypeScript794 const client = new Anthropic();795796 const deletedInvite = await client.beta.organization.invites.delete(797 "invite_015gWxHNr6h6TdRPZTmuCGnn"798 );799800 console.log(`id: ${deletedInvite.id}`);801 ```802803 ```csharp C#804 AnthropicClient client = new();805806 var deletedInvite = await client.Beta.Organization.Invites.Delete(807 "invite_015gWxHNr6h6TdRPZTmuCGnn"808 );809810 Console.WriteLine($"id: {deletedInvite.ID}");811 ```812813 ```go Go814 client := anthropic.NewClient()815816 deletedInvite, err := client.Beta.Organization.Invites.Delete(context.Background(), "invite_015gWxHNr6h6TdRPZTmuCGnn")817 if err != nil {818 log.Fatal(err)819 }820821 fmt.Printf("id: %s\n", deletedInvite.ID)822 ```823824 ```java Java825 AnthropicClient client = AnthropicOkHttpClient.fromEnv();826827 var deletedInvite = client.beta().organization().invites()828 .delete("invite_015gWxHNr6h6TdRPZTmuCGnn");829830 IO.println("id: " + deletedInvite.id());831 ```832833 ```php PHP834 $client = new Client();835836 $deletedInvite = $client->beta->organization->invites->delete(837 inviteID: 'invite_015gWxHNr6h6TdRPZTmuCGnn',838 );839840 echo "id: {$deletedInvite->id}\n";841 ```842843 ```ruby Ruby844 client = Anthropic::Client.new845846 invite_id = "invite_015gWxHNr6h6TdRPZTmuCGnn"847 deleted_invite = client.beta.organization.invites.delete(invite_id)848849 puts "id: #{deleted_invite.id}"850 ```851</CodeGroup>852853### Workspaces854855See [Workspaces](https://platform.claude.com/docs/en/manage-claude/workspaces) for Console and API examples.856857### Workspace members858859Manage [user access to specific workspaces](https://platform.claude.com/docs/en/api/admin-api/workspace_members/get-workspace-member):860861Add a member to a workspace:862863<CodeGroup>864 ```bash cURL865 curl "https://api.anthropic.com/v1/organizations/workspaces/wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ/members" \866 -H "x-api-key: $ANTHROPIC_API_KEY" \867 -H "anthropic-version: 2023-06-01" \868 -H "content-type: application/json" \869 -d '{870 "user_id": "user_01XyDMpzjS89pFZXqSFUBDr6",871 "workspace_role": "workspace_developer"872 }'873 ```874875 ```bash CLI876 ant beta:organization:workspaces:members add \877 --workspace-id wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ \878 --user-id user_01XyDMpzjS89pFZXqSFUBDr6 \879 --workspace-role workspace_developer880 ```881882 ```python Python883 client = anthropic.Anthropic()884885 member = client.beta.organization.workspaces.members.add(886 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",887 user_id="user_01XyDMpzjS89pFZXqSFUBDr6",888 workspace_role="workspace_developer",889 )890891 print(f"user_id: {member.user_id}")892 print(f"workspace_role: {member.workspace_role}")893 ```894895 ```typescript TypeScript896 const client = new Anthropic();897898 const member = await client.beta.organization.workspaces.members.add(899 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",900 {901 user_id: "user_01XyDMpzjS89pFZXqSFUBDr6",902 workspace_role: "workspace_developer"903 }904 );905906 console.log(`user_id: ${member.user_id}`);907 console.log(`workspace_role: ${member.workspace_role}`);908 ```909910 ```csharp C#911 using Anthropic.Models.Beta.Organization.Workspaces;912913 AnthropicClient client = new();914915 var member = await client.Beta.Organization.Workspaces.Members.Add(916 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",917 new()918 {919 UserID = "user_01XyDMpzjS89pFZXqSFUBDr6",920 WorkspaceRole = BetaNoBillingWorkspaceRole.WorkspaceDeveloper921 }922 );923924 Console.WriteLine($"user_id: {member.UserID}");925 Console.WriteLine($"workspace_role: {member.WorkspaceRole.Raw()}");926 ```927928 ```go Go929 client := anthropic.NewClient()930931 member, err := client.Beta.Organization.Workspaces.Members.Add(932 context.Background(),933 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",934 anthropic.BetaOrganizationWorkspaceMemberAddParams{935 UserID: "user_01XyDMpzjS89pFZXqSFUBDr6",936 WorkspaceRole: anthropic.BetaNoBillingWorkspaceRoleWorkspaceDeveloper,937 },938 )939 if err != nil {940 log.Fatal(err)941 }942943 fmt.Printf("user_id: %s\n", member.UserID)944 fmt.Printf("workspace_role: %s\n", member.WorkspaceRole)945 ```946947 ```java Java948 import com.anthropic.models.beta.organization.workspaces.BetaNoBillingWorkspaceRole;949 import com.anthropic.models.beta.organization.workspaces.members.MemberAddParams;950951 void main() {952 AnthropicClient client = AnthropicOkHttpClient.fromEnv();953954 var params = MemberAddParams.builder()955 .userId("user_01XyDMpzjS89pFZXqSFUBDr6")956 .workspaceRole(BetaNoBillingWorkspaceRole.WORKSPACE_DEVELOPER)957 .build();958 var member = client.beta().organization().workspaces().members()959 .add("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ", params);960961 IO.println("user_id: " + member.userId());962 IO.println("workspace_role: " + member.workspaceRole().asString());963 }964 ```965966 ```php PHP967 use Anthropic\Beta\Organization\Workspaces\NoBillingWorkspaceRole;968 // ...969970 $client = new Client();971972 $member = $client->beta->organization->workspaces->members->add(973 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',974 userID: 'user_01XyDMpzjS89pFZXqSFUBDr6',975 workspaceRole: NoBillingWorkspaceRole::WORKSPACE_DEVELOPER,976 );977978 echo "user_id: {$member->userID}\n";979 echo "workspace_role: {$member->workspaceRole}\n";980 ```981982 ```ruby Ruby983 client = Anthropic::Client.new984985 workspace_id = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"986 member = client.beta.organization.workspaces.members.add(987 workspace_id,988 user_id: "user_01XyDMpzjS89pFZXqSFUBDr6",989 workspace_role: :workspace_developer990 )991992 puts "user_id: #{member.user_id}"993 puts "workspace_role: #{member.workspace_role}"994 ```995</CodeGroup>996997List the members of a workspace:998999<CodeGroup>1000 ```bash cURL1001 curl "https://api.anthropic.com/v1/organizations/workspaces/wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ/members?limit=10" \1002 -H "x-api-key: $ANTHROPIC_API_KEY" \1003 -H "anthropic-version: 2023-06-01"1004 ```10051006 ```bash CLI1007 ant beta:organization:workspaces:members list \1008 --workspace-id wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ \1009 --limit 101010 ```10111012 ```python Python1013 client = anthropic.Anthropic()10141015 members = client.beta.organization.workspaces.members.list(1016 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ", limit=101017 )10181019 # Automatically fetches more pages as needed.1020 for member in members:1021 print(f"{member.user_id}: {member.workspace_role}")1022 ```10231024 ```typescript TypeScript1025 const client = new Anthropic();10261027 const members = await client.beta.organization.workspaces.members.list(1028 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1029 { limit: 10 }1030 );10311032 for await (const member of members) {1033 console.log(`${member.user_id}: ${member.workspace_role}`);1034 }1035 ```10361037 ```csharp C#1038 AnthropicClient client = new();10391040 var page = await client.Beta.Organization.Workspaces.Members.List(1041 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1042 new() { Limit = 10 }1043 );10441045 await foreach (var member in page.Paginate())1046 {1047 Console.WriteLine($"{member.UserID}: {member.WorkspaceRole.Raw()}");1048 }1049 ```10501051 ```go Go1052 client := anthropic.NewClient()10531054 members := client.Beta.Organization.Workspaces.Members.ListAutoPaging(1055 context.Background(),1056 "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1057 anthropic.BetaOrganizationWorkspaceMemberListParams{1058 Limit: anthropic.Int(10),1059 },1060 )10611062 for members.Next() {1063 member := members.Current()1064 fmt.Printf("%s: %s\n", member.UserID, member.WorkspaceRole)1065 }1066 if err := members.Err(); err != nil {1067 log.Fatal(err)1068 }1069 ```10701071 ```java Java1072 import com.anthropic.models.beta.organization.workspaces.members.MemberListParams;10731074 void main() {1075 AnthropicClient client = AnthropicOkHttpClient.fromEnv();10761077 var params = MemberListParams.builder()1078 .limit(10)1079 .build();1080 var members = client.beta().organization().workspaces().members()1081 .list("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ", params);10821083 for (var member : members.autoPager()) {1084 IO.println(member.userId() + ": " + member.workspaceRole().asString());1085 }1086 }1087 ```10881089 ```php PHP1090 $client = new Client();10911092 $members = $client->beta->organization->workspaces->members->list(1093 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',1094 limit: 10,1095 );10961097 foreach ($members->getItems() as $member) {1098 echo "{$member->userID}: {$member->workspaceRole}\n";1099 }1100 ```11011102 ```ruby Ruby1103 client = Anthropic::Client.new11041105 workspace_id = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1106 members = client.beta.organization.workspaces.members.list(workspace_id, limit: 10)11071108 members.data.each do |member|1109 puts "#{member.user_id}: #{member.workspace_role}"1110 end1111 ```1112</CodeGroup>11131114Update a workspace member's role:11151116<CodeGroup>1117 ```bash cURL1118 curl "https://api.anthropic.com/v1/organizations/workspaces/wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ/members/user_01XyDMpzjS89pFZXqSFUBDr6" \1119 -H "x-api-key: $ANTHROPIC_API_KEY" \1120 -H "anthropic-version: 2023-06-01" \1121 -H "content-type: application/json" \1122 -d '{"workspace_role": "workspace_admin"}'1123 ```11241125 ```bash CLI1126 ant beta:organization:workspaces:members update \1127 --user-id user_01XyDMpzjS89pFZXqSFUBDr6 \1128 --workspace-id wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ \1129 --workspace-role workspace_admin1130 ```11311132 ```python Python1133 client = anthropic.Anthropic()11341135 member = client.beta.organization.workspaces.members.update(1136 "user_01XyDMpzjS89pFZXqSFUBDr6",1137 workspace_id="wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1138 workspace_role="workspace_admin",1139 )11401141 print(f"user_id: {member.user_id}")1142 print(f"workspace_role: {member.workspace_role}")1143 ```11441145 ```typescript TypeScript1146 const client = new Anthropic();11471148 const member = await client.beta.organization.workspaces.members.update(1149 "user_01XyDMpzjS89pFZXqSFUBDr6",1150 {1151 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1152 workspace_role: "workspace_admin"1153 }1154 );11551156 console.log(`user_id: ${member.user_id}`);1157 console.log(`workspace_role: ${member.workspace_role}`);1158 ```11591160 ```csharp C#1161 using Anthropic.Models.Beta.Organization.Workspaces;11621163 AnthropicClient client = new();11641165 var member = await client.Beta.Organization.Workspaces.Members.Update(1166 "user_01XyDMpzjS89pFZXqSFUBDr6",1167 new()1168 {1169 WorkspaceID = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1170 WorkspaceRole = BetaWorkspaceRole.WorkspaceAdmin1171 }1172 );11731174 Console.WriteLine($"user_id: {member.UserID}");1175 Console.WriteLine($"workspace_role: {member.WorkspaceRole.Raw()}");1176 ```11771178 ```go Go1179 client := anthropic.NewClient()11801181 member, err := client.Beta.Organization.Workspaces.Members.Update(1182 context.Background(),1183 "user_01XyDMpzjS89pFZXqSFUBDr6",1184 anthropic.BetaOrganizationWorkspaceMemberUpdateParams{1185 WorkspaceID: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1186 WorkspaceRole: anthropic.BetaWorkspaceRoleWorkspaceAdmin,1187 },1188 )1189 if err != nil {1190 log.Fatal(err)1191 }11921193 fmt.Printf("user_id: %s\n", member.UserID)1194 fmt.Printf("workspace_role: %s\n", member.WorkspaceRole)1195 ```11961197 ```java Java1198 import com.anthropic.models.beta.organization.workspaces.BetaWorkspaceRole;1199 import com.anthropic.models.beta.organization.workspaces.members.MemberUpdateParams;12001201 void main() {1202 AnthropicClient client = AnthropicOkHttpClient.fromEnv();12031204 var params = MemberUpdateParams.builder()1205 .workspaceId("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ")1206 .workspaceRole(BetaWorkspaceRole.WORKSPACE_ADMIN)1207 .build();1208 var member = client.beta().organization().workspaces().members()1209 .update("user_01XyDMpzjS89pFZXqSFUBDr6", params);12101211 IO.println("user_id: " + member.userId());1212 IO.println("workspace_role: " + member.workspaceRole().asString());1213 }1214 ```12151216 ```php PHP1217 use Anthropic\Beta\Organization\Workspaces\WorkspaceRole;1218 // ...12191220 $client = new Client();12211222 $member = $client->beta->organization->workspaces->members->update(1223 userID: 'user_01XyDMpzjS89pFZXqSFUBDr6',1224 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',1225 workspaceRole: WorkspaceRole::WORKSPACE_ADMIN,1226 );12271228 echo "user_id: {$member->userID}\n";1229 echo "workspace_role: {$member->workspaceRole}\n";1230 ```12311232 ```ruby Ruby1233 client = Anthropic::Client.new12341235 user_id = "user_01XyDMpzjS89pFZXqSFUBDr6"1236 member = client.beta.organization.workspaces.members.update(1237 user_id,1238 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1239 workspace_role: :workspace_admin1240 )12411242 puts "user_id: #{member.user_id}"1243 puts "workspace_role: #{member.workspace_role}"1244 ```1245</CodeGroup>12461247Remove a member from a workspace:12481249<CodeGroup>1250 ```bash cURL1251 curl -X DELETE "https://api.anthropic.com/v1/organizations/workspaces/wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ/members/user_01XyDMpzjS89pFZXqSFUBDr6" \1252 -H "x-api-key: $ANTHROPIC_API_KEY" \1253 -H "anthropic-version: 2023-06-01"1254 ```12551256 ```bash CLI1257 ant beta:organization:workspaces:members remove \1258 --user-id user_01XyDMpzjS89pFZXqSFUBDr6 \1259 --workspace-id wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ1260 ```12611262 ```python Python1263 client = anthropic.Anthropic()12641265 removed_member = client.beta.organization.workspaces.members.remove(1266 "user_01XyDMpzjS89pFZXqSFUBDr6", workspace_id="wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1267 )12681269 print(f"user_id: {removed_member.user_id}")1270 ```12711272 ```typescript TypeScript1273 const client = new Anthropic();12741275 const removedMember = await client.beta.organization.workspaces.members.remove(1276 "user_01XyDMpzjS89pFZXqSFUBDr6",1277 { workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" }1278 );12791280 console.log(`user_id: ${removedMember.user_id}`);1281 ```12821283 ```csharp C#1284 AnthropicClient client = new();12851286 var removedMember = await client.Beta.Organization.Workspaces.Members.Remove(1287 "user_01XyDMpzjS89pFZXqSFUBDr6",1288 new() { WorkspaceID = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" }1289 );12901291 Console.WriteLine($"user_id: {removedMember.UserID}");1292 ```12931294 ```go Go1295 client := anthropic.NewClient()12961297 removedMember, err := client.Beta.Organization.Workspaces.Members.Remove(1298 context.Background(),1299 "user_01XyDMpzjS89pFZXqSFUBDr6",1300 anthropic.BetaOrganizationWorkspaceMemberRemoveParams{1301 WorkspaceID: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1302 },1303 )1304 if err != nil {1305 log.Fatal(err)1306 }13071308 fmt.Printf("user_id: %s\n", removedMember.UserID)1309 ```13101311 ```java Java1312 import com.anthropic.models.beta.organization.workspaces.members.MemberRemoveParams;13131314 void main() {1315 AnthropicClient client = AnthropicOkHttpClient.fromEnv();13161317 var params = MemberRemoveParams.builder()1318 .workspaceId("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ")1319 .build();1320 var removedMember = client.beta().organization().workspaces().members()1321 .remove("user_01XyDMpzjS89pFZXqSFUBDr6", params);13221323 IO.println("user_id: " + removedMember.userId());1324 }1325 ```13261327 ```php PHP1328 $client = new Client();13291330 $removedMember = $client->beta->organization->workspaces->members->remove(1331 userID: 'user_01XyDMpzjS89pFZXqSFUBDr6',1332 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',1333 );13341335 echo "user_id: {$removedMember->userID}\n";1336 ```13371338 ```ruby Ruby1339 client = Anthropic::Client.new13401341 user_id = "user_01XyDMpzjS89pFZXqSFUBDr6"1342 removed_member = client.beta.organization.workspaces.members.remove(1343 user_id,1344 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1345 )13461347 puts "user_id: #{removed_member.user_id}"1348 ```1349</CodeGroup>13501351### API keys13521353Monitor and manage [API keys](https://platform.claude.com/docs/en/api/admin/api_keys/list). Each key in the response includes its `expires_at` timestamp (`null` for keys without an [expiration](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration)) and `principal`, the identity it acts as (see [Key types](https://platform.claude.com/docs/en/manage-claude/authentication#key-types)). For a personal key, `principal` is `{"type": "user_actor", "user_id": "user_..."}`; for a service account key, `{"type": "service_account_actor", "service_account_id": "svac_..."}`; and for a workspace key, `null`. Each key also has a `scope` object: `{"type": "workspace", "workspace_id": "wrkspc_..."}` for a key bound to one workspace, or `{"type": "organization"}` for a key that can work across any workspace the account has access to. The top-level `workspace_id` field is deprecated and is `null` both for keys bound to the Default Workspace and for keys without a workspace scope; use `scope` to tell them apart. Filtering the list by `workspace_id` with the Default Workspace's ID returns only keys bound to the Default Workspace; keys without a workspace scope aren't returned under any `workspace_id` filter.13541355List the active API keys in a workspace:13561357<CodeGroup>1358 ```bash cURL1359 curl "https://api.anthropic.com/v1/organizations/api_keys?limit=10&status=active&workspace_id=wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" \1360 -H "x-api-key: $ANTHROPIC_API_KEY" \1361 -H "anthropic-version: 2023-06-01"1362 ```13631364 ```bash CLI1365 ant beta:organization:api-keys list \1366 --limit 10 \1367 --status active \1368 --workspace-id wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ1369 ```13701371 ```python Python1372 client = anthropic.Anthropic()13731374 api_keys = client.beta.organization.api_keys.list(1375 limit=10, status="active", workspace_id="wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1376 )13771378 # Automatically fetches more pages as needed.1379 for api_key in api_keys:1380 print(f"{api_key.id}: {api_key.name} ({api_key.status})")1381 ```13821383 ```typescript TypeScript1384 const client = new Anthropic();13851386 const apiKeys = await client.beta.organization.apiKeys.list({1387 limit: 10,1388 status: "active",1389 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1390 });13911392 for await (const apiKey of apiKeys) {1393 console.log(`${apiKey.id}: ${apiKey.name} (${apiKey.status})`);1394 }1395 ```13961397 ```csharp C#1398 using Anthropic.Models.Beta.Organization.ApiKeys;13991400 AnthropicClient client = new();14011402 var page = await client.Beta.Organization.ApiKeys.List(new()1403 {1404 Limit = 10,1405 Status = ApiKeyListParamsStatus.Active,1406 WorkspaceID = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1407 });14081409 await foreach (var apiKey in page.Paginate())1410 {1411 Console.WriteLine($"{apiKey.ID}: {apiKey.Name} ({apiKey.Status.Raw()})");1412 }1413 ```14141415 ```go Go1416 client := anthropic.NewClient()14171418 apiKeys := client.Beta.Organization.APIKeys.ListAutoPaging(context.Background(), anthropic.BetaOrganizationAPIKeyListParams{1419 Limit: anthropic.Int(10),1420 Status: anthropic.BetaOrganizationAPIKeyListParamsStatusActive,1421 WorkspaceID: anthropic.String("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"),1422 })14231424 for apiKeys.Next() {1425 apiKey := apiKeys.Current()1426 fmt.Printf("%s: %s (%s)\n", apiKey.ID, apiKey.Name, apiKey.Status)1427 }1428 if err := apiKeys.Err(); err != nil {1429 log.Fatal(err)1430 }1431 ```14321433 ```java Java1434 import com.anthropic.models.beta.organization.apikeys.ApiKeyListParams;14351436 void main() {1437 AnthropicClient client = AnthropicOkHttpClient.fromEnv();14381439 var params = ApiKeyListParams.builder()1440 .limit(10)1441 .status(ApiKeyListParams.Status.ACTIVE)1442 .workspaceId("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ")1443 .build();1444 var apiKeys = client.beta().organization().apiKeys().list(params);14451446 for (var apiKey : apiKeys.autoPager()) {1447 IO.println(apiKey.id() + ": " + apiKey.name() + " (" + apiKey.status().asString() + ")");1448 }1449 }1450 ```14511452 ```php PHP1453 use Anthropic\Beta\Organization\APIKeys\APIKeyListParams\Status;1454 // ...14551456 $client = new Client();14571458 $apiKeys = $client->beta->organization->apiKeys->list(1459 limit: 10,1460 status: Status::ACTIVE,1461 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',1462 );14631464 foreach ($apiKeys->getItems() as $apiKey) {1465 echo "{$apiKey->id}: {$apiKey->name} ({$apiKey->status})\n";1466 }1467 ```14681469 ```ruby Ruby1470 client = Anthropic::Client.new14711472 api_keys = client.beta.organization.api_keys.list(1473 limit: 10,1474 status: :active,1475 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"1476 )14771478 api_keys.data.each do |api_key|1479 puts "#{api_key.id}: #{api_key.name} (#{api_key.status})"1480 end1481 ```1482</CodeGroup>14831484Rename or deactivate an API key:14851486<CodeGroup>1487 ```bash cURL1488 curl "https://api.anthropic.com/v1/organizations/api_keys/apikey_01Rj2N8SVvo6BePZj99NhmiT" \1489 -H "x-api-key: $ANTHROPIC_API_KEY" \1490 -H "anthropic-version: 2023-06-01" \1491 -H "content-type: application/json" \1492 -d '{1493 "status": "inactive",1494 "name": "New Key Name"1495 }'1496 ```14971498 ```bash CLI1499 ant beta:organization:api-keys update \1500 --api-key-id apikey_01Rj2N8SVvo6BePZj99NhmiT \1501 --status inactive \1502 --name "New Key Name"1503 ```15041505 ```python Python1506 client = anthropic.Anthropic()15071508 api_key = client.beta.organization.api_keys.update(1509 "apikey_01Rj2N8SVvo6BePZj99NhmiT", status="inactive", name="New Key Name"1510 )15111512 print(f"id: {api_key.id}")1513 print(f"name: {api_key.name}")1514 print(f"status: {api_key.status}")1515 ```15161517 ```typescript TypeScript1518 const client = new Anthropic();15191520 const apiKey = await client.beta.organization.apiKeys.update(1521 "apikey_01Rj2N8SVvo6BePZj99NhmiT",1522 {1523 status: "inactive",1524 name: "New Key Name"1525 }1526 );15271528 console.log(`id: ${apiKey.id}`);1529 console.log(`name: ${apiKey.name}`);1530 console.log(`status: ${apiKey.status}`);1531 ```15321533 ```csharp C#1534 using Anthropic.Models.Beta.Organization.ApiKeys;15351536 AnthropicClient client = new();15371538 var apiKey = await client.Beta.Organization.ApiKeys.Update(1539 "apikey_01Rj2N8SVvo6BePZj99NhmiT",1540 new()1541 {1542 Status = Status.Inactive,1543 Name = "New Key Name"1544 }1545 );15461547 Console.WriteLine($"id: {apiKey.ID}");1548 Console.WriteLine($"name: {apiKey.Name}");1549 Console.WriteLine($"status: {apiKey.Status.Raw()}");1550 ```15511552 ```go Go1553 client := anthropic.NewClient()15541555 apiKey, err := client.Beta.Organization.APIKeys.Update(1556 context.Background(),1557 "apikey_01Rj2N8SVvo6BePZj99NhmiT",1558 anthropic.BetaOrganizationAPIKeyUpdateParams{1559 Status: anthropic.BetaOrganizationAPIKeyUpdateParamsStatusInactive,1560 Name: anthropic.String("New Key Name"),1561 },1562 )1563 if err != nil {1564 log.Fatal(err)1565 }15661567 fmt.Printf("id: %s\n", apiKey.ID)1568 fmt.Printf("name: %s\n", apiKey.Name)1569 fmt.Printf("status: %s\n", apiKey.Status)1570 ```15711572 ```java Java1573 import com.anthropic.models.beta.organization.apikeys.ApiKeyUpdateParams;15741575 void main() {1576 AnthropicClient client = AnthropicOkHttpClient.fromEnv();15771578 var params = ApiKeyUpdateParams.builder()1579 .status(ApiKeyUpdateParams.Status.INACTIVE)1580 .name("New Key Name")1581 .build();1582 var apiKey = client.beta().organization().apiKeys()1583 .update("apikey_01Rj2N8SVvo6BePZj99NhmiT", params);15841585 IO.println("id: " + apiKey.id());1586 IO.println("name: " + apiKey.name());1587 IO.println("status: " + apiKey.status().asString());1588 }1589 ```15901591 ```php PHP1592 use Anthropic\Beta\Organization\APIKeys\APIKeyUpdateParams\Status;1593 // ...15941595 $client = new Client();15961597 $apiKey = $client->beta->organization->apiKeys->update(1598 apiKeyID: 'apikey_01Rj2N8SVvo6BePZj99NhmiT',1599 status: Status::INACTIVE,1600 name: 'New Key Name',1601 );16021603 echo "id: {$apiKey->id}\n";1604 echo "name: {$apiKey->name}\n";1605 echo "status: {$apiKey->status}\n";1606 ```16071608 ```ruby Ruby1609 client = Anthropic::Client.new16101611 api_key_id = "apikey_01Rj2N8SVvo6BePZj99NhmiT"1612 api_key = client.beta.organization.api_keys.update(1613 api_key_id,1614 status: :inactive,1615 name: "New Key Name"1616 )16171618 puts "id: #{api_key.id}"1619 puts "name: #{api_key.name}"1620 puts "status: #{api_key.status}"1621 ```1622</CodeGroup>16231624### Service accounts16251626Create and manage service accounts (`svac_...`), the non-human identities that [service account keys](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) and [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) tokens act as. These endpoints, like the federation-issuer and federation-rule endpoints, require an `org:admin` OAuth token. See [Manage WIF with the Admin API](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#service-accounts).16271628### Federation issuers16291630Register the OIDC identity providers (`fdis_...`) whose tokens may assert workload identity for your organization. See [Manage WIF with the Admin API](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#federation-issuers).16311632### Federation rules16331634Manage the rules (`fdrl_...`) that map issuer tokens to service accounts and scopes. See [Manage WIF with the Admin API](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#federation-rules).16351636## Accessing organization info16371638The `/v1/organizations/me` endpoint returns the organization that your credential belongs to:16391640<CodeGroup>1641 ```bash cURL1642 curl "https://api.anthropic.com/v1/organizations/me" \1643 -H "x-api-key: $ANTHROPIC_API_KEY" \1644 -H "anthropic-version: 2023-06-01"1645 ```16461647 ```bash CLI1648 ant beta:organization retrieve1649 ```16501651 ```python Python1652 client = anthropic.Anthropic()16531654 organization = client.beta.organization.retrieve()16551656 print(f"id: {organization.id}")1657 print(f"name: {organization.name}")1658 ```16591660 ```typescript TypeScript1661 const client = new Anthropic();16621663 const organization = await client.beta.organization.retrieve();16641665 console.log(`id: ${organization.id}`);1666 console.log(`name: ${organization.name}`);1667 ```16681669 ```csharp C#1670 AnthropicClient client = new();16711672 var organization = await client.Beta.Organization.Retrieve();16731674 Console.WriteLine($"id: {organization.ID}");1675 Console.WriteLine($"name: {organization.Name}");1676 ```16771678 ```go Go1679 client := anthropic.NewClient()16801681 organization, err := client.Beta.Organization.Get(context.Background())1682 if err != nil {1683 log.Fatal(err)1684 }16851686 fmt.Printf("id: %s\n", organization.ID)1687 fmt.Printf("name: %s\n", organization.Name)1688 ```16891690 ```java Java1691 AnthropicClient client = AnthropicOkHttpClient.fromEnv();16921693 var organization = client.beta().organization().retrieve();16941695 IO.println("id: " + organization.id());1696 IO.println("name: " + organization.name());1697 ```16981699 ```php PHP1700 $client = new Client();17011702 $organization = $client->beta->organization->retrieve();17031704 echo "id: {$organization->id}\n";1705 echo "name: {$organization->name}\n";1706 ```17071708 ```ruby Ruby1709 client = Anthropic::Client.new17101711 organization = client.beta.organization.retrieve17121713 puts "id: #{organization.id}"1714 puts "name: #{organization.name}"1715 ```1716</CodeGroup>17171718```json1719{1720 "id": "12345678-1234-5678-1234-567812345678",1721 "type": "organization",1722 "name": "Organization Name"1723}1724```17251726For parameter details and response schemas, see the [Organization Info API reference](https://platform.claude.com/docs/en/api/admin-api/organization/get-me).17271728## Usage and cost reports17291730Track your organization's usage and costs with the [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api).17311732## Claude Code analytics17331734Monitor developer productivity and Claude Code adoption with the [Claude Code Analytics API](https://platform.claude.com/docs/en/manage-claude/claude-code-analytics-api).17351736## Rate limits17371738Read the rate limits configured for your organization and its workspaces with the [Rate Limits API](https://platform.claude.com/docs/en/manage-claude/rate-limits-api).17391740## Compliance API17411742Retrieve audit and activity data for your organization with the [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api). Admin API keys can read only the Activity Feed. For full access, see [Set up the Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api-access).17431744## Best practices17451746* Use meaningful names and descriptions for workspaces and API keys1747* Handle errors from failed operations1748* Regularly audit member roles and permissions1749* Clean up unused workspaces and expired invites1750* Monitor API key usage, audit each key's [`expires_at`](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration), and rotate keys periodically17511752## FAQ17531754<AccordionGroup>1755 <Accordion title="What permissions are needed to use the Admin API?">1756 The Admin API accepts an Admin API key (starting with `sk-ant-admin`), an OAuth bearer token with the `org:admin` scope, or a personal key or service account key that isn't scoped to a specific workspace. Only organization members with the admin role can provision Admin API keys, and only members with the admin, owner, or primary owner role can obtain `org:admin` tokens. A personal key or service account key has the same permissions as the linked account. See [Authentication](https://platform.claude.com/docs/en/manage-claude/admin-api#authentication).1757 </Accordion>17581759 <Accordion title="Can I create new API keys through the Admin API?">1760 No. You create API keys in the Claude Console. The Admin API can only read, rename, and change the status of existing keys.1761 </Accordion>17621763 <Accordion title="What happens to API keys when removing a user?">1764 Behavior depends on the [key type](https://platform.claude.com/docs/en/manage-claude/authentication#key-types).17651766 Personal keys stop working when their user is removed from the organization. Service account keys stop working if their service account is archived, but continue to work even if the user that created them is removed. Workspace API keys continue to work. In the [Claude Code workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#claude-code-workspace), each key is bound to the member who created it and stops working when that member is removed.1767 </Accordion>17681769 <Accordion title="Can organization admins be removed through the API?">1770 No. The API can't remove members with the admin role.1771 </Accordion>17721773 <Accordion title="How long do organization invites last?">1774 Invites expire after 21 days. The expiration period isn't configurable.1775 </Accordion>1776</AccordionGroup>17771778For workspace-specific questions, see the [Workspaces FAQ](https://platform.claude.com/docs/en/manage-claude/workspaces#faq).1779