Repository Public
1---2title: Manage WIF with the Admin API3url: https://platform.claude.com/docs/en/manage-claude/wif-admin-api4description: Create and manage Workload Identity Federation service accounts, issuers, and rules programmatically for infrastructure-as-code and CI workflows.5---67The Admin API lets you create and manage [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) resources programmatically: service accounts, federation issuers, and federation rules. Use it to keep your federation configuration in infrastructure as code, provision it from CI, and reproduce it across organizations instead of clicking through the Claude Console. These endpoints share the `/v1/organizations` path prefix with the rest of the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api).89## Prerequisites1011Every request on this page authenticates with an OAuth bearer token that carries the `org:admin` scope. The scope is granted only to organization members with the admin, owner, or primary owner role, and it grants access to the whole organization: any workspace binding is ignored. There are two ways to obtain a token, and they carry different permissions: a token from your own login acts as a user, whereas a federated token acts as a service account and cannot perform every operation on this page.1213### Interactive (your terminal)1415Log in with the [`ant` CLI](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart) under a dedicated profile, requesting 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. Logging in with `--profile admin` stores the `org:admin` credential under its own profile name and also makes it the CLI's active profile, and the exported variable applies to every SDK and CLI call in that shell; so use a shell you reserve for administration, unset the variable when you are done, and switch the CLI back with `ant profile activate default`:1617```bash CLI18ant auth login --profile admin --scope "org:admin"19export ANTHROPIC_AUTH_TOKEN=$(ant auth print-credentials --profile admin --access-token)20```2122Interactive tokens are short-lived; if requests start returning 401, re-run the export command (it refreshes the token automatically).2324The SDKs and the `ant` CLI read `ANTHROPIC_AUTH_TOKEN` automatically; leave `ANTHROPIC_API_KEY` unset in the same shell, because these endpoints reject API keys and some clients prefer the key when both are set.2526### Workload (CI and automation)2728Create a federation rule with `oauth_scope: org:admin` that targets a service account whose `organization_role` is `admin`. The rule itself must be created in the Claude Console: granting a workload organization-admin access is a deliberate human action, not something automation can bootstrap for itself. The next section walks through this once-per-organization setup.2930## Bootstrap a workload to manage WIF3132One Console-created rule is enough to put the rest of your federation configuration under infrastructure as code: grant a single trusted workload the `org:admin` scope, and let that workload manage federation issuers and every workspace-scoped federation rule through this API.3334<Steps>35 <Step title="Create the org:admin rule in the Console">36 In the Claude Console, go to **Settings → Workload identity** and select **Connect workload** to create one federation rule for your automation workload, for example a GitHub Actions workflow in your infrastructure repository. Under **Advanced rule options**, set the rule's OAuth scope to `org:admin`: the wizard then creates the new service account with the Admin organization role (or asks you to pick an existing admin service account as the target).3738 <Warning>39 Match the rule to one exact workload identity, not a broad pattern. `subject_prefix` is an exact match unless it ends in `*`. For GitHub Actions, pin the subject to a protected branch, such as `repo:my-org/my-repo:ref:refs/heads/main`. A trailing wildcard such as `repo:my-org/my-repo:*` also matches `pull_request` runs, including runs triggered from forks, so anyone who could open a pull request against the repository could mint an `org:admin` token. See [Restrict which workflows can authenticate](https://platform.claude.com/docs/en/manage-claude/wif-providers/github-actions#restrict-which-workflows-can-authenticate).40 </Warning>41 </Step>4243 <Step title="Exchange the workload's identity token">44 A workload that uses one of the SDKs or the `ant` CLI does not perform the exchange itself. Point the client at the rule with the federation environment variables and construct it with no arguments, exactly as for inference in [Construct the SDK client](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#construct-the-sdk-client); the client exchanges the identity token on the first request and, before the resulting access token expires, re-reads the identity token and exchanges it again:4546 ```bash47 export ANTHROPIC_FEDERATION_RULE_ID=fdrl_... # the org:admin rule from step 148 export ANTHROPIC_ORGANIZATION_ID=00000000-0000-0000-0000-00000000000049 export ANTHROPIC_SERVICE_ACCOUNT_ID=svac_... # the rule's target service account50 export ANTHROPIC_IDENTITY_TOKEN_FILE=/path/to/jwt # or ANTHROPIC_IDENTITY_TOKEN51 # ANTHROPIC_WORKSPACE_ID is required only if the rule is enabled for all52 # workspaces or more than one; the org:admin endpoints ignore the binding.53 unset ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN # both take precedence over federation54 ```5556 The `ant` CLI reads the same variables, or takes `--federation-rule`, `--organization-id`, `--service-account-id`, and `--identity-token-file` flags. For a workload that runs more than one `ant` command, use a [federation profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#profile-configuration-file) rather than flags or environment variables: with flags or variables the CLI exchanges the identity token again in every process, and identity tokens that carry a `jti` claim (GitHub Actions tokens do) are accepted only once, so a second command would be rejected; a profile is also the only way to give the CLI a `workspace_id` for the exchange when the rule is enabled for all workspaces or more than one, because unlike the SDKs the CLI does not pass `ANTHROPIC_WORKSPACE_ID` or `--workspace-id` into the exchange. Every SDK also accepts the same settings as explicit constructor arguments, shown per language in [Construct the SDK client](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#construct-the-sdk-client). See [Environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables) and [Credential precedence](https://platform.claude.com/docs/en/manage-claude/wif-reference#credential-precedence) for the full list and ordering.5758 A workload that calls the API with curl exchanges the JWT for a short-lived `org:admin` bearer token itself, using the same [token exchange](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#authenticate-from-your-workload) as any other federated workload, and sends it in the `authorization: Bearer` header.59 </Step>6061 <Step title="Manage issuers and workspace-scoped rules through the API">62 With the client configured (or, for curl, the minted token in `ANTHROPIC_AUTH_TOKEN`), the workload creates and manages your federation configuration using the endpoints on this page.63 </Step>64</Steps>6566For the operations a workload-minted token can and cannot perform, see [Permissions and constraints](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#permissions-and-constraints). If you already created issuers, service accounts, or rules with the **Connect workload** wizard, list them with the following endpoints and import them into your infrastructure-as-code state instead of recreating them.6768## Authentication6970All endpoints live under `https://api.anthropic.com/v1/organizations/`. Every request to the federation and service-account endpoints needs the API version header and the bearer token:7172In the SDKs these endpoints are `client.beta.organization.service_accounts`, `client.beta.organization.federation.issuers`, and `client.beta.organization.federation.rules` (`ant beta:organization:service-accounts`, `federation:issuers`, and `federation:rules` in the CLI). The SDK and CLI examples construct the default client, which sends the bearer token from `ANTHROPIC_AUTH_TOKEN`, or, in an automated workload, performs the federation exchange itself as described in [Bootstrap a workload to manage WIF](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#bootstrap-a-workload-to-manage-wif). SDK list methods fetch further pages on demand, so `limit` sets the page size; the PHP and Ruby examples read one page.7374<CodeGroup>75 ```bash cURL76 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/service_accounts" \77 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \78 -H "anthropic-version: 2023-06-01"79 ```8081 ```bash CLI82 ant beta:organization:service-accounts list83 ```8485 ```python Python86 client = anthropic.Anthropic()8788 service_accounts = client.beta.organization.service_accounts.list()8990 for service_account in service_accounts:91 print(f"{service_account.id}: {service_account.name}")92 ```9394 ```typescript TypeScript95 const client = new Anthropic();9697 for await (const serviceAccount of client.beta.organization.serviceAccounts.list()) {98 console.log(`${serviceAccount.id}: ${serviceAccount.name}`);99 }100 ```101102 ```csharp C#103 AnthropicClient client = new();104105 var page = await client.Beta.Organization.ServiceAccounts.List();106107 await foreach (var serviceAccount in page.Paginate())108 {109 Console.WriteLine($"{serviceAccount.ID}: {serviceAccount.Name}");110 }111 ```112113 ```go Go114 client := anthropic.NewClient()115116 serviceAccounts := client.Beta.Organization.ServiceAccounts.ListAutoPaging(context.Background(), anthropic.BetaOrganizationServiceAccountListParams{})117118 for serviceAccounts.Next() {119 serviceAccount := serviceAccounts.Current()120 fmt.Printf("%s: %s\n", serviceAccount.ID, serviceAccount.Name)121 }122 if err := serviceAccounts.Err(); err != nil {123 log.Fatal(err)124 }125 ```126127 ```java Java128 AnthropicClient client = AnthropicOkHttpClient.fromEnv();129130 var serviceAccounts = client.beta().organization().serviceAccounts().list();131132 for (var serviceAccount : serviceAccounts.autoPager()) {133 IO.println(serviceAccount.id() + ": " + serviceAccount.name());134 }135 ```136137 ```php PHP138 $client = new Client();139140 $serviceAccounts = $client->beta->organization->serviceAccounts->list();141142 foreach ($serviceAccounts->getItems() as $serviceAccount) {143 echo "{$serviceAccount->id}: {$serviceAccount->name}\n";144 }145 ```146147 ```ruby Ruby148 client = Anthropic::Client.new149150 service_accounts = client.beta.organization.service_accounts.list151152 service_accounts.data.each do |service_account|153 puts "#{service_account.id}: #{service_account.name}"154 end155 ```156</CodeGroup>157158Admin API keys are not accepted on these endpoints; the Admin API page's `x-api-key` examples do not apply here.159160## Service accounts161162A [service account](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#service-accounts) (`svac_...`) is the non-human identity that a federated token acts as. Set `organization_role` to `developer`.163164Create a service account:165166<CodeGroup>167 ```bash cURL168 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/service_accounts" \169 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \170 -H "anthropic-version: 2023-06-01" \171 -H "content-type: application/json" \172 -d '{173 "name": "inference-worker",174 "organization_role": "developer"175 }'176 ```177178 ```bash CLI179 ant beta:organization:service-accounts create \180 --name inference-worker \181 --organization-role developer182 ```183184 ```python Python185 client = anthropic.Anthropic()186187 service_account = client.beta.organization.service_accounts.create(188 name="inference-worker", organization_role="developer"189 )190191 print(f"id: {service_account.id}")192 print(f"name: {service_account.name}")193 ```194195 ```typescript TypeScript196 const client = new Anthropic();197198 const serviceAccount = await client.beta.organization.serviceAccounts.create({199 name: "inference-worker",200 organization_role: "developer"201 });202203 console.log(`id: ${serviceAccount.id}`);204 console.log(`name: ${serviceAccount.name}`);205 ```206207 ```csharp C#208 using Anthropic.Models.Beta.Organization.ServiceAccounts;209210 AnthropicClient client = new();211212 var serviceAccount = await client.Beta.Organization.ServiceAccounts.Create(new()213 {214 Name = "inference-worker",215 OrganizationRole = OrganizationRole.Developer216 });217218 Console.WriteLine($"id: {serviceAccount.ID}");219 Console.WriteLine($"name: {serviceAccount.Name}");220 ```221222 ```go Go223 client := anthropic.NewClient()224225 serviceAccount, err := client.Beta.Organization.ServiceAccounts.New(context.Background(), anthropic.BetaOrganizationServiceAccountNewParams{226 Name: "inference-worker",227 OrganizationRole: anthropic.BetaOrganizationServiceAccountNewParamsOrganizationRoleDeveloper,228 })229 if err != nil {230 log.Fatal(err)231 }232233 fmt.Printf("id: %s\n", serviceAccount.ID)234 fmt.Printf("name: %s\n", serviceAccount.Name)235 ```236237 ```java Java238 import com.anthropic.models.beta.organization.serviceaccounts.ServiceAccountCreateParams;239240 void main() {241 AnthropicClient client = AnthropicOkHttpClient.fromEnv();242243 var params = ServiceAccountCreateParams.builder()244 .name("inference-worker")245 .organizationRole(ServiceAccountCreateParams.OrganizationRole.DEVELOPER)246 .build();247 var serviceAccount = client.beta().organization().serviceAccounts().create(params);248249 IO.println("id: " + serviceAccount.id());250 IO.println("name: " + serviceAccount.name());251 }252 ```253254 ```php PHP255 use Anthropic\Beta\Organization\ServiceAccounts\ServiceAccountCreateParams\OrganizationRole;256 // ...257258 $client = new Client();259260 $serviceAccount = $client->beta->organization->serviceAccounts->create(261 name: 'inference-worker',262 organizationRole: OrganizationRole::DEVELOPER,263 );264265 echo "id: {$serviceAccount->id}\n";266 echo "name: {$serviceAccount->name}\n";267 ```268269 ```ruby Ruby270 client = Anthropic::Client.new271272 service_account = client.beta.organization.service_accounts.create(273 name: "inference-worker",274 organization_role: :developer275 )276277 puts "id: #{service_account.id}"278 puts "name: #{service_account.name}"279 ```280</CodeGroup>281282List service accounts:283284<CodeGroup>285 ```bash cURL286 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/service_accounts?limit=20" \287 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \288 -H "anthropic-version: 2023-06-01"289 ```290291 ```bash CLI292 ant beta:organization:service-accounts list --limit 20293 ```294295 ```python Python296 client = anthropic.Anthropic()297298 service_accounts = client.beta.organization.service_accounts.list(limit=20)299300 for service_account in service_accounts:301 print(f"{service_account.id}: {service_account.name}")302 ```303304 ```typescript TypeScript305 const client = new Anthropic();306307 for await (const serviceAccount of client.beta.organization.serviceAccounts.list({308 limit: 20309 })) {310 console.log(`${serviceAccount.id}: ${serviceAccount.name}`);311 }312 ```313314 ```csharp C#315 AnthropicClient client = new();316317 var page = await client.Beta.Organization.ServiceAccounts.List(new() { Limit = 20 });318319 await foreach (var serviceAccount in page.Paginate())320 {321 Console.WriteLine($"{serviceAccount.ID}: {serviceAccount.Name}");322 }323 ```324325 ```go Go326 client := anthropic.NewClient()327328 serviceAccounts := client.Beta.Organization.ServiceAccounts.ListAutoPaging(context.Background(), anthropic.BetaOrganizationServiceAccountListParams{329 Limit: anthropic.Int(20),330 })331332 for serviceAccounts.Next() {333 serviceAccount := serviceAccounts.Current()334 fmt.Printf("%s: %s\n", serviceAccount.ID, serviceAccount.Name)335 }336 if err := serviceAccounts.Err(); err != nil {337 log.Fatal(err)338 }339 ```340341 ```java Java342 import com.anthropic.models.beta.organization.serviceaccounts.ServiceAccountListParams;343344 void main() {345 AnthropicClient client = AnthropicOkHttpClient.fromEnv();346347 var params = ServiceAccountListParams.builder()348 .limit(20)349 .build();350 var serviceAccounts = client.beta().organization().serviceAccounts().list(params);351352 for (var serviceAccount : serviceAccounts.autoPager()) {353 IO.println(serviceAccount.id() + ": " + serviceAccount.name());354 }355 }356 ```357358 ```php PHP359 $client = new Client();360361 $serviceAccounts = $client->beta->organization->serviceAccounts->list(limit: 20);362363 foreach ($serviceAccounts->getItems() as $serviceAccount) {364 echo "{$serviceAccount->id}: {$serviceAccount->name}\n";365 }366 ```367368 ```ruby Ruby369 client = Anthropic::Client.new370371 service_accounts = client.beta.organization.service_accounts.list(limit: 20)372373 service_accounts.data.each do |service_account|374 puts "#{service_account.id}: #{service_account.name}"375 end376 ```377</CodeGroup>378379Archive a service account:380381<CodeGroup>382 ```bash cURL383 curl --fail-with-body -sS -X POST "https://api.anthropic.com/v1/organizations/service_accounts/svac_01ABCDEFabcdef0123456789XY/archive" \384 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \385 -H "anthropic-version: 2023-06-01"386 ```387388 ```bash CLI389 ant beta:organization:service-accounts archive svac_01ABCDEFabcdef0123456789XY390 ```391392 ```python Python393 client = anthropic.Anthropic()394395 service_account = client.beta.organization.service_accounts.archive(396 "svac_01ABCDEFabcdef0123456789XY"397 )398399 print(f"id: {service_account.id}")400 print(f"archived_at: {service_account.archived_at}")401 ```402403 ```typescript TypeScript404 const client = new Anthropic();405406 const serviceAccount = await client.beta.organization.serviceAccounts.archive(407 "svac_01ABCDEFabcdef0123456789XY"408 );409410 console.log(`id: ${serviceAccount.id}`);411 console.log(`archived_at: ${serviceAccount.archived_at}`);412 ```413414 ```csharp C#415 AnthropicClient client = new();416417 var serviceAccount = await client.Beta.Organization.ServiceAccounts.Archive(418 "svac_01ABCDEFabcdef0123456789XY"419 );420421 Console.WriteLine($"id: {serviceAccount.ID}");422 Console.WriteLine($"archived_at: {serviceAccount.ArchivedAt:O}");423 ```424425 ```go Go426 client := anthropic.NewClient()427428 serviceAccount, err := client.Beta.Organization.ServiceAccounts.Archive(429 context.Background(),430 "svac_01ABCDEFabcdef0123456789XY",431 anthropic.BetaOrganizationServiceAccountArchiveParams{},432 )433 if err != nil {434 log.Fatal(err)435 }436437 fmt.Printf("id: %s\n", serviceAccount.ID)438 fmt.Printf("archived_at: %s\n", serviceAccount.ArchivedAt)439 ```440441 ```java Java442 AnthropicClient client = AnthropicOkHttpClient.fromEnv();443444 var serviceAccount = client.beta().organization().serviceAccounts()445 .archive("svac_01ABCDEFabcdef0123456789XY");446447 IO.println("id: " + serviceAccount.id());448 IO.println("archived_at: " + serviceAccount.archivedAt().orElseThrow());449 ```450451 ```php PHP452 $client = new Client();453454 $serviceAccount = $client->beta->organization->serviceAccounts->archive(455 serviceAccountID: 'svac_01ABCDEFabcdef0123456789XY',456 );457458 echo "id: {$serviceAccount->id}\n";459 echo "archived_at: {$serviceAccount->archivedAt?->format(DATE_ATOM)}\n";460 ```461462 ```ruby Ruby463 client = Anthropic::Client.new464465 service_account_id = "svac_01ABCDEFabcdef0123456789XY"466 service_account = client.beta.organization.service_accounts.archive(service_account_id)467468 puts "id: #{service_account.id}"469 puts "archived_at: #{service_account.archived_at}"470 ```471</CodeGroup>472473The create endpoint returns the new service account:474475```json476{477 "id": "svac_...",478 "name": "inference-worker",479 "organization_role": "developer",480 "created_at": "...",481 "type": "service_account",482 "...": "..."483}484```485486To read or update a single service account, use `GET` and `POST` on `/v1/organizations/service_accounts/{service_account_id}`. A service account must be a member of a workspace before federated tokens can act in it. Every service account has an implicit membership in your organization's default workspace; add explicit memberships for other workspaces with `GET`, `POST`, and `DELETE` on `/v1/organizations/service_accounts/{service_account_id}/workspaces`, where `DELETE` targets `.../workspaces/{workspace_id}`.487488For complete parameter details and response schemas, see the [Service accounts API reference](https://platform.claude.com/docs/en/api/admin/service_accounts).489490## Federation issuers491492A [federation issuer](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#federation-issuers) (`fdis_...`) registers an OIDC identity provider with your organization. The `jwks` field is a discriminated union that controls how Anthropic fetches the provider's signing keys:493494| `jwks` value | When to use |495| ---------------------------------------- | --------------------------------------------------------------------------------- |496| `{"type": "discovery"}` | The provider serves `/.well-known/openid-configuration` at the issuer URL. |497| `{"type": "explicit_url", "url": "..."}` | Point at a JWKS endpoint directly. |498| `{"type": "inline", "keys": [...]}` | Upload the key set for providers that are not reachable from the public internet. |499500Register an issuer. This example registers GitHub Actions with JWKS discovery:501502<CodeGroup>503 ```bash cURL504 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/federation_issuers" \505 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \506 -H "anthropic-version: 2023-06-01" \507 -H "content-type: application/json" \508 -d '{509 "name": "github-actions",510 "issuer_url": "https://token.actions.githubusercontent.com",511 "jwks": {"type": "discovery"}512 }'513 ```514515 ```bash CLI516 ant beta:organization:federation:issuers create \517 --name github-actions \518 --issuer-url https://token.actions.githubusercontent.com \519 --jwks '{type: discovery}'520 ```521522 ```python Python523 client = anthropic.Anthropic()524525 issuer = client.beta.organization.federation.issuers.create(526 name="github-actions",527 issuer_url="https://token.actions.githubusercontent.com",528 jwks={"type": "discovery"},529 )530531 print(f"id: {issuer.id}")532 print(f"name: {issuer.name}")533 print(f"issuer_url: {issuer.issuer_url}")534 ```535536 ```typescript TypeScript537 const client = new Anthropic();538539 const issuer = await client.beta.organization.federation.issuers.create({540 name: "github-actions",541 issuer_url: "https://token.actions.githubusercontent.com",542 jwks: { type: "discovery" }543 });544545 console.log(`id: ${issuer.id}`);546 console.log(`name: ${issuer.name}`);547 console.log(`issuer_url: ${issuer.issuer_url}`);548 ```549550 ```csharp C#551 using Anthropic.Models.Beta.Organization.Federation.Issuers;552553 AnthropicClient client = new();554555 var issuer = await client.Beta.Organization.Federation.Issuers.Create(new()556 {557 Name = "github-actions",558 IssuerUrl = "https://token.actions.githubusercontent.com",559 Jwks = new BetaJwksDiscovery()560 });561562 Console.WriteLine($"id: {issuer.ID}");563 Console.WriteLine($"name: {issuer.Name}");564 Console.WriteLine($"issuer_url: {issuer.IssuerUrl}");565 ```566567 ```go Go568 client := anthropic.NewClient()569570 issuer, err := client.Beta.Organization.Federation.Issuers.New(context.Background(), anthropic.BetaOrganizationFederationIssuerNewParams{571 Name: "github-actions",572 IssuerURL: "https://token.actions.githubusercontent.com",573 JWKS: anthropic.BetaOrganizationFederationIssuerNewParamsJWKSUnion{574 OfDiscovery: &anthropic.BetaJWKSDiscoveryParam{},575 },576 })577 if err != nil {578 log.Fatal(err)579 }580581 fmt.Printf("id: %s\n", issuer.ID)582 fmt.Printf("name: %s\n", issuer.Name)583 fmt.Printf("issuer_url: %s\n", issuer.IssuerURL)584 ```585586 ```java Java587 import com.anthropic.models.beta.organization.federation.issuers.BetaJwksDiscovery;588 import com.anthropic.models.beta.organization.federation.issuers.IssuerCreateParams;589590 void main() {591 AnthropicClient client = AnthropicOkHttpClient.fromEnv();592593 var params = IssuerCreateParams.builder()594 .name("github-actions")595 .issuerUrl("https://token.actions.githubusercontent.com")596 .jwks(BetaJwksDiscovery.builder().build())597 .build();598 var issuer = client.beta().organization().federation().issuers().create(params);599600 IO.println("id: " + issuer.id());601 IO.println("name: " + issuer.name());602 IO.println("issuer_url: " + issuer.issuerUrl());603 }604 ```605606 ```php PHP607 $client = new Client();608609 $issuer = $client->beta->organization->federation->issuers->create(610 name: 'github-actions',611 issuerURL: 'https://token.actions.githubusercontent.com',612 jwks: ['type' => 'discovery'],613 );614615 echo "id: {$issuer->id}\n";616 echo "name: {$issuer->name}\n";617 echo "issuer_url: {$issuer->issuerURL}\n";618 ```619620 ```ruby Ruby621 client = Anthropic::Client.new622623 issuer = client.beta.organization.federation.issuers.create(624 name: "github-actions",625 issuer_url: "https://token.actions.githubusercontent.com",626 jwks: {type: :discovery}627 )628629 puts "id: #{issuer.id}"630 puts "name: #{issuer.name}"631 puts "issuer_url: #{issuer.issuer_url}"632 ```633</CodeGroup>634635List issuers:636637<CodeGroup>638 ```bash cURL639 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/federation_issuers?limit=20" \640 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \641 -H "anthropic-version: 2023-06-01"642 ```643644 ```bash CLI645 ant beta:organization:federation:issuers list --limit 20646 ```647648 ```python Python649 client = anthropic.Anthropic()650651 issuers = client.beta.organization.federation.issuers.list(limit=20)652653 for issuer in issuers:654 print(f"{issuer.id}: {issuer.name}")655 ```656657 ```typescript TypeScript658 const client = new Anthropic();659660 for await (const issuer of client.beta.organization.federation.issuers.list({ limit: 20 })) {661 console.log(`${issuer.id}: ${issuer.name}`);662 }663 ```664665 ```csharp C#666 AnthropicClient client = new();667668 var page = await client.Beta.Organization.Federation.Issuers.List(new() { Limit = 20 });669670 await foreach (var issuer in page.Paginate())671 {672 Console.WriteLine($"{issuer.ID}: {issuer.Name}");673 }674 ```675676 ```go Go677 client := anthropic.NewClient()678679 issuers := client.Beta.Organization.Federation.Issuers.ListAutoPaging(context.Background(), anthropic.BetaOrganizationFederationIssuerListParams{680 Limit: anthropic.Int(20),681 })682683 for issuers.Next() {684 issuer := issuers.Current()685 fmt.Printf("%s: %s\n", issuer.ID, issuer.Name)686 }687 if err := issuers.Err(); err != nil {688 log.Fatal(err)689 }690 ```691692 ```java Java693 import com.anthropic.models.beta.organization.federation.issuers.IssuerListParams;694695 void main() {696 AnthropicClient client = AnthropicOkHttpClient.fromEnv();697698 var params = IssuerListParams.builder()699 .limit(20)700 .build();701 var issuers = client.beta().organization().federation().issuers().list(params);702703 for (var issuer : issuers.autoPager()) {704 IO.println(issuer.id() + ": " + issuer.name());705 }706 }707 ```708709 ```php PHP710 $client = new Client();711712 $issuers = $client->beta->organization->federation->issuers->list(limit: 20);713714 foreach ($issuers->getItems() as $issuer) {715 echo "{$issuer->id}: {$issuer->name}\n";716 }717 ```718719 ```ruby Ruby720 client = Anthropic::Client.new721722 issuers = client.beta.organization.federation.issuers.list(limit: 20)723724 issuers.data.each do |issuer|725 puts "#{issuer.id}: #{issuer.name}"726 end727 ```728</CodeGroup>729730Archive an issuer:731732<CodeGroup>733 ```bash cURL734 curl --fail-with-body -sS -X POST "https://api.anthropic.com/v1/organizations/federation_issuers/fdis_01ABCDEFabcdef0123456789XY/archive" \735 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \736 -H "anthropic-version: 2023-06-01"737 ```738739 ```bash CLI740 ant beta:organization:federation:issuers archive \741 --federation-issuer-id fdis_01ABCDEFabcdef0123456789XY742 ```743744 ```python Python745 client = anthropic.Anthropic()746747 issuer = client.beta.organization.federation.issuers.archive(748 "fdis_01ABCDEFabcdef0123456789XY"749 )750751 print(f"id: {issuer.id}")752 print(f"archived_at: {issuer.archived_at}")753 ```754755 ```typescript TypeScript756 const client = new Anthropic();757758 const issuer = await client.beta.organization.federation.issuers.archive(759 "fdis_01ABCDEFabcdef0123456789XY"760 );761762 console.log(`id: ${issuer.id}`);763 console.log(`archived_at: ${issuer.archived_at}`);764 ```765766 ```csharp C#767 AnthropicClient client = new();768769 var issuer = await client.Beta.Organization.Federation.Issuers.Archive(770 "fdis_01ABCDEFabcdef0123456789XY"771 );772773 Console.WriteLine($"id: {issuer.ID}");774 Console.WriteLine($"archived_at: {issuer.ArchivedAt:O}");775 ```776777 ```go Go778 client := anthropic.NewClient()779780 issuer, err := client.Beta.Organization.Federation.Issuers.Archive(781 context.Background(),782 "fdis_01ABCDEFabcdef0123456789XY",783 anthropic.BetaOrganizationFederationIssuerArchiveParams{},784 )785 if err != nil {786 log.Fatal(err)787 }788789 fmt.Printf("id: %s\n", issuer.ID)790 fmt.Printf("archived_at: %s\n", issuer.ArchivedAt)791 ```792793 ```java Java794 AnthropicClient client = AnthropicOkHttpClient.fromEnv();795796 var issuer = client.beta().organization().federation().issuers()797 .archive("fdis_01ABCDEFabcdef0123456789XY");798799 IO.println("id: " + issuer.id());800 IO.println("archived_at: " + issuer.archivedAt().orElseThrow());801 ```802803 ```php PHP804 $client = new Client();805806 $issuer = $client->beta->organization->federation->issuers->archive(807 federationIssuerID: 'fdis_01ABCDEFabcdef0123456789XY',808 );809810 echo "id: {$issuer->id}\n";811 echo "archived_at: {$issuer->archivedAt?->format(DATE_ATOM)}\n";812 ```813814 ```ruby Ruby815 client = Anthropic::Client.new816817 issuer_id = "fdis_01ABCDEFabcdef0123456789XY"818 issuer = client.beta.organization.federation.issuers.archive(issuer_id)819820 puts "id: #{issuer.id}"821 puts "archived_at: #{issuer.archived_at}"822 ```823</CodeGroup>824825To read or update a single issuer, use `GET` and `POST` on `/v1/organizations/federation_issuers/{issuer_id}`. An OAuth caller cannot update an issuer that backs a rule whose `oauth_scope` is anything other than `workspace:developer` or `workspace:inference`; see [Permissions and constraints](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#permissions-and-constraints).826827For complete parameter details and response schemas, see the [Federation issuers API reference](https://platform.claude.com/docs/en/api/admin/federation_issuers).828829## Federation rules830831A [federation rule](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#federation-rules) (`fdrl_...`) binds an issuer to a service account: JWTs from the issuer that satisfy the rule's match conditions can mint tokens that act as the rule's target. The `workspace_id` in the create request enables the rule in that workspace at creation; add more workspaces later through the `/federation_rules/{rule_id}/workspaces` sub-resource. Either `workspace_id` or `applies_to_all_workspaces: true` is required on create.832833Create a rule. This example lets GitHub Actions deploys from the main branch act as the service account:834835<CodeGroup>836 ```bash cURL837 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/federation_rules" \838 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \839 -H "anthropic-version: 2023-06-01" \840 -H "content-type: application/json" \841 -d '{842 "name": "gha-deploy",843 "issuer_id": "fdis_01ABCDEFabcdef0123456789XY",844 "match": {845 "subject_prefix": "repo:my-org/my-repo:ref:refs/heads/main",846 "claims": {"repository_owner": "my-org"}847 },848 "target": {849 "type": "service_account",850 "service_account_id": "svac_01ABCDEFabcdef0123456789XY"851 },852 "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",853 "oauth_scope": "workspace:developer",854 "token_lifetime_seconds": 600855 }'856 ```857858 ```bash CLI859 ant beta:organization:federation:rules create <<'YAML'860 name: gha-deploy861 issuer_id: fdis_01ABCDEFabcdef0123456789XY862 match:863 subject_prefix: "repo:my-org/my-repo:ref:refs/heads/main"864 claims:865 repository_owner: my-org866 target:867 type: service_account868 service_account_id: svac_01ABCDEFabcdef0123456789XY869 workspace_id: wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ870 oauth_scope: "workspace:developer"871 token_lifetime_seconds: 600872 YAML873 ```874875 ```python Python876 client = anthropic.Anthropic()877878 rule = client.beta.organization.federation.rules.create(879 name="gha-deploy",880 issuer_id="fdis_01ABCDEFabcdef0123456789XY",881 match={882 "subject_prefix": "repo:my-org/my-repo:ref:refs/heads/main",883 "claims": {"repository_owner": "my-org"},884 },885 target={886 "type": "service_account",887 "service_account_id": "svac_01ABCDEFabcdef0123456789XY",888 },889 workspace_id="wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",890 oauth_scope="workspace:developer",891 token_lifetime_seconds=600,892 )893894 print(f"id: {rule.id}")895 print(f"name: {rule.name}")896 ```897898 ```typescript TypeScript899 const client = new Anthropic();900901 const rule = await client.beta.organization.federation.rules.create({902 name: "gha-deploy",903 issuer_id: "fdis_01ABCDEFabcdef0123456789XY",904 match: {905 subject_prefix: "repo:my-org/my-repo:ref:refs/heads/main",906 claims: { repository_owner: "my-org" }907 },908 target: {909 type: "service_account",910 service_account_id: "svac_01ABCDEFabcdef0123456789XY"911 },912 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",913 oauth_scope: "workspace:developer",914 token_lifetime_seconds: 600915 });916917 console.log(`id: ${rule.id}`);918 console.log(`name: ${rule.name}`);919 ```920921 ```csharp C#922 AnthropicClient client = new();923924 var rule = await client.Beta.Organization.Federation.Rules.Create(new()925 {926 Name = "gha-deploy",927 IssuerID = "fdis_01ABCDEFabcdef0123456789XY",928 Match = new()929 {930 SubjectPrefix = "repo:my-org/my-repo:ref:refs/heads/main",931 Claims = new Dictionary<string, string> { ["repository_owner"] = "my-org" }932 },933 Target = new() { ServiceAccountID = "svac_01ABCDEFabcdef0123456789XY" },934 WorkspaceID = "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",935 OAuthScope = "workspace:developer",936 TokenLifetimeSeconds = 600937 });938939 Console.WriteLine($"id: {rule.ID}");940 Console.WriteLine($"name: {rule.Name}");941 ```942943 ```go Go944 client := anthropic.NewClient()945946 rule, err := client.Beta.Organization.Federation.Rules.New(context.Background(), anthropic.BetaOrganizationFederationRuleNewParams{947 Name: "gha-deploy",948 IssuerID: "fdis_01ABCDEFabcdef0123456789XY",949 Match: anthropic.BetaFederationRuleMatchParam{950 SubjectPrefix: anthropic.String("repo:my-org/my-repo:ref:refs/heads/main"),951 Claims: map[string]string{"repository_owner": "my-org"},952 },953 Target: anthropic.BetaServiceAccountTargetParam{954 ServiceAccountID: "svac_01ABCDEFabcdef0123456789XY",955 },956 WorkspaceID: anthropic.String("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"),957 OAuthScope: "workspace:developer",958 TokenLifetimeSeconds: anthropic.Int(600),959 })960 if err != nil {961 log.Fatal(err)962 }963964 fmt.Printf("id: %s\n", rule.ID)965 fmt.Printf("name: %s\n", rule.Name)966 ```967968 ```java Java969 import com.anthropic.core.JsonValue;970 import com.anthropic.models.beta.organization.federation.rules.BetaFederationRuleMatch;971 import com.anthropic.models.beta.organization.federation.rules.BetaServiceAccountTarget;972 import com.anthropic.models.beta.organization.federation.rules.RuleCreateParams;973974 void main() {975 AnthropicClient client = AnthropicOkHttpClient.fromEnv();976977 var match = BetaFederationRuleMatch.builder()978 .subjectPrefix("repo:my-org/my-repo:ref:refs/heads/main")979 .claims(BetaFederationRuleMatch.Claims.builder()980 .putAdditionalProperty("repository_owner", JsonValue.from("my-org"))981 .build())982 .build();983 var params = RuleCreateParams.builder()984 .name("gha-deploy")985 .issuerId("fdis_01ABCDEFabcdef0123456789XY")986 .match(match)987 .target(BetaServiceAccountTarget.of("svac_01ABCDEFabcdef0123456789XY"))988 .workspaceId("wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ")989 .oauthScope("workspace:developer")990 .tokenLifetimeSeconds(600)991 .build();992 var rule = client.beta().organization().federation().rules().create(params);993994 IO.println("id: " + rule.id());995 IO.println("name: " + rule.name());996 }997 ```998999 ```php PHP1000 $client = new Client();10011002 $rule = $client->beta->organization->federation->rules->create(1003 name: 'gha-deploy',1004 issuerID: 'fdis_01ABCDEFabcdef0123456789XY',1005 match: [1006 'subjectPrefix' => 'repo:my-org/my-repo:ref:refs/heads/main',1007 'claims' => ['repository_owner' => 'my-org'],1008 ],1009 target: [1010 'type' => 'service_account',1011 'serviceAccountID' => 'svac_01ABCDEFabcdef0123456789XY',1012 ],1013 workspaceID: 'wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ',1014 oauthScope: 'workspace:developer',1015 tokenLifetimeSeconds: 600,1016 );10171018 echo "id: {$rule->id}\n";1019 echo "name: {$rule->name}\n";1020 ```10211022 ```ruby Ruby1023 client = Anthropic::Client.new10241025 rule = client.beta.organization.federation.rules.create(1026 name: "gha-deploy",1027 issuer_id: "fdis_01ABCDEFabcdef0123456789XY",1028 match: {1029 subject_prefix: "repo:my-org/my-repo:ref:refs/heads/main",1030 claims: {repository_owner: "my-org"}1031 },1032 target: {1033 type: :service_account,1034 service_account_id: "svac_01ABCDEFabcdef0123456789XY"1035 },1036 workspace_id: "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",1037 oauth_scope: "workspace:developer",1038 token_lifetime_seconds: 6001039 )10401041 puts "id: #{rule.id}"1042 puts "name: #{rule.name}"1043 ```1044</CodeGroup>10451046List rules, optionally filtered by issuer:10471048<CodeGroup>1049 ```bash cURL1050 curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/federation_rules?issuer_id=fdis_01ABCDEFabcdef0123456789XY" \1051 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \1052 -H "anthropic-version: 2023-06-01"1053 ```10541055 ```bash CLI1056 ant beta:organization:federation:rules list \1057 --issuer-id fdis_01ABCDEFabcdef0123456789XY1058 ```10591060 ```python Python1061 client = anthropic.Anthropic()10621063 rules = client.beta.organization.federation.rules.list(1064 issuer_id="fdis_01ABCDEFabcdef0123456789XY"1065 )10661067 for rule in rules:1068 print(f"{rule.id}: {rule.name}")1069 ```10701071 ```typescript TypeScript1072 const client = new Anthropic();10731074 for await (const rule of client.beta.organization.federation.rules.list({1075 issuer_id: "fdis_01ABCDEFabcdef0123456789XY"1076 })) {1077 console.log(`${rule.id}: ${rule.name}`);1078 }1079 ```10801081 ```csharp C#1082 AnthropicClient client = new();10831084 var page = await client.Beta.Organization.Federation.Rules.List(new()1085 {1086 IssuerID = "fdis_01ABCDEFabcdef0123456789XY"1087 });10881089 await foreach (var rule in page.Paginate())1090 {1091 Console.WriteLine($"{rule.ID}: {rule.Name}");1092 }1093 ```10941095 ```go Go1096 client := anthropic.NewClient()10971098 rules := client.Beta.Organization.Federation.Rules.ListAutoPaging(context.Background(), anthropic.BetaOrganizationFederationRuleListParams{1099 IssuerID: anthropic.String("fdis_01ABCDEFabcdef0123456789XY"),1100 })11011102 for rules.Next() {1103 rule := rules.Current()1104 fmt.Printf("%s: %s\n", rule.ID, rule.Name)1105 }1106 if err := rules.Err(); err != nil {1107 log.Fatal(err)1108 }1109 ```11101111 ```java Java1112 import com.anthropic.models.beta.organization.federation.rules.RuleListParams;11131114 void main() {1115 AnthropicClient client = AnthropicOkHttpClient.fromEnv();11161117 var params = RuleListParams.builder()1118 .issuerId("fdis_01ABCDEFabcdef0123456789XY")1119 .build();1120 var rules = client.beta().organization().federation().rules().list(params);11211122 for (var rule : rules.autoPager()) {1123 IO.println(rule.id() + ": " + rule.name());1124 }1125 }1126 ```11271128 ```php PHP1129 $client = new Client();11301131 $rules = $client->beta->organization->federation->rules->list(1132 issuerID: 'fdis_01ABCDEFabcdef0123456789XY',1133 );11341135 foreach ($rules->getItems() as $rule) {1136 echo "{$rule->id}: {$rule->name}\n";1137 }1138 ```11391140 ```ruby Ruby1141 client = Anthropic::Client.new11421143 rules = client.beta.organization.federation.rules.list(1144 issuer_id: "fdis_01ABCDEFabcdef0123456789XY"1145 )11461147 rules.data.each do |rule|1148 puts "#{rule.id}: #{rule.name}"1149 end1150 ```1151</CodeGroup>11521153Archive a rule:11541155<CodeGroup>1156 ```bash cURL1157 curl --fail-with-body -sS -X POST "https://api.anthropic.com/v1/organizations/federation_rules/fdrl_01ABCDEFabcdef0123456789XY/archive" \1158 -H "authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \1159 -H "anthropic-version: 2023-06-01"1160 ```11611162 ```bash CLI1163 ant beta:organization:federation:rules archive \1164 --federation-rule-id fdrl_01ABCDEFabcdef0123456789XY1165 ```11661167 ```python Python1168 client = anthropic.Anthropic()11691170 rule = client.beta.organization.federation.rules.archive(1171 "fdrl_01ABCDEFabcdef0123456789XY"1172 )11731174 print(f"id: {rule.id}")1175 print(f"archived_at: {rule.archived_at}")1176 ```11771178 ```typescript TypeScript1179 const client = new Anthropic();11801181 const rule = await client.beta.organization.federation.rules.archive(1182 "fdrl_01ABCDEFabcdef0123456789XY"1183 );11841185 console.log(`id: ${rule.id}`);1186 console.log(`archived_at: ${rule.archived_at}`);1187 ```11881189 ```csharp C#1190 AnthropicClient client = new();11911192 var rule = await client.Beta.Organization.Federation.Rules.Archive(1193 "fdrl_01ABCDEFabcdef0123456789XY"1194 );11951196 Console.WriteLine($"id: {rule.ID}");1197 Console.WriteLine($"archived_at: {rule.ArchivedAt:O}");1198 ```11991200 ```go Go1201 client := anthropic.NewClient()12021203 rule, err := client.Beta.Organization.Federation.Rules.Archive(1204 context.Background(),1205 "fdrl_01ABCDEFabcdef0123456789XY",1206 anthropic.BetaOrganizationFederationRuleArchiveParams{},1207 )1208 if err != nil {1209 log.Fatal(err)1210 }12111212 fmt.Printf("id: %s\n", rule.ID)1213 fmt.Printf("archived_at: %s\n", rule.ArchivedAt)1214 ```12151216 ```java Java1217 AnthropicClient client = AnthropicOkHttpClient.fromEnv();12181219 var rule = client.beta().organization().federation().rules()1220 .archive("fdrl_01ABCDEFabcdef0123456789XY");12211222 IO.println("id: " + rule.id());1223 IO.println("archived_at: " + rule.archivedAt().orElseThrow());1224 ```12251226 ```php PHP1227 $client = new Client();12281229 $rule = $client->beta->organization->federation->rules->archive(1230 federationRuleID: 'fdrl_01ABCDEFabcdef0123456789XY',1231 );12321233 echo "id: {$rule->id}\n";1234 echo "archived_at: {$rule->archivedAt?->format(DATE_ATOM)}\n";1235 ```12361237 ```ruby Ruby1238 client = Anthropic::Client.new12391240 rule_id = "fdrl_01ABCDEFabcdef0123456789XY"1241 rule = client.beta.organization.federation.rules.archive(rule_id)12421243 puts "id: #{rule.id}"1244 puts "archived_at: #{rule.archived_at}"1245 ```1246</CodeGroup>12471248The list endpoint returns a page of rules and the cursor for the next page:12491250```json1251{1252 "data": [{ "id": "fdrl_...", "name": "gha-deploy", "...": "..." }],1253 "next_page": "..."1254}1255```12561257To read or update a single rule, use `GET` and `POST` on `/v1/organizations/federation_rules/{rule_id}`. To manage the workspaces a rule can mint tokens in, use `GET` and `POST` on `/v1/organizations/federation_rules/{rule_id}/workspaces`, and `DELETE` on `/v1/organizations/federation_rules/{rule_id}/workspaces/{workspace_id}`.12581259For complete parameter details and response schemas, see the [Federation rules API reference](https://platform.claude.com/docs/en/api/admin/federation_rules).12601261## Permissions and constraints12621263<Note>1264 * OAuth-authenticated callers can only create or modify rules whose `oauth_scope` is `workspace:developer` or `workspace:inference`. To create or modify a rule with any other scope (such as `org:admin` or `workspace:manage_tunnels`), use the Console.1265 * An OAuth caller cannot update a federation issuer that backs a rule whose `oauth_scope` is anything other than `workspace:developer` or `workspace:inference` (such as `org:admin` or `workspace:manage_tunnels`). Consider registering a dedicated issuer for the bootstrap rule so the issuers behind workspace-scoped rules stay updatable through the API.1266 * Admin API keys are not accepted on these endpoints, for reads or writes; use an `org:admin` OAuth token.1267</Note>12681269A rule with `oauth_scope: org:admin` must target a service account whose `organization_role` is `admin`. Resource names must match `^[a-z0-9-]+$`, be 1 to 255 characters, and be unique within an organization for each resource type; for the full field-level constraints, see [Validation rules](https://platform.claude.com/docs/en/manage-claude/wif-reference#validation-rules).12701271## Pagination and archiving12721273The service-account, federation-issuer, and federation-rule list endpoints accept `limit` (1 to 100, default 20) and a `page` cursor taken from the previous response. Pass the response's `next_page` value as the `page` query parameter on the next request. The rule-workspaces sub-resource list returns the full set without pagination. Archived resources are hidden from lists by default; pass `include_archived=true` to include them.12741275Archiving is a soft delete and is idempotent: archiving an already-archived resource succeeds. Archiving an issuer or a service account returns `400` while a live federation rule still references it; archive the rule first.12761277## See also12781279* [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation): concepts and the Console setup walkthrough1280* [WIF reference](https://platform.claude.com/docs/en/manage-claude/wif-reference): environment variables, validation rules, OAuth scopes, and error codes1281* [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api): the rest of the organization management surface1282* [Admin API reference](https://platform.claude.com/docs/en/api/admin): generated request and response schemas for every Admin API endpoint1283