Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One capture · api

One read of Claude Developer Platformapi-20261113T163712Z

13 pages moved out of 916 read.

Pages moved 13 significant first
Pages read 916 in this capture
Captured 16:37 UTC
Corpus hash e5691fcc3fdb corpus-hash

What this read moved

1-13 of 13

agents-and-tools/tool-use/programmatic-tool-calling Changed · +2 / -3 lines

from line 462
462462* **Expiration:** Containers expire 30 days after creation. After about 5 minutes of inactivity a container is checkpointed, and sending a request with its ID inside the 30-day window restores it. The `expires_at` timestamp is a shorter rolling value and doesn’t report the 30-day limit.
463463 
464464<Warning>
465 While Claude’s code is waiting for a programmatic tool result, the pending call times out after about 4 minutes and raises a `TimeoutError` inside the code. Return each tool result well before the `expires_at` timestamp on the paused response. See [Container expiration during tool call](https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling#container-expiration-during-tool-call).
465 While Claude’s code is waiting for a programmatic tool result, the pending call times out after about 4 minutes and raises a `TimeoutError` inside the code. That time starts when Claude’s code makes the call, before the paused response reaches you. The `expires_at` timestamp on the paused response falls after the call times out, so it isn’t your deadline. See [Container expiration during tool call](https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling#container-expiration-during-tool-call).
466466</Warning>
467467 
468468## Example workflow
from line 1321
13211321 
13221322To prevent timeouts:
13231323 
1324* Monitor the `expires_at` field on paused responses.
13251324* Implement timeouts for your tool execution.
13261325* Consider breaking long operations into smaller chunks.
13271326 
from line 1481
14821481 
14831482**Container expiration**
14841483 
1485* Respond to each programmatic tool call well before the paused response’s `expires_at` timestamp. Claude’s code stops waiting for a result after about 4 minutes.
1484* Respond to each programmatic tool call as soon as you can. Don’t treat the paused response’s `expires_at` timestamp as your deadline: it falls after the call times out. Claude’s code stops waiting for a result after about 4 minutes.
14861485* Consider implementing faster tool execution.
14871486 
14881487**Tool result not parsed correctly**

agents-and-tools/tool-use/tool-runner Changed · +10 / -7 lines

### Compacting long conversations ### Automatic context management

from line 43
4343* Manages conversation state
4444* Provides type safety and validation
4545 
46<Note>
47 The tool runner is in beta and available in the [Python SDK](https://github.com/anthropics/anthropic-sdk-python/blob/main/tools.md), [TypeScript SDK](https://github.com/anthropics/anthropic-sdk-typescript/blob/main/helpers.md#tool-helpers), [C# SDK](https://github.com/anthropics/anthropic-sdk-csharp/blob/main/examples/ToolRunnerExample/Program.cs), [Go SDK](https://github.com/anthropics/anthropic-sdk-go/blob/main/tools.md), [Java SDK](https://github.com/anthropics/anthropic-sdk-java/blob/main/anthropic-java-example/src/main/java/com/anthropic/example/BetaToolRunnerRunnableToolExample.java), [PHP SDK](https://github.com/anthropics/anthropic-sdk-php/blob/main/examples/beta/beta_tool_runner.php), and [Ruby SDK](https://github.com/anthropics/anthropic-sdk-ruby/blob/main/helpers.md#3-auto-looping-tool-runner-beta).
48</Note>
46The tool runner is available in the [Python SDK](https://github.com/anthropics/anthropic-sdk-python/blob/main/tools.md), [TypeScript SDK](https://github.com/anthropics/anthropic-sdk-typescript/blob/main/helpers.md#tool-helpers), [C# SDK](https://github.com/anthropics/anthropic-sdk-csharp/blob/main/examples/ToolRunnerExample/Program.cs), [Go SDK](https://github.com/anthropics/anthropic-sdk-go/blob/main/tools.md), [Java SDK](https://github.com/anthropics/anthropic-sdk-java/blob/main/anthropic-java-example/src/main/java/com/anthropic/example/BetaToolRunnerRunnableToolExample.java), [PHP SDK](https://github.com/anthropics/anthropic-sdk-php/blob/main/examples/beta/beta_tool_runner.php), and [Ruby SDK](https://github.com/anthropics/anthropic-sdk-ruby/blob/main/helpers.md#3-auto-looping-tool-runner-beta).
4947 
5048## Basic usage
5149 
from line 842
844842 
845843You take over by modifying the runner’s messages from inside the loop body. The exact method depends on the SDK. See the per-language tabs that follow.
846844 
847When you take over for an iteration, the runner does not append the assistant message or tool results from that turn. You become responsible for keeping the conversation valid: append the assistant message and a tool result yourself (if you want the turn to count), modify state conditionally so the loop can still exit when there are no tool calls, and pass `max_iterations` (csharp, php: `maxIterations`; java: `.maxIterations()`; go: `MaxIterations`) to bound the loop. The SDK supports `max_iterations` (csharp, php: `maxIterations`; java: `.maxIterations()`; go: `MaxIterations`) in all seven languages.
845When you take over for an iteration, the runner does not append the assistant message or tool results from that turn. You become responsible for keeping the conversation valid. Append the assistant message and a tool result yourself if you want the turn to count. Modify state only conditionally, so that the loop can still exit when there are no tool calls. To bound the loop, pass `max_iterations` (csharp, php: `maxIterations`; java: `.maxIterations()`; go: `MaxIterations`).
848846 
849847<Tabs exclude="shell">
850848 <Tab title="Python">
from line 1122
11241122 </Tab>
11251123</Tabs>
11261124 
1127### Automatic context management
1125### Compacting long conversations
11281126 
1129For long-running agentic tasks, the TypeScript and Ruby tool runners support automatic [compaction](https://platform.claude.com/docs/en/build-with-claude/context-editing#client-side-compaction-sdk), which generates summaries when token usage exceeds a threshold so the conversation can continue beyond context window limits. Both SDKs have deprecated this client-side option in favor of [server-side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold), which works with every SDK’s tool runner through the `context_management` request parameter. The Python SDK (v1.0 and later) and the Go, Java, C#, and PHP tool runners don’t include client-side compaction. The tool runner has a `compact_before_next_turn()` (typescript, java, php: `compactBeforeNextTurn()`; csharp, go: `CompactBeforeNextTurn()`) helper for on-demand compaction. See [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop). Use it or a `context_management` compaction edit on a runner, not both.
1127The tool runner supports two kinds of compaction. [Choose how to compact](https://platform.claude.com/docs/en/build-with-claude/compaction#choose-how-to-compact) compares them.
1128 
1129* [Compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold): when the conversation reaches a token threshold that you can set, the API summarizes it. The runner automatically sends the summary back on its later requests, so the task can continue beyond the context window. Add an entry of type [`compact_20260112`](https://platform.claude.com/docs/en/api/beta/messages#beta_compact_20260112_edit) to the `edits` array of the runner’s [`context_management`](https://platform.claude.com/docs/en/api/beta/messages/create#create.context_management) request parameter. Create the runner with the `compact-2026-01-12` beta, because the runner doesn’t add it.
1130* [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand): you choose when to compact. Call the runner’s `compact_before_next_turn()` (ruby: `compact_before_next_turn`; typescript, java, php: `compactBeforeNextTurn()`; csharp, go: `CompactBeforeNextTurn()`) helper, and the runner compacts before its next turn. [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop) shows the call and names the beta header that it needs.
1131 
1132A runner can’t compact on demand while its `context_management` holds a `compact_20260112` entry, so use one kind on a runner.
11301133 
11311134### Debugging tool execution
11321135 

api/claude-platform-on-aws-iam-actions Changed · +12 / -11 lines

from line 298
298298| --------------- | ----------------- |
299299| `AssumeConsole` | (none) |
300300 
301`AssumeConsole` authorizes a principal to open the Claude Console for a Claude Platform on AWS workspace through the AWS Console federation flow. It does not map to a route. Grant it to principals who should be able to click **Open Claude Console** on the Claude Platform on AWS service page in the AWS Console. The Claude Console role (Admin or Developer) is assigned separately by your Anthropic account representative; it is not derived from the principal’s IAM permissions. See [Using the Claude Console](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#using-the-claude-console) for the sign-in flow and role descriptions.
301`AssumeConsole` authorizes a principal to open the Claude Console for its Claude Platform on AWS organization through the AWS Console federation flow. It does not map to a route or bind to a workspace ARN, so a statement that grants it needs `Resource: "*"`. Grant it to principals who should be able to click **Open Claude Console** on the Claude Platform on AWS service page in the AWS Console. See [Using the Claude Console](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#using-the-claude-console) for the sign-in flow and what each Claude Console role (Admin or Developer) can do.
302302 
303A Claude Console session covers the whole organization, not one workspace, and some Claude Console pages bypass IAM action checks. On those pages, a principal with either Claude Console role can see the whole organization’s usage, cost, and rate limits, whatever its IAM policies allow. With the Admin role, it can also see request metadata on the **Logs** page. An Admin session can also change settings outside IAM, such as spend limits for the organization and each workspace. Grant `AssumeConsole` only to principals who may see and act on the whole organization. [Claude Console pages available on Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#available-pages) shows which pages check IAM actions and which bypass them.
304 
303305## Route-to-action mapping
304306 
305307The following tables list every route on Claude Platform on AWS and the IAM action required to call it. Each IAM action also authorizes requests that use the `anthropic-beta` header; beta variants of a route do not require a separate IAM action. CloudTrail classifies each action as either a Data event (high-volume, data-plane operations) or a Management event (control-plane operations). Vault and webhook actions are classified as Management events because they hold secrets (vault credentials and webhook signing secrets) and benefit from default-on audit logging. Workspace, external key, telemetry destination, and compliance actions are also classified as Management events because they are organization-scoped control-plane operations. All other actions, including inference, batch, model, file, skill, user profile, usage and cost, and the remaining Claude Managed Agents actions, are classified as Data events.
from line 463
461463 
462464`AnthropicSelfHostedEnvironmentAccess` is the narrowest managed policy sufficient to run a [self-hosted sandbox](https://platform.claude.com/docs/en/managed-agents/self-hosted-sandboxes) worker. Attach it to the principal your environment worker authenticates as.
463465 
464`AssumeConsole` is not included in `AnthropicReadOnlyAccess`, `AnthropicInferenceAccess`, `AnthropicLimitedAccess`, or `AnthropicSelfHostedEnvironmentAccess`. Principals who need Claude Console access require either `AnthropicFullAccess` or a custom policy that grants `aws-external-anthropic:AssumeConsole`. See [Console access](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#console-access).
466To open the Claude Console, a principal needs `AssumeConsole` (see [Console access](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#console-access)). `AnthropicFullAccess` allows it through `aws-external-anthropic:*`. `AnthropicLimitedAccess` allows it only under a condition (see [AnthropicLimitedAccess in the AWS Managed Policy Reference](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AnthropicLimitedAccess.html)). A custom policy can also grant `aws-external-anthropic:AssumeConsole`.
465467 
466468<Note>
467469 `CreateInference` and `CreateBatchInference` are separate actions. Denying one does not block the other. If you intend to prevent all model calls, deny both.
from line 515
513515 },
514516 {
515517 "Effect": "Allow",
516 "Action": [
517 "aws-external-anthropic:CallWithBearerToken",
518 "aws-external-anthropic:AssumeConsole"
519 ],
518 "Action": "aws-external-anthropic:CallWithBearerToken",
520519 "Resource": "*"
521520 }
522521 ]
from line 522
523522}
524523```
525524 
526<Note>
527 The `aws-external-anthropic:*` wildcard in the first statement includes account-scoped actions (`CreateWorkspace`, `ListWorkspaces`, `ListComplianceActivities`, the external key actions, the account-scoped telemetry destination actions, the user profile actions, and the usage and cost actions) that the workspace ARN constraint silently filters out. This is consistent with the “isolation” intent (the role cannot create workspaces, enumerate workspaces, manage encryption key registrations, read the compliance Activity Feed, read usage or cost reports, or read or manage user profiles, and it cannot create, read, or change telemetry destinations; it can still attach an already-registered key to its own workspace through `UpdateWorkspace`, and add its own workspace to a destination, or remove it from one, given the destination’s ID), but the policy contains permissions that have no effect. If the role needs user profiles or usage and cost reports, add a separate `Allow` statement for those actions with `Resource: "*"`. See [Provisioning automation](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#provisioning-automation) for the account-scoped pattern.
525The second statement grants `CallWithBearerToken` on `Resource: "*"` so the role can authenticate with an API key. That action does not bind to a workspace ARN, so the first statement does not grant it. Omit the second statement if the role uses SigV4 only.
528526 
529 `CallWithBearerToken` and `AssumeConsole` are route-less actions that do not bind to a workspace ARN. The second statement grants them on `Resource: "*"` so the role can authenticate with an API key and open the Claude Console. Omit this statement if the role uses SigV4 only and does not need Claude Console access.
530</Note>
527The `aws-external-anthropic:*` wildcard in the first statement includes account-scoped actions, such as `CreateWorkspace` and `ListWorkspaces`. The workspace ARN constraint silently filters them out.
528 
529The [encryption key actions](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#encryption-keys) and the account-scoped [telemetry destination actions](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#telemetry-destinations) are among those filtered out. The role can still attach an already-registered encryption key to its own workspace through `UpdateWorkspace`. Given a telemetry destination’s ID, it can also add its own workspace to that destination or remove the workspace from it.
530 
531Like `CallWithBearerToken`, `AssumeConsole` does not bind to a workspace ARN, so the first statement does not grant it. No statement grants `AssumeConsole`; see [Console access](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#console-access) for why a role limited to one workspace should not have it.
531532 
532533### Feature lockdown for a ZDR-sensitive workspace
533534 

build-with-claude/claude-in-microsoft-foundry Changed · +28 / -26 lines

from line 4
44description: Access Claude models through Microsoft Foundry with Azure-native endpoints and authentication.
55---
66 
7This guide shows you how to set up Claude in Microsoft Foundry and make API calls to it. You can use one of Anthropic’s client SDKs or direct HTTP requests. When you access Claude in Microsoft Foundry, you are billed for Claude usage in the Azure Marketplace. The available models include Claude Fable 5.2, Claude Fable 5.1, Claude Opus 5.5, Claude Opus 5, and Claude Opus 4.8. They also include Claude Sonnet 5.5, Claude Sonnet 5, and Claude Haiku 5.5. Features such as the [1M-token context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) are also available. You manage costs through your Azure subscription.
7This guide shows you how to set up Claude in Microsoft Foundry and make API calls to it. You can use one of Anthropic’s client SDKs or direct HTTP requests. When you access Claude in Microsoft Foundry, you pay for Claude usage through the Azure Marketplace. [API model IDs and deployments](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments) lists the available models. Features such as the [1M-token context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) are also available. You manage costs through your Azure subscription.
88 
99Claude is available in Global Standard and US Data Zone Standard deployment types in Foundry resources, billed in Claude Consumption Units through the Azure Marketplace. Visit [Claude in Microsoft Foundry pricing](https://platform.claude.com/docs/en/about-claude/pricing#claude-in-microsoft-foundry-pricing) for details.
1010 
from line 12
1212 
1313Claude models in Microsoft Foundry are available in two hosting options. You choose the hosting option when you configure the deployment.
1414 
15| | Hosted on Azure | Hosted on Anthropic |
16| -------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
17| Where inference runs | Anthropic-operated service running on Azure infrastructure | Anthropic-operated service running on Anthropic infrastructure |
18| Model availability | The latest models in the Opus, Sonnet, and Haiku families | All Claude models available on Microsoft Foundry |
19| Deployment types | Global Standard, US Data Zone Standard | Global Standard |
20| Recommended for | Most workloads | [Access to features or models not yet hosted on Azure](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#additional-features-not-supported-when-hosted-on-azure) |
15| | Hosted on Azure | Hosted on Anthropic |
16| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17| Where inference runs | Anthropic-operated service running on Azure infrastructure | Anthropic-operated service running on Anthropic infrastructure |
18| Model availability | [Some Opus, Sonnet, and Haiku models](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments) | [All Claude models available on Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments) |
19| Deployment types | Global Standard, US Data Zone Standard | Global Standard |
20| Recommended for | Most workloads | Workloads that need [models hosted only on Anthropic](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments) or [features available only when hosted on Anthropic](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#additional-features-not-supported-when-hosted-on-azure) |
2121 
22For deployments hosted on Azure, prompts and completions remain within Azure. Only usage metadata and content flagged by Anthropic’s safety systems egress to Anthropic.
23 
2224<Note>
23 Anthropic acts as an independent processor for Microsoft. Customers using Claude through Microsoft Foundry are subject to Anthropic’s data use terms. For deployments hosted on Azure, prompts and completions remain within Azure. Only usage metadata and content flagged by Anthropic’s safety systems egress to Anthropic. Anthropic continues to provide its safety and data commitments.
25 Anthropic acts as an independent processor for Microsoft. Customers using Claude through Microsoft Foundry are subject to Anthropic’s [data use terms](https://www.anthropic.com/legal). Anthropic continues to provide its safety and data commitments.
2426</Note>
2527 
2628## Prerequisites
from line 31
2931 
3032* An active Azure subscription
3133* Access to the [Foundry portal](https://ai.azure.com/)
32* The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed (required for the Entra ID examples in cURL, CLI, and Ruby, optional otherwise)
33* An Azure RBAC role that allows you to use the resource, such as **Foundry User** (formerly Azure AI User) or **Cognitive Services User**
34* An Azure role-based access control (RBAC) role, such as **Foundry User** or **Cognitive Services User**, for the Foundry resource that you create in [Provisioning](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#provisioning)
35* Optional: the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) to get [Microsoft Entra ID](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#microsoft-entra-authentication) tokens with `az account get-access-token`
3436 
3537## Install an SDK
3638 
from line 120
118120 
119121### Provisioning Foundry resources
120122 
121Create a Foundry resource, which is required to use and manage services in Azure. You can follow these instructions to create a [Foundry resource](https://learn.microsoft.com/en-us/azure/ai-services/multi-service-resource?pivots=azportal#create-a-new-azure-ai-foundry-resource). Alternatively, you can start by creating a [Foundry project](https://learn.microsoft.com/en-us/azure/foundry/how-to/create-projects), which involves creating a Foundry resource.
122 
123123To provision your resource:
124124 
1251251. Navigate to the [Foundry portal](https://ai.azure.com/).
1262. Create a new Foundry resource or select an existing one.
1273. Configure access management using Azure-issued API keys or Entra ID (formerly Azure Active Directory) for role-based access control.
1284. Optionally configure the resource to be part of a private network (Azure Virtual Network) to restrict network access to your resource.
1295. Note your resource name. You’ll use this as `{resource}` in API endpoints (for example, `https://{resource}.services.ai.azure.com/anthropic/v1/*`).
1262. Create or select a Foundry resource in an [Azure region where your model is available](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/use-foundry-models-claude). You can follow Microsoft’s [instructions for creating a Foundry resource](https://learn.microsoft.com/en-us/azure/ai-services/multi-service-resource?pivots=azportal) or [create a Foundry project](https://learn.microsoft.com/en-us/azure/foundry/how-to/create-projects), which creates a resource for you.
1273. Note your resource name, which is `{resource}` in API endpoints such as `https://{resource}.services.ai.azure.com/anthropic/v1/*`.
130128 
129To restrict network access, you can [add your resource to a private network](https://learn.microsoft.com/en-us/azure/foundry/how-to/configure-private-link) (Azure Virtual Network).
130 
131131### Creating Foundry deployments
132132 
133133After creating your resource, deploy a Claude model to make it available for API calls. These steps describe the new Foundry portal (the **New Foundry** toggle is on):
from line 143
1431435. Configure the deployment:
144144 
145145 * **Deployment name:** Defaults to the model ID, but you can customize it (for example, `my-claude-deployment`). The deployment name cannot be changed after creation.
146 * **Region scope:** Select **Global**, or for models hosted on Azure, **Data Zone**. Selecting **Data Zone** creates a US Data Zone Standard deployment, which keeps inference within the United States and is equivalent to setting [`inference_geo: "us"`](https://platform.claude.com/docs/en/manage-claude/data-residency#inference-geo) on the Claude API.
147 * **Model version:** Expand **Model version settings** and select a version from the **Model version** dropdown menu. Each [hosting option](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options) is listed as a separate model version, labeled with its hosting option (for example, version 1 for Hosted on Anthropic, version 2 for Hosted on Azure).
146 * **Model version:** This setting determines the [hosting option](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options). Expand **Model version settings**, open the **Model version** dropdown menu, and select the version labeled with the hosting option that you want.
147 * **Region scope:** Select **Global**, or **Data Zone** if the deployment is hosted on Azure. **Data Zone** creates a US Data Zone Standard deployment, which keeps inference within the United States. For pricing, see [Inference geography](https://platform.claude.com/docs/en/about-claude/pricing#foundry-inference-geography).
148148 
1491496. Select **Deploy** and wait for provisioning to complete.
150150 
from line 158
158158 
159159## Authentication
160160 
161Claude in Microsoft Foundry supports two authentication methods: API keys and Entra ID tokens. Both methods use Azure-hosted endpoints in the format `https://{resource}.services.ai.azure.com/anthropic/v1/*`.
161Claude in Microsoft Foundry supports two authentication methods: API keys and Entra ID tokens. Both methods use endpoints in the format `https://{resource}.services.ai.azure.com/anthropic/v1/*`. For [Claude Mythos models](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments), use [Entra ID tokens](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#microsoft-entra-authentication).
162162 
163163### API key authentication
164164 
from line 173
173173 
174174* `ANTHROPIC_FOUNDRY_API_KEY` - Your API key
175175* `ANTHROPIC_FOUNDRY_RESOURCE` - Your resource name (for example, `example-resource`)
176* `ANTHROPIC_FOUNDRY_BASE_URL` - Alternative to resource name: the full base URL (for example, `https://example-resource.services.ai.azure.com/anthropic/`). The C# SDK does not read this variable: it always constructs the base URL from the resource name.
176* `ANTHROPIC_FOUNDRY_BASE_URL` - Alternative to resource name in every SDK except C#: the full base URL (for example, `https://example-resource.services.ai.azure.com/anthropic/`)
177177 
178178<Note>
179179 The `resource` and `base_url` parameters are mutually exclusive. Provide either the resource name (which the SDK uses to construct the URL as `https://{resource}.services.ai.azure.com/anthropic/`) or the full base URL directly.
from line 613
613613 
614614## Feature support
615615 
616Claude in Microsoft Foundry supports most Claude features. You can find all the features currently supported in [Features overview](https://platform.claude.com/docs/en/build-with-claude/overview).
616Claude in Microsoft Foundry supports most Claude features. [Features overview](https://platform.claude.com/docs/en/build-with-claude/overview) lists Claude’s features, and the **Availability** section of a feature’s page shows whether Foundry supports it and with which hosting option.
617617 
618618### Context window
619619 
620Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Sonnet 5.5, Claude Sonnet 5, Claude Sonnet 4.6, and Claude Haiku 5.5 have a [1M-token context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) on Microsoft Foundry. Other Claude models, including Claude Sonnet 4.5 (deprecated), have a 200k-token context window.
620All [available models](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-model-ids-and-deployments) have a [1M-token context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) on Microsoft Foundry except Claude Opus 4.5, Claude Sonnet 4.5 (deprecated), and Claude Haiku 4.5. These three models have a 200k-token context window.
621621 
622622### Claude features not supported for Claude in Microsoft Foundry
623623 
from line 644
644644 
645645## API responses
646646 
647API responses from Claude in Microsoft Foundry follow the standard [Claude API response format](https://platform.claude.com/docs/en/api/messages/create). This includes the `usage` object in response bodies, which provides detailed token consumption information for your requests. The `usage` object is consistent across all platforms, including the Claude API, Amazon Bedrock, Claude Platform on AWS, Foundry, and Claude Models on Google Cloud (Google managed).
647API responses from Claude in Microsoft Foundry follow the standard [Claude API response format](https://platform.claude.com/docs/en/api/messages/create), including the `usage` object.
648648 
649649For details on response headers specific to Foundry, see [Correlation request IDs](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#correlation-request-ids).
650650 
from line 728
728728 
729729**Error:** `403 Forbidden`
730730 
731* **Solution:** Your Azure account might lack the necessary permissions. Ensure you have the appropriate Azure RBAC role assigned (for example, **Foundry User** (formerly Azure AI User) or **Cognitive Services User**).
731**Cause:** Your Azure account might lack the necessary permissions.
732732 
733* **Solution:** Ensure you have the appropriate Azure RBAC role assigned (for example, **Foundry User** or **Cognitive Services User**).
734 
733735### Rate limiting
734736 
735737**Error:** `429 Too Many Requests`
from line 777
775777 Browse Anthropic models in the Foundry catalog.
776778 </Card>
777779 
778 <Card title="Azure AI Foundry pricing" icon="calculator" href="https://azure.microsoft.com/en-us/pricing/details/ai-foundry/#pricing">
779 View Microsoft’s pricing details for Azure AI Foundry.
780 <Card title="Microsoft Foundry pricing" icon="calculator" href="https://azure.microsoft.com/en-us/pricing/details/ai-foundry/#pricing">
781 View Microsoft’s pricing details for Microsoft Foundry.
780782 </Card>
781783 
782784 <Card title="Model pricing" icon="table" href="https://platform.claude.com/docs/en/about-claude/pricing#model-pricing">

build-with-claude/message-threads Changed · +42 / -42 lines

## Use a thread with the SDK ## Use a thread with an SDK

from line 37
3737 
3838With a message thread, requests are smaller, and time to first token stays lower and steadier as the conversation grows. Threads help most in long agent loops. Without a thread, every turn uploads the whole conversation again, and the API validates and tokenizes all of it again. With a thread, most of that work covers only the new turn.
3939 
40A message thread keeps a conversation on the server for a short time. You send the full conversation once, with your system prompt and tools. On each later turn, you send only the new messages and the `id` of the previous response. The API rebuilds the conversation before it calls the model. You add one parameter, `thread`, to a [Messages API](https://platform.claude.com/docs/en/api/messages) request. The response is the usual message.
40A message thread keeps a conversation on the server for a short time. You send the full conversation, your system prompt, and your tools once. On each later turn, you send the new messages and the `id` of the previous response instead of the full conversation. The API rebuilds the conversation before it calls the model. You add the [`thread`](https://platform.claude.com/docs/en/api/beta/messages/create#create.thread) parameter and a beta header to a Messages API request. The response is the usual message.
4141 
4242<Note>
4343 Message threads are different from [session threads](https://platform.claude.com/docs/en/managed-agents/session-threads) in Claude Managed Agents.
from line 45
4545 
4646## How message threads work
4747 
48* **Create.** Send your first request as you do today, with the full conversation, `system`, and `tools`, and add `"thread": {"type": "create"}`. The API stores the conversation, including Claude’s reply, under the response `id`.
49* **Continue.** Send only the messages since the previous response, and add `"thread": {"type": "continue", "previous_message_id": "<previous id>"}`. Leave `system` and `tools` out of the request. The thread keeps the values from the create request. Use each new response `id` for the next turn.
50* **Replay.** A thread is best-effort. It expires 5 minutes after its last request, and the API deletes it no more than 1 hour after its last use. Each response that the API stores restarts the 5 minutes. If the API can no longer continue the thread, a continue request returns a 404 error. Send the full conversation again in a new create request, and continue from that response’s `id`. The SDK thread helper does this replay for you (see [How the SDK helper behaves](https://platform.claude.com/docs/en/build-with-claude/message-threads#sdk-helper-handles)). After a response from a fallback model, see [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
48* **Create.** Send your first request as you do today, with the full conversation, `system`, and `tools`. Add `"thread": {"type": "create"}` to the request. The API stores the conversation, including Claude’s reply, under the response `id`.
49* **Continue.** Send only the messages since the previous response and add `"thread": {"type": "continue", "previous_message_id": "<previous id>"}`. Leave `system` and `tools` out of the request. The thread keeps the values from the create request. Use each new response `id` for the next turn.
50* **Replay.** A thread is best-effort. It expires 5 minutes after its last request, and the API deletes it no more than 1 hour after its last use. Each response that the API stores restarts the 5 minutes. If the API can no longer continue the thread, a continue request returns a 404 error. Send the full conversation again in a new create request and continue from the new response `id`. The SDK thread helper does this replay for you (see [How the SDK helper behaves](https://platform.claude.com/docs/en/build-with-claude/message-threads#sdk-helper-handles)). After a response from a fallback model, see [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
5151 
52Your application stays the source of truth for the conversation. Keep your own copy of every message, and build the [replay path](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover) from the start. No response, to a create or a continue request, says whether the API stored that turn. You find out on the next continue request. The SDK thread helper keeps this copy in memory while the helper object exists, and saves it nowhere else. If the conversation has to outlive your process, keep your own copy.
52Your application stays the source of truth for the conversation. Keep your own copy of every message and build the [replay path](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover) from the start. No response to a create or a continue request says whether the API stored that turn. You find out on the next continue request. The SDK thread helper keeps this copy in memory while the helper object exists, and it saves the copy nowhere else. If the conversation has to outlive your process, keep your own copy.
5353 
54## Use a thread with an SDK
54## Use a thread with the SDK
5555 
56The SDK has a thread helper that builds the thread requests for you. Create it with the same fields as a Messages request, then send it one turn at a time. The helper keeps the full conversation in memory.
56The SDK has a thread helper that builds each request for you. Create the helper with the same fields as a Messages request. Then send one turn at a time. The helper keeps the full conversation in memory.
5757 
5858This example has two turns. The helper creates a thread on the first turn and continues it on the second, and it adds the beta header for you. The top-level `cache_control` is optional. It asks for prompt caching on each turn (see [Prompt caching on a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#prompt-caching)). Without it, each later turn still sends only the new messages, but nothing is cached unless you add cache breakpoints yourself.
5959 
from line 217
217217 $thread = $client->beta->messages->thread(
218218 maxTokens: 1024,
219219 model: Model::CLAUDE_OPUS_5_5,
220 cacheControl: new BetaCacheControlEphemeral,
220 cacheControl: new BetaCacheControlEphemeral(),
221221 system: 'You are a support agent for Acme. Keep replies short.',
222222 );
223223 
from line 239
239239 
240240 # Create the helper. This call sends no request.
241241 thread = client.beta.messages.thread(
242 model: :"claude-opus-5-5",
242 model: Anthropic::Model::CLAUDE_OPUS_5_5,
243243 max_tokens: 1024,
244244 cache_control: {type: "ephemeral"},
245245 system_: "You are a support agent for Acme. Keep replies short."
from line 259
259259 
260260## Send the `thread` field yourself
261261 
262To build thread requests yourself, for example with cURL, the CLI, or an SDK’s usual `create` method, add the `thread` field to each request.
262Add the `thread` field to each request yourself. You can do this with cURL, with the CLI, or with an ordinary SDK request.
263263 
264264Send the `message-threads-2026-08-12` beta header on every request of a thread.
265265 
266This example creates a thread on the first turn and continues it on the second. The top-level `cache_control` asks for prompt caching on each turn. It takes effect once the conversation is longer than the [minimum cacheable length](https://platform.claude.com/docs/en/build-with-claude/prompt-caching).
266This example creates a thread on the first turn and continues it on the second. The top-level `cache_control` asks for prompt caching on each turn. Nothing is cached until the full conversation, together with `system` and `tools`, reaches the [minimum cacheable length](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#cache-limitations).
267267 
268268<CodeGroup>
269269 ```bash cURL
from line 526
526526 $first = $client->beta->messages->create(
527527 model: Model::CLAUDE_OPUS_5_5,
528528 maxTokens: 1024,
529 cacheControl: new BetaCacheControlEphemeral,
529 cacheControl: new BetaCacheControlEphemeral(),
530530 system: 'You are a support agent for Acme. Keep replies short.',
531531 messages: [
532532 ['role' => 'user', 'content' => 'Hi! I have a question about an order.'],
from line 540
540540 $second = $client->beta->messages->create(
541541 model: Model::CLAUDE_OPUS_5_5,
542542 maxTokens: 1024,
543 cacheControl: new BetaCacheControlEphemeral,
543 cacheControl: new BetaCacheControlEphemeral(),
544544 messages: [
545545 ['role' => 'user', 'content' => 'How long does standard shipping usually take?'],
546546 ],
from line 560
560560 
561561 # Turn 1: send the full conversation and create a thread
562562 first = client.beta.messages.create(
563 model: :"claude-opus-5-5",
563 model: Anthropic::Model::CLAUDE_OPUS_5_5,
564564 max_tokens: 1024,
565565 cache_control: {type: "ephemeral"},
566566 system_: "You are a support agent for Acme. Keep replies short.",
from line 572
572572 # Turn 2: send only the new message and the id of the turn 1 response.
573573 # Leave out system_ and tools: the thread keeps them.
574574 second = client.beta.messages.create(
575 model: :"claude-opus-5-5",
575 model: Anthropic::Model::CLAUDE_OPUS_5_5,
576576 max_tokens: 1024,
577577 cache_control: {type: "ephemeral"},
578578 messages: [{role: "user", content: "How long does standard shipping usually take?"}],
from line 609
609609 
610610Send only the new messages on a continue request. The API doesn’t check them against the messages it already has. A message you send again can appear twice in the conversation, or the request can return an error. For example, a continue request that starts with the previous response returns an error.
611611 
612The new messages usually start with a `user` message: your next user turn, or the `tool_result` blocks that answer a `tool_use` in the previous response. If a response stops with [`stop_reason: "pause_turn"`](https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons#pause-turn), resume it with a continue request from that response’s `id` and an empty `messages` list (`"messages": []`). If that request returns a 404 error, replay the full conversation, including the paused response, in a new create request. Don’t send a new `user` message while the turn is paused: the API rejects it. With the SDK thread helper, call `send()` (go, csharp: `Send()`; ruby: `send_message()`) with no messages: the helper sends this request and replays on a 404 error.
612The new messages usually start with a `user` message: your next user turn or the `tool_result` blocks that answer a `tool_use` in the previous response. If a response stops with [`stop_reason: "pause_turn"`](https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons#pause-turn), resume it with a continue request from that response’s `id` and an empty `messages` list (`"messages": []`). If that request returns a 404 error, replay the full conversation, including the paused response, in a new create request. Don’t send a new `user` message while the turn is paused: the API rejects it. With the SDK thread helper, call `send()` (go, csharp: `Send()`; ruby: `send_message()`) with no messages: the helper sends this request and replays on a 404 error.
613613 
614614A thread is append-only, and each response `id` can be continued once. Always continue from the latest response `id` of the thread. To edit or branch an earlier message, start a new thread with a create request. To replace earlier turns with a summary, see [Compact a conversation](https://platform.claude.com/docs/en/build-with-claude/message-threads#compaction).
615615 
from line 617
617617 
618618A thread does not cache your prompt for you. [Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) works as it does without a thread: you choose where the cache breakpoints go.
619619 
620To cache each turn, send a top-level `cache_control` on every request of the thread, as in the earlier example. The API applies it to the last block of each request’s `messages` that can be cached. Each turn then reads the earlier conversation from the cache and writes the new turn to it. The top-level `cache_control` is a fixed field: send the same value on every request.
620To cache each turn, send a top-level `cache_control` on every request of the thread as in the earlier example. The API applies it to the last block of each request’s `messages` that can be cached. Each turn then reads the earlier conversation from the cache and writes the new turn to it. The top-level `cache_control` is a fixed field: send the same value on every request.
621621 
622622You can also place `cache_control` breakpoints on blocks yourself:
623623 
from line 624
624624* Breakpoints that you send on the create request keep working on every later turn if they are on `tools`, on `system`, or on a message block before the last one. A breakpoint on the last block of a request’s `messages` writes the cache on that request. To cache each new turn, send a breakpoint on every request. A request without a breakpoint might still read part of the conversation from the cache.
625625* You can’t move or remove a breakpoint after you send it, because a continue request can’t send an earlier message again.
626626* A request with `thread` can carry at most 4 `cache_control` breakpoints. The top-level `cache_control` counts as one. Breakpoints on the `system` and `tools` of the create request count again on every continue request. Breakpoints on earlier stored messages do not count. One breakpoint too many returns a 400 error with the code `thread_unsupported_request`.
627* If you place breakpoints on message blocks yourself, remove them from earlier messages when you replay the conversation in a new create request, and keep one on the last block, so the request stays within the limit of 4.
627* If you place breakpoints on message blocks yourself, remove them from earlier messages and keep one on the last block when you replay the conversation in a new create request. The request then stays within the limit of 4.
628628 
629629## Streaming
630630 
from line 632
632632 
633633If the stream of a continue request drops before `message_stop`, send the same continue request again. If that request returns a `thread_already_continued` or `thread_continue_in_flight` error, replay the full conversation in a new create request.
634634 
635Your connection might have dropped while the server was still generating the response, or after the server saved it. That is why the API can reject the retry. Replaying your exact copy is safe.
635Your connection might have dropped while the server was still generating the response or after the server saved it. That is why the API can reject the retry. Replaying your exact copy is safe.
636636 
637637The SDK thread helper doesn’t retry the continue request after a dropped stream. See [How the SDK helper behaves](https://platform.claude.com/docs/en/build-with-claude/message-threads#sdk-helper-handles).
638638 
from line 648
648648* The request comes from a different user or service account from the one that created the thread. A thread created with a [workspace key (legacy)](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) stays with that key, so use the same key for the whole thread.
649649* The new messages add something that the stored conversation can’t take. For example, the first image in a conversation that had none can return this error.
650650 
651To recover, send the full conversation from your own copy in a new create request, with `system` and `tools`. The SDK thread helper sends this create request once by itself, and leaves out the `cache_control` breakpoints of earlier turns when it does. If earlier messages in your copy carry `cache_control` breakpoints, remove them first (see [Prompt caching on a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#prompt-caching)). Then continue from the new response `id`. If a fallback model wrote the previous response, see [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks). To rule out the ownership causes, use the same API key and workspace for every request of a thread. On Claude Platform on AWS, sign every request of a thread with credentials for the IAM role or IAM user that created it.
651To recover, send the full conversation from your own copy in a new create request with `system` and `tools`. The SDK thread helper sends this create request once by itself and leaves out the `cache_control` breakpoints of earlier turns when it does. If earlier messages in your copy carry `cache_control` breakpoints, remove them first (see [Prompt caching on a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#prompt-caching)). Then continue from the new response `id`. If a fallback model wrote the previous response, see [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks). To rule out the ownership causes, use the same API key and workspace for every request of a thread. On Claude Platform on AWS, sign every request of a thread with credentials for the IAM role or IAM user that created the thread.
652652 
653653A request for a model that does not exist also returns a 404 error, so check `error.details.error_code` before you replay.
654654 
655If a continue request still returns a 404 error right after you replay, the API might be unable to store that conversation, for example a very large one. Send it without `thread`. The SDK thread helper does this when you create it with `unsupported_request_behavior` (typescript, java, php: `unsupportedRequestBehavior`; go, csharp: `UnsupportedRequestBehavior`) set to `continue_unthreaded` (ruby: `:continue_unthreaded`; java: `CONTINUE_UNTHREADED`; csharp: `ContinueUnthreaded`; go: `BetaMessageThreadUnsupportedRequestBehaviorContinueUnthreaded`). Otherwise it replays on every turn.
655If a continue request still returns a 404 error right after you replay, the API might be unable to store that conversation (for example, a very large one). Send it without `thread`. The SDK thread helper does this when you create it with `unsupported_request_behavior` (typescript, java, php: `unsupportedRequestBehavior`; go, csharp: `UnsupportedRequestBehavior`) set to `continue_unthreaded` (ruby: `:continue_unthreaded`; java: `CONTINUE_UNTHREADED`; csharp: `ContinueUnthreaded`; go: `BetaMessageThreadUnsupportedRequestBehaviorContinueUnthreaded`). Otherwise, the helper replays on every turn.
656656 
657657### After a refusal
658658 
from line 660
660660 
661661### Use fallbacks with a thread
662662 
663[Server-side fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#server-side-fallback) is available with threads on the Claude API. Decide when you create the thread: send `fallbacks` on every request of the thread, or on none. The value of `fallbacks` can change between requests. A continue request that adds or drops `fallbacks` returns a 400 error with the code `thread_fingerprint_mismatch`.
663[Server-side fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#server-side-fallback) is available with threads on the Claude API. Decide when you create the thread: send `fallbacks` on every request of the thread or on none. The value of `fallbacks` can change between requests. A continue request that adds or drops `fallbacks` returns a 400 error with the code `thread_fingerprint_mismatch`.
664664 
665665A thread keeps one model, so the API doesn’t store a turn that a fallback model wrote. You get the response as usual, but you can’t continue from its `id`. After each response, follow these steps:
666666 
from line 675
675675 
6766764. Go back to step 1 with the response to that request. When it has no `fallback_message` entry, continue the new thread from its `id`.
677677 
678[Sticky routing](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#sticky-routing) starts after a request falls back (a create request, or a request without `thread`). For about an hour, it might send later create requests for the same conversation that include `fallbacks` straight to the fallback model, without trying the model you requested. The API stores none of those turns, and each answered one restarts the hour. A continue request never starts this routing and never uses it. Sticky routing doesn’t apply if your organization or workspace uses zero data retention or customer-managed encryption keys.
678[Sticky routing](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#sticky-routing) starts after a request falls back (a create request or a request without `thread`). For about an hour, it might send later create requests for the same conversation that include `fallbacks` straight to the fallback model without trying the model you requested. The API stores none of those turns, and each answered one restarts the hour. A continue request never starts this routing and never uses it. Sticky routing doesn’t apply if your organization or workspace uses zero data retention or customer-managed encryption keys.
679679 
680680## Compact a conversation
681681 
682A thread is append-only, so you can’t replace its earlier turns with a summary. To compact a conversation, start a new thread from the summary. Write the summary in your code, and send it as an ordinary message in a new create request, with `system` and `tools`. [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
682A thread is append-only, so you can’t replace its earlier turns with a summary. To compact a conversation, start a new thread from the summary. Write the summary in your code and send it as an ordinary message in a new create request with `system` and `tools`. [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
683683 
684684## How the SDK helper behaves
685685 
from line 689
689689* Creates a thread on the first turn and continues it after that, sending only the new messages and leaving out `system` and `tools`.
690690* Replays the full conversation once in a new create request when a continue request returns `thread_not_found`, `thread_already_continued`, or `thread_continue_in_flight`.
691691* Resumes a `pause_turn` response when you call `send()` (go, csharp: `Send()`; ruby: `send_message()`) with no messages.
692* Starts a new thread after a refusal. You get the `stop_reason: "refusal"` response as usual, but the helper doesn’t keep that turn: it takes back the messages you gave to that call. Messages that you added with `thread.append(...)` (csharp, go: `thread.Append(...)`; php: `$thread->append(...)`), or gave when you created the helper, stay staged. Your next turn sends them with the conversation from before the refused turn, in a new create request. Send a rephrased message, or, if a staged message led to the refusal, start a new thread from the params without it.
692* Starts a new thread after a refusal. You get the `stop_reason: "refusal"` response as usual, but the helper doesn’t keep that turn: it takes back the messages you gave to that call. Messages that you added with `thread.append(...)` (csharp, go: `thread.Append(...)`; php: `$thread->append(...)`) or gave when you created the helper stay staged. Your next turn sends them in a new create request with the conversation from before the refused turn. Send a rephrased message or, if a staged message led to the refusal, start a new thread from the params without that message.
693693* Sends a new create request after a response from a fallback model. When a response has a `fallback_message` entry in `usage.iterations`, the helper keeps the response and sends the full conversation in a new create request on the next turn. It doesn’t wait for a 404 error. That request keeps the `model` and `fallbacks` that you set.
694* Leaves out the `cache_control` breakpoints of earlier turns whenever it sends them again, for example in a replay or in the first turn of a fork. Your newest messages, `system`, `tools`, and the top-level `cache_control` go out as you gave them.
694* Leaves out the `cache_control` breakpoints of earlier turns whenever it sends those turns again (for example, in a replay or in the first turn of a fork). Your newest messages, `system`, `tools`, and the top-level `cache_control` go out as you gave them.
695695 
696696What you handle yourself:
697697 
698* **Fallbacks.** While the API keeps answering from a fallback model, the helper sends the full conversation in a new create request on every turn, because the API stores none of those turns. It goes back to continue requests after a response from the model that you requested. To move the conversation to the fallback model instead, start a new thread from the params with that `model` and without `fallbacks`, as in [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
698* **Fallbacks.** While the API keeps answering from a fallback model, the helper sends the full conversation in a new create request on every turn because the API stores none of those turns. The helper goes back to continue requests after a response from the model that you requested. To move the conversation to the fallback model instead, start a new thread from the params with that `model` and without `fallbacks` as in [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
699699* **Dropped streams.** If a stream ends partway through a response, the helper keeps the finished blocks and any text that arrived, and the next turn sends the full conversation in a new create request. The helper doesn’t retry by itself: to re-send the interrupted turn instead, call `send()` (go, csharp: `Send()`; ruby: `send_message()`) with no messages. If the kept part ends in tool calls, answer them in your next message. If you stop reading a stream after it shows `stop_reason: "refusal"`, the helper treats that turn as a refusal.
700700* **Other errors.** `thread_fingerprint_mismatch` and `thread_unsupported_request` errors reach your code. To carry on without `thread` after a `thread_unsupported_request` error, create the helper with `unsupported_request_behavior` (typescript, java, php: `unsupportedRequestBehavior`; go, csharp: `UnsupportedRequestBehavior`) set to `continue_unthreaded` (ruby: `:continue_unthreaded`; java: `CONTINUE_UNTHREADED`; csharp: `ContinueUnthreaded`; go: `BetaMessageThreadUnsupportedRequestBehaviorContinueUnthreaded`). With that setting, the helper also stops using `thread` when the first continue request after a replay returns `thread_not_found` again. The API might be unable to store that conversation. Without that setting, the helper replays on every turn. A tool runner that creates its own thread uses that setting by default.
701701 
702The SDK’s beta tool runner also uses a thread by default, which you can turn off when you create the runner.
702The SDK’s beta tool runner also uses a thread by default. You can turn off this default when you create the runner.
703703 
704704### Other helper methods
705705 
from line 712
712712| Add messages without sending | `thread.append(...)` (csharp, go: `thread.Append(...)`; php: `$thread->append(...)`) |
713713| Change fields for later turns | `thread.update(...)` (csharp: `thread.Update(p => p with { ... })`; go: `thread.Params.MaxTokens = ...`; java: `thread.update(b -> ...)`; php: `$thread->update([...])`) |
714714| Copy the thread | `thread.fork()` (csharp, go: `thread.Fork()`; php: `$thread->fork()`; ruby: `thread.fork`) |
715| Fields and conversation, to start a new thread | `thread.params` (csharp, go: `thread.Params`; java: `thread.params()`; php: `$thread->params()`) |
715| Fields and conversation to start a new thread | `thread.params` (csharp, go: `thread.Params`; java: `thread.params()`; php: `$thread->params()`) |
716716| Tool runner on this thread | `thread.tool_runner()` (typescript, java: `thread.toolRunner()`; csharp: `thread.ToolRunner(tools)`; go: `thread.NewToolRunner(tools)`; php: `$thread->toolRunner()`; ruby: `thread.tool_runner`) |
717717| Tool runner without a thread | `tool_runner(..., thread=False)` (typescript: `toolRunner({ ..., thread: false })`; csharp: `ToolRunner(parameters, tools, thread: false)`; go: `BetaToolRunnerParams{DisableThread: true}`; java: `ToolRunnerCreateParams.builder().thread(false)`; php: `toolRunner(..., thread: false)`; ruby: `tool_runner(..., thread: false)`) |
718718 
from line 727
727727 
728728In C#, the request goes out when you start to read the stream.
729729 
730In C#, Go, Java, and PHP, after a refusal `thread.LastMessage` (go: `thread.LastMessage()`; java: `thread.lastMessage()`; php: `$thread->lastMessage()`) still returns the previous turn’s response, or nothing on a first turn. Read the refusal from the stream’s events.
730In C#, Go, Java, and PHP, after a refusal, `thread.LastMessage` (go: `thread.LastMessage()`; java: `thread.lastMessage()`; php: `$thread->lastMessage()`) still returns the previous turn’s response or nothing on a first turn. Read the refusal from the stream’s events.
731731 
732732**Changing fields.** An update sends nothing and applies to every later turn. Once a thread has a response, the helper refuses a turn that changes `system` or `tools`, and the API rejects a change to any other fixed field (see [What to send on each request](https://platform.claude.com/docs/en/build-with-claude/message-threads#what-to-send)). To change one of these fields, start a new thread from the params, or fork the thread and update the fork before its first turn.
733733 
734**Forking.** A fork copies the conversation, the fields, and the request options, and sends nothing. Its first turn sends the full conversation in a new create request, and the two threads are independent after that. A fork always starts from the whole conversation, not from an earlier response.
734**Forking.** A fork copies the conversation, the fields, and the request options, and it sends nothing. Its first turn sends the full conversation in a new create request, and the two threads are independent after that. A fork always starts from the whole conversation, not from an earlier response.
735735 
736**Params.** The params hold the helper’s fields and the full conversation. Pass them to the method that creates a helper to start a new thread, for example with a different `system` (see [What to send on each request](https://platform.claude.com/docs/en/build-with-claude/message-threads#what-to-send)), or with `messages` cut back to drop later turns. A thread that you start from the params sends every message as you gave it, `cache_control` breakpoints included, so keep within the limit of 4 (see [Prompt caching on a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#prompt-caching)). Except in Ruby, the params leave out the request options, so pass those again.
736**Params.** The params hold the helper’s fields and the full conversation. Pass them to the method that creates a helper to start a new thread. For example, start one with a different `system` (see [What to send on each request](https://platform.claude.com/docs/en/build-with-claude/message-threads#what-to-send)) or with `messages` cut back to drop later turns. A thread that you start from the params sends every message as you gave it, `cache_control` breakpoints included, so keep within the limit of 4 (see [Prompt caching on a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#prompt-caching)). Except in Ruby, the params leave out the request options, so pass those again.
737737 
738738**Structured output.** Give the output format when you create the helper. A later turn can’t change it. How you get the parsed result depends on the SDK:
739739 
from line 751
751751| Status | `error_code` | Meaning | What to do |
752752| ------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
753753| 404 | `thread_not_found` | The API can’t continue the thread. | Send the full conversation in a new create request. |
754| 400 | `thread_fingerprint_mismatch` | A fixed field differs from the value stored with the thread. The error message names the fields. | Keep the fixed fields the same, or start a new thread to change one. |
754| 400 | `thread_fingerprint_mismatch` | A fixed field differs from the value stored with the thread. The error message names the fields. | Keep the fixed fields the same or start a new thread to change one. |
755755| 400 | `thread_already_continued` | Each response `id` can be continued once. | Continue from the latest response `id` of the thread. If your client never received that response, replay. |
756756| 400 | `thread_continue_in_flight` | Another continue request from this response `id` is still running. This is usually your own earlier attempt. | Let it finish and continue from its response `id`, or replay. |
757| 400 | `thread_unsupported_request` | The request uses a feature or an organization setting that threads don’t support. `error.details.unsupported` names it when present. | Remove that feature from the request, or send the full conversation without `thread`. |
757| 400 | `thread_unsupported_request` | The request uses a feature or an organization setting that threads don’t support. `error.details.unsupported` names it when present. | Remove that feature from the request or send the full conversation without `thread`. |
758758 
759Some 400 errors for thread requests carry no `error_code`, for example a continue request without `previous_message_id`, or one that includes `system` or `tools`.
759Some requests with `thread` return a 400 error with no `error_code`. For example, a continue request returns this error if it has no `previous_message_id` or if it includes `system` or `tools`.
760760 
761761The following example shows an error body:
762762 
from line 781
781781 
782782* [Message Batches](https://platform.claude.com/docs/en/build-with-claude/batch-processing). A request item that includes `thread` ends with an `invalid_request_error` in the batch results.
783783* [Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting). A token counting request that includes `thread` returns a 400 error. Count the full conversation instead, with `system` and `tools`.
784* [Compaction](https://platform.claude.com/docs/en/build-with-claude/compaction). [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads. A request that includes `thread` returns a 400 error if it sets the `compaction` parameter, or if it sends a `compaction` block with the `compact-2026-09-04` beta header. See [Compact a conversation](https://platform.claude.com/docs/en/build-with-claude/message-threads#compaction).
785* [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing), except `clear_thinking_20251015` with `keep: "all"`.
784* [Compaction](https://platform.claude.com/docs/en/build-with-claude/compaction). [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) is not available with threads. A request that includes `thread` returns a 400 error if it sets the `compaction` parameter or if it sends a `compaction` block with the `compact-2026-09-04` beta header. See [Compact a conversation](https://platform.claude.com/docs/en/build-with-claude/message-threads#compaction).
785* [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) except `clear_thinking_20251015` with `keep: "all"`.
786786* Organizations that have [HIPAA readiness](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#hipaa-readiness) enabled.
787787* Organizations that have [Inference hooks](https://platform.claude.com/docs/en/manage-claude/inference-hooks) turned on.
788788 

build-with-claude/text-watermark Changed · +5 / -1 lines

from line 10
1010 
1111## Sampling settings
1212 
13On Claude Sonnet 4.6, text generated for a request that sets `temperature`, `top_p`, or `top_k` to a non-default value might not carry the watermark. If you rely on the watermark, omit all three parameters from your requests, including any that a framework or client library sets for you.
13**This section applies to:** Claude Sonnet 4.6
14 
15If you need your output to carry the watermark, omit `temperature`, `top_p`, and `top_k` from your requests. If a request sets any of them to a non-default value, the output might not carry the watermark.
16 
17Your framework or client library might set these parameters for you. If you need the watermark, check its settings and the request body it sends, and remove any of the three that it sets.
1418 

manage-claude/admin-api-keys Changed · +30 / -26 lines

from line 4
44description: Create an Admin API key for your Claude Console or Claude Enterprise organization.
55---
66 
7An Admin API key authenticates every API in the **Admin** section of this guide: the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api), [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api), [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api), [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api), [Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api), [Spend Limits API](https://platform.claude.com/docs/en/manage-claude/spend-limits-api), [Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api), [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api), and [Rate Limits API](https://platform.claude.com/docs/en/manage-claude/rate-limits-api). You do not need a separate key for each API. The one exception is the Admin API’s service-account, federation-issuer, and federation-rule endpoints, which accept only an OAuth bearer token with the `org:admin` scope. See [Obtain an OAuth bearer token](https://platform.claude.com/docs/en/manage-claude/admin-api#oauth-bearer-token).
7An Admin API key authenticates calls to the APIs that manage and report on your organization, such as the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) and the [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api). One key can work with several of these APIs.
88 
9Where you create the key depends on which Claude product your organization uses.
10 
119## Which key do you need?
1210 
13| Your organization | Create the key in | Key prefix | Who can create it | Works with |
14| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15| **Claude Console** (Claude Platform, `platform.claude.com`) | [Admin keys](https://platform.claude.com/settings/admin-keys) page (`platform.claude.com/settings/admin-keys`) in the Claude Console | `sk-ant-admin01-...` | Organization members with the **admin** role | [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api), [Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api), [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api), [Rate Limits API](https://platform.claude.com/docs/en/manage-claude/rate-limits-api), [Claude Code Analytics API](https://platform.claude.com/docs/en/manage-claude/claude-code-analytics-api), and the Compliance API [Activity Feed](https://platform.claude.com/docs/en/manage-claude/compliance-activity-feed) |
16| **Claude Enterprise** (`claude.ai`) | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | `sk-ant-api01-...` | The parent organization’s **primary owner** (all linked organizations). An **organization owner** can create one carrying Compliance API scopes only, restricted to their own organization | [User management](https://platform.claude.com/docs/en/manage-claude/user-management) (the Admin API’s member, invite, and group endpoints), [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api), [Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api), [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api), [Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api), [Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api), and [Spend Limits API](https://platform.claude.com/docs/en/manage-claude/spend-limits-api), according to the [scopes](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#choose-scopes-for-a-claude-enterprise-key) you select |
11The key you need depends on which Claude product your organization uses: Claude Console (Claude Platform) or Claude Enterprise.
1712 
18A key created in one organization cannot be used to manage a different organization. If your company uses both Claude Console and Claude Enterprise, create one key in each.
13| Organization | Claude Console | Claude Enterprise |
14| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
15| **Sign-in address** | `platform.claude.com` | `claude.ai` |
16| **Where to create it** | [Admin keys](https://platform.claude.com/settings/admin-keys) page in the Claude Console | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) |
17| **Key prefix** | `sk-ant-admin01-...` | `sk-ant-api01-...` |
18| **Who can create it** | Organization members with the **admin** role | **Primary owner:** any scope<br />**Organization owner:** Compliance API scopes only, for their own organization |
19| **Scopes** | None to select: every key has full access to the endpoints that accept it | [Choose scopes](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#choose-scopes-for-a-claude-enterprise-key) when you create the key. The key works only with the APIs your scopes cover |
20| **Works with** | [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api)<br />[Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api)<br />[Compliance API Activity Feed](https://platform.claude.com/docs/en/manage-claude/compliance-activity-feed)<br />[Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api) (legacy)<br />[Rate Limits API](https://platform.claude.com/docs/en/manage-claude/rate-limits-api)<br />[Claude Code Analytics API](https://platform.claude.com/docs/en/manage-claude/claude-code-analytics-api) | Admin API [user management](https://platform.claude.com/docs/en/manage-claude/user-management)<br />[Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api)<br />[Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api)<br />[Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api)<br />[Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api)<br />[Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api)<br />[Spend Limits API](https://platform.claude.com/docs/en/manage-claude/spend-limits-api) |
1921 
22Most keys reach only the organization you created them in. Some keys, such as those with Compliance API, group, or audit scopes, can reach further if your company links its organizations under a [parent organization](https://platform.claude.com/docs/en/manage-claude/compliance-api-access#which-key-do-you-need). If your company uses both Claude Console and Claude Enterprise, create one key in each.
23 
2024## Create a key for a Claude Console organization
2125 
22<Steps>
23 <Step title="Sign in as an organization admin">
24 Only organization members with the **admin** role can create Admin API keys. See [Organization roles and permissions](https://platform.claude.com/docs/en/manage-claude/admin-api#organization-roles-and-permissions).
25 </Step>
26An individual Claude Console account cannot create this key, so [set up an organization](https://platform.claude.com/docs/en/manage-claude/admin-api#availability) first. To use the key with the Activity Feed, [enable the Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api-access#set-up-the-compliance-api) before you create it.
2627 
28<Steps>
2729 <Step title="Open Admin keys settings">
28 In the Claude Console, go to the [Admin keys](https://platform.claude.com/settings/admin-keys) page (`platform.claude.com/settings/admin-keys`).
30 Sign in to the Claude Console as an [organization admin](https://platform.claude.com/docs/en/manage-claude/admin-api#organization-roles-and-permissions). Go to the [Admin keys](https://platform.claude.com/settings/admin-keys) page (`platform.claude.com/settings/admin-keys`).
2931 </Step>
3032 
3133 <Step title="Create the key">
32 Click **Create admin key**, give it a name, select a [key expiration](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration), and click **Add**. Claude Console keys do not have selectable scopes; every key carries full access to all endpoints that accept Admin API keys (the service-account and federation endpoints noted at the top of this page do not accept Admin API keys).
34 Click **Create admin key**, give it a name, select a [key expiration](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration), and click **Add**.
3335 </Step>
3436 
3537 <Step title="Copy and store the secret">
from line 42
4042## Create a key for a Claude Enterprise organization
4143 
4244<Steps>
43 <Step title="Sign in as the primary owner or an organization owner">
44 The **primary owner** of the Claude Enterprise parent organization can create a key that can access every linked organization, or one restricted to a single organization. An **organization owner** can create a key with Compliance API scopes only, restricted to their own organization.
45 </Step>
46 
4745 <Step title="Open API settings">
48 Go to [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) and find the **Keys** section.
46 Sign in to claude.ai as the [primary owner or an organization owner](https://platform.claude.com/docs/en/manage-claude/user-management#organization-roles). Go to [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) and find the **Keys** section.
4947 </Step>
5048 
51 <Step title="Click + Create key">
52 Name the key and select the scopes you need from the [scopes table](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#choose-scopes-for-a-claude-enterprise-key). The primary owner can combine scopes from different APIs (for example, `read:analytics` and `read:spend_limits`) on a single key.
49 <Step title="Create the key">
50 Click **Create key**, name the key, and select the scopes you need from the [scopes table](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#choose-scopes-for-a-claude-enterprise-key). The primary owner can combine scopes from different APIs (for example, `read:analytics` and `read:spend_limits`) on a single key.
51 
52 If the **Key access** options appear when you select a Compliance API scope, **Only this organization** is selected by default. To reach every organization under your parent organization, choose **All organizations**. Such a key can hold only Compliance API, group, and audit scopes.
53 
54 Click **Create**. If the key has the `delete:compliance_user_data` scope, also click **Confirm and create key**.
5355 </Step>
5456 
5557 <Step title="Copy and store the secret">
from line 61
5961 
6062## Choose scopes for a Claude Enterprise key
6163 
62When you create a Claude Enterprise key, select every scope that the APIs you plan to call require. Scopes are fixed at creation; to add a scope later, create a new key.
64When you create a Claude Enterprise key, select every scope that the APIs you plan to call require. Scopes are fixed at creation; to add a scope later, create a new key. A key that holds only Compliance API scopes is also called a Compliance Access Key. A key that holds only `read:analytics` is also called an Analytics API key.
6365 
6466| To call... | Select these scopes |
6567| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
from line 71
6971| Admin API [user management](https://platform.claude.com/docs/en/manage-claude/user-management): create, rename, and delete groups; add and remove group members; with `write:members`, assign the `managed` role (on an invite or a role change) or assign groups on an invite | `write:rbac_groups` |
7072| [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api): read plugins, versions, installation settings, shares, and marketplaces; download plugin files, including the files of members’ personal plugins; validate a marketplace before you connect it | `read:plugins` |
7173| [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api): upload plugins and versions; choose which version members are served; delete plugins, including members’ personal plugins; set and remove installation settings; set a marketplace’s default installation setting; validate a marketplace before you connect it (to read plugins, also select `read:plugins`) | `write:plugins` |
72| [Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api): read Claude Tag’s settings on Slack channels and Slack workspaces; list Access bundles and where they are attached (no other scope grants access to the Claude Tag API) | `read:claude_tag` |
74| [Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api): read Claude Tag’s settings on Slack channels and Slack workspaces; list Access bundles and where they are attached (no other scope grants read access to the Claude Tag API) | `read:claude_tag` |
7375| [Claude Tag API](https://platform.claude.com/docs/en/manage-claude/claude-tag-api): set up and remove channels; change settings; attach and detach Access bundles (to read as well, also select `read:claude_tag`) | `write:claude_tag` |
7476| [Spend Limits API](https://platform.claude.com/docs/en/manage-claude/spend-limits-api): read members’ effective spend limits and increase requests | `read:spend_limits` |
7577| [Spend Limits API](https://platform.claude.com/docs/en/manage-claude/spend-limits-api): set or clear per-user spend limits; approve or deny increase requests | `write:spend_limits` |
from line 82
8082| [Compliance API organization endpoints](https://platform.claude.com/docs/en/manage-claude/compliance-org-data): read organization metadata and effective settings, and an organization’s [Security posture](https://platform.claude.com/docs/en/manage-claude/compliance-security-posture/results-reference); [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api): every `GET` endpoint, including file downloads | `read:compliance_org_data` |
8183| Admin API [user management](https://platform.claude.com/docs/en/manage-claude/user-management) read endpoints, every Compliance API read endpoint, and every [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api) `GET` endpoint, including file downloads, with a single read-only scope (for security-audit integrations; does not include the Spend Limits or Analytics APIs) | `read:org_audit` |
8284 
83The Compliance and Analytics APIs must be enabled for your organization before keys with those scopes can be used. See [Set up the Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api-access#set-up-the-compliance-api) and [Get access to the Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api#get-access-to-the-claude-enterprise-analytics-api).
85Compliance API scopes need the [Compliance API enabled](https://platform.claude.com/docs/en/manage-claude/compliance-api-access#set-up-the-compliance-api) before you can create a key with them. The `read:analytics` scope needs [access to the Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api#get-access-to-the-claude-enterprise-analytics-api).
8486 
85You can create and use keys with `read:plugins` or `write:plugins` only if your organization can use the Plugins API. The [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api) guide says which organizations can use it. In those organizations, keys with `read:org_audit` or `read:compliance_org_data` can also call the Plugins API’s read endpoints, including file downloads, but not marketplace validation. The `read:plugins` and `write:plugins` scopes act only on the organization the key was created in. See [Plugins API scopes](https://platform.claude.com/docs/en/manage-claude/plugins-api#scopes) and [Reading another organization under the same parent](https://platform.claude.com/docs/en/manage-claude/plugins-api#reading-another-organization-under-the-same-parent).
87The `read:plugins` and `write:plugins` scopes need an organization that can use the [Plugins API](https://platform.claude.com/docs/en/manage-claude/plugins-api), and they act only on the organization you created the key in. Keys with `read:org_audit` or `read:compliance_org_data` can read the Plugins API only in organizations that can use it. See [Plugins API scopes](https://platform.claude.com/docs/en/manage-claude/plugins-api#scopes). To read another organization’s plugins, see [Reading another organization under the same parent](https://platform.claude.com/docs/en/manage-claude/plugins-api#reading-another-organization-under-the-same-parent).
8688 
8789## Use the key
8890 
8991Pass the key in the `x-api-key` header on every request. See each API’s documentation for complete request examples.
9092 
91A call that exceeds the key’s scopes returns `403 Forbidden` with a message listing the scopes the key has and the scopes the endpoint needs.
93A call to an endpoint outside the key’s scopes returns `403 Forbidden`. The error message names the scopes the endpoint accepts.
94 
95Neither a Claude Console key nor a Claude Enterprise key works with the Admin API’s service-account, federation-issuer, or federation-rule endpoints. Those endpoints accept only an OAuth bearer token with the `org:admin` scope. See [OAuth bearer token](https://platform.claude.com/docs/en/manage-claude/admin-api#oauth-bearer-token).
9296 
9397## Next steps
9498 

manage-claude/analytics-api Changed · +5 / -5 lines

from line 13
1313 
1414## Which API do you need?
1515 
16| API | Key type | Created in | Who can create it | What it covers |
17| ----------------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
18| **Claude Code Analytics API** | Admin API key (`sk-ant-admin01-...`) | [Admin keys](https://platform.claude.com/settings/admin-keys) page (`platform.claude.com/settings/admin-keys`) in the Claude Console | Organization admin | Daily Claude Code metrics per user: sessions, lines of code, commits, pull requests, tool acceptance, and estimated cost by model |
19| **Claude Enterprise Analytics API** | Analytics API key | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | Primary owner | Organization-wide engagement and adoption (user activity, active-user summaries, project, skill, and connector usage), plus cost and usage reports |
16| API | Key type | Created in | Who can create it | What it covers |
17| ----------------------------------- | ----------------- | ---------------------------------------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
18| **Claude Code Analytics API** | Admin API key | [Admin keys](https://platform.claude.com/settings/admin-keys) page in the Claude Console | Organization admin | Daily Claude Code metrics for each user: sessions, lines of code, commits, pull requests, tool acceptance, and estimated cost by model |
19| **Claude Enterprise Analytics API** | Analytics API key | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | Primary owner | Organization-wide engagement and adoption (user activity, active-user summaries, project, skill, and connector usage), plus cost and usage reports |
2020 
2121The key types are not interchangeable: an Admin API key cannot call the Claude Enterprise Analytics API, and an Analytics API key cannot call the Admin API. The one exception is the [Usage and Cost Analytics API](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api), which Claude Enterprise organizations call with their Analytics API key. Both product analytics APIs appear under the [Admin API reference](https://platform.claude.com/docs/en/api/beta/organization), but they are separate APIs with separate key types. If your organization uses both the Claude Platform and Claude Enterprise, you can provision both keys and use each API for its own data.
2222 
from line 25
2525</Note>
2626 
2727<Note>
28 If you want to view engagement and adoption data in the product rather than programmatically, use the [Analytics dashboard](https://claude.ai/analytics/activity) in claude.ai. For governance and auditing use cases (individual user actions, raw activity events, conversation content), see the [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api-access).
28 If you want to view engagement and adoption data in the product rather than programmatically, use the [Analytics dashboard](https://claude.ai/analytics/activity) in claude.ai. For governance and auditing use cases (individual user actions, raw activity events, conversation content), see the [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api).
2929</Note>
3030 
3131## Get access to the Claude Code Analytics API

manage-claude/compliance-api-access Changed · +11 / -11 lines

from line 16
1616 
1717## Which key do you need?
1818 
19| Key type | Created in | Used for | Works with the Compliance API? |
20| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
21| **Compliance Access Key** (`sk-ant-api01-...`) | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | Activity Feed, chats, files, projects, sessions (in apps such as Cowork and Claude Code), users, organization metadata, and organization settings | Yes (all endpoints) |
22| **Admin API key** (`sk-ant-admin01-...`) | [Admin keys](https://platform.claude.com/settings/admin-keys) page (`platform.claude.com/settings/admin-keys`) in the Claude Console | The [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) and the Compliance API Activity Feed | Activity Feed only |
23| **Analytics API key** | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | The Claude Enterprise Analytics API (see [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api)) | No |
24| **Claude API key** (`sk-ant-api03-...`) | [API keys](https://platform.claude.com/settings/keys) page (`platform.claude.com/settings/keys`) in the Claude Console | Calling Claude models through the [Claude API](https://platform.claude.com/docs/en/api/overview) | No |
19| Key type | Created in | Used for | Works with the Compliance API? |
20| ---------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
21| **Compliance Access Key** (`sk-ant-api01-...`) | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | Activity Feed, chats, files, projects, sessions (in apps such as Cowork and Claude Code), users, organization metadata, and organization settings | Yes (all endpoints) |
22| **Admin API key** (`sk-ant-admin01-...`) | [Admin keys](https://platform.claude.com/settings/admin-keys) page in the Claude Console | The [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) and the Compliance API Activity Feed | Activity Feed only |
23| **Analytics API key** | [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access) | The Claude Enterprise Analytics API (see [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api)) | No |
24| **Claude API key** (`sk-ant-api03-...`) | [API keys](https://platform.claude.com/settings/keys) page in the Claude Console | Calling Claude models through the [Claude API](https://platform.claude.com/docs/en/api/overview) | No |
2525 
2626A Claude Enterprise tenant has one **parent organization** that centralizes identity, SSO, and SCIM for every workload organization beneath it. These workload organizations are the parent’s **linked organizations**.
2727 
from line 42
4242 Where you enable the Compliance API depends on how your organization is set up:
4343 
4444 * **Claude Enterprise organizations:** The primary owner enables the Compliance API at [claude.ai > Organization settings > API](https://claude.ai/admin-settings/api-access). Enablement occurs at the parent organization level and cascades to every linked organization, both claude.ai and Claude Console.
45 * **Standalone Claude Console organizations:** An organization admin turns on the **Compliance API** toggle on the [Compliance](https://platform.claude.com/settings/security) page (`platform.claude.com/settings/security`) in the Claude Console. Enablement is self-service for eligible organizations, and the change takes effect immediately. If the page shows a page-not-found error, or doesn’t show the **Compliance API** section, you do not have the admin role, your organization is linked to a parent organization (the Compliance API is enabled from the parent organization instead), or your organization is not eligible for self-service enablement; contact your account team or [Anthropic support](https://support.claude.com) if you are not sure which applies.
46 * **Claude Console organizations linked to a parent organization:** There is nothing to turn on in Claude Console. Ask the primary owner of your parent organization to enable the Compliance API in claude.ai, or contact your account team.
45 * **Standalone Claude Console organizations:** An organization admin turns on the **Compliance API** toggle on the [Compliance](https://platform.claude.com/settings/security) page (`platform.claude.com/settings/security`) in the Claude Console. Enablement is self-service for eligible organizations, and the change takes effect immediately. If the page shows a page-not-found error, or doesn’t show the **Compliance API** section, three causes are possible. You might not have the admin role. Your organization might be linked to a parent organization. Or your organization might not be eligible for self-service enablement. For a linked organization, the Compliance API is enabled from the parent organization instead. Contact your account team or [Anthropic support](https://support.claude.com) if you are not sure which cause applies.
46 * **Claude Console organizations linked to a parent organization:** There is nothing to turn on in Claude Console. Ask whoever manages your parent organization to enable the Compliance API, or contact your account team.
4747 
4848 Organizations with the Compliance API enabled cannot call the Claude API directly from a browser. When a parent organization enables it, that includes every linked Claude Console organization. Before you enable the Compliance API, ask the teams that use these organizations whether any application calls the Claude API from browser code. See [Browser-based applications](https://platform.claude.com/docs/en/manage-claude/authentication#browser-based-applications).
4949 
5050 <Warning>
51 **Turning the Compliance API off stops activity recording.** An organization admin can turn the Compliance API off at any time with the same **Compliance API** toggle that turns it on. While the Compliance API is off, no activity events are recorded for your organization, so the [Activity Feed](https://platform.claude.com/docs/en/manage-claude/compliance-activity-feed) receives no new events. Activity that is not recorded while the Compliance API is off cannot be recovered later. Turning the Compliance API back on resumes recording from that point forward; activity that was already recorded is not deleted. Access Transparency events are an exception. If your organization is enrolled in [Access Transparency](https://platform.claude.com/docs/en/manage-claude/access-transparency), turning the Compliance API off stops your access to these events, not their recording. They are still recorded while the Compliance API is off, and the Activity Feed returns them after the Compliance API is turned back on. For Claude Enterprise organizations, the Compliance API setting in claude.ai also governs transcript capture for [local sessions](https://platform.claude.com/docs/en/manage-claude/compliance-sessions#retrieve-local-sessions) (sessions on users’ machines): capture starts when the Compliance API is enabled and stops while it is off, and transcript content from sessions that run while it is off is not captured and cannot be recovered later.
51 **Turning the Compliance API off stops activity recording.** Anyone who can turn the Compliance API on can turn it off at any time with the same **Compliance API** toggle. While the Compliance API is off, no activity events are recorded for your organization, so the [Activity Feed](https://platform.claude.com/docs/en/manage-claude/compliance-activity-feed) receives no new events. Activity that is not recorded while the Compliance API is off cannot be recovered later. Turning the Compliance API back on resumes recording from that point forward; activity that was already recorded is not deleted. Access Transparency events are an exception. If your organization is enrolled in [Access Transparency](https://platform.claude.com/docs/en/manage-claude/access-transparency), turning the Compliance API off stops your access to these events, not their recording. They are still recorded while the Compliance API is off, and the Activity Feed returns them after the Compliance API is turned back on. For Claude Enterprise organizations, the Compliance API setting in claude.ai also governs transcript capture for [local sessions](https://platform.claude.com/docs/en/manage-claude/compliance-sessions#retrieve-local-sessions) (sessions on users’ machines). Capture starts when the Compliance API is enabled and stops while it is off. Transcript content from local sessions that run while the Compliance API is off is not captured and cannot be recovered later.
5252 </Warning>
5353 
5454 A standalone Claude Console organization uses Admin API keys rather than Compliance Access Keys: after enablement, skip the remaining steps and [create a new Admin API key](https://platform.claude.com/docs/en/manage-claude/compliance-api-access#create-an-admin-api-key) instead. The remaining steps provision Compliance Access Keys, which are available only to organizations that are part of a Claude Enterprise tenant.
from line 62
6262 </Step>
6363 
6464 <Step title="Sign in with the matching role">
65 Sign in to claude.ai. The primary owner of the parent organization can create a key with either scope. An organization owner can create a key restricted to their own organization only.
65 Sign in to claude.ai. The organization’s primary owner can create a key with either scope. An organization owner can create a key restricted to their own organization only.
6666 
67 If the **API** page described in the next step is not visible, or compliance scopes are unavailable when creating a key, either your role cannot create Compliance Access Keys, or the Compliance API has not been enabled for your organization yet (return to the first step).
67 If the **API** page in the next step is not visible, or compliance scopes are unavailable when you create a key, two causes are possible. Either your role cannot create Compliance Access Keys, or the Compliance API has not been enabled for your organization (return to the first step).
6868 </Step>
6969 
7070 <Step title="Open API settings">

manage-claude/wif-reference Changed · +40 / -38 lines

from line 10
1010 
1111`POST /v1/oauth/token` accepts a JSON body using the [RFC 7523](https://www.rfc-editor.org/rfc/rfc7523) `jwt-bearer` grant. The SDK builds this request for you from the [environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables).
1212 
13| Field | Required | Description |
14| -------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15| `grant_type` | Yes | Always `urn:ietf:params:oauth:grant-type:jwt-bearer`. |
16| `assertion` | Yes | The OIDC JWT issued by your identity provider. |
17| `federation_rule_id` | Yes | Tagged ID (`fdrl_...`) of the federation rule to evaluate. |
18| `organization_id` | Yes | UUID of your Anthropic organization. |
19| `service_account_id` | Yes | Tagged ID (`svac_...`) of the target service account. |
20| `workspace_id` | Conditional | Tagged ID (`wrkspc_...`) of the workspace to scope the minted token to. Required when the rule is enabled for more than one workspace. When omitted, the server selects the rule’s sole enabled workspace. The literal `default` also works for the organization’s Default Workspace but is deprecated. Use that workspace’s `wrkspc_...` ID. |
13| Field | Required | Description |
14| -------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15| `grant_type` | Yes | Always `urn:ietf:params:oauth:grant-type:jwt-bearer`. |
16| `assertion` | Yes | The OIDC JWT issued by your identity provider. |
17| `federation_rule_id` | Yes | Tagged ID (`fdrl_...`) of the federation rule to evaluate. |
18| `organization_id` | Yes | UUID of your Anthropic organization. |
19| `service_account_id` | No | Tagged ID (`svac_...`) of the rule’s target service account. The rule, not this field, determines which account the token acts as. If you send the field, it must be that account’s ID. |
20| `workspace_id` | Conditional | Tagged ID (`wrkspc_...`) of the workspace to scope the minted token to. Required when the rule is enabled for all workspaces or for more than one. When omitted, the server selects the rule’s sole enabled workspace. The literal `default` also works for the organization’s Default Workspace but is deprecated. Use that workspace’s `wrkspc_...` ID. |
2121 
2222## Token exchange response
2323 
from line 34
3434 
3535The SDK reads these variables to perform a federated token exchange with no constructor arguments.
3636 
37| Variable | Required | Description | Example |
38| ------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
39| `ANTHROPIC_FEDERATION_RULE_ID` | Yes | Tagged ID of the federation rule to evaluate. | `fdrl_...` |
40| `ANTHROPIC_ORGANIZATION_ID` | Yes | UUID of your Anthropic organization. Find it on the [Organization](https://platform.claude.com/settings/organization) page (`platform.claude.com/settings/organization`) in the Claude Console. | `00000000-0000-0000-0000-000000000000` |
41| `ANTHROPIC_IDENTITY_TOKEN_FILE` | One of `_TOKEN_FILE` or `_TOKEN` | Filesystem path to the JWT issued by your identity provider (IdP). The SDK rereads this file on every exchange so that projected tokens that rotate on disk are always current. | `/var/run/secrets/anthropic.com/token` |
42| `ANTHROPIC_IDENTITY_TOKEN` | One of `_TOKEN_FILE` or `_TOKEN` | The literal JWT as a string. Use when your platform injects the token as an environment variable rather than a file. | `eyJhbGciOiJSUzI1NiIs...` |
43| `ANTHROPIC_SERVICE_ACCOUNT_ID` | Yes | Tagged ID of the target Anthropic service account that the issued access token acts as. | `svac_...` |
44| `ANTHROPIC_WORKSPACE_ID` | Conditional | Tagged ID of the workspace to scope the minted token to. Required when the federation rule is enabled for more than one workspace. Optional when the rule is bound to a single workspace. The exchange scopes the minted token to this workspace, so switching workspaces requires a new exchange. Without a profile, the `ant` CLI does not pass this variable into the exchange. With the `ant` CLI, set `workspace_id` in a federation profile and set `ANTHROPIC_PROFILE` to its name. The literal `default` also works for the Default Workspace but is deprecated. Use its `wrkspc_...` ID. | `wrkspc_...` |
45| `ANTHROPIC_PROFILE` | No | Name of a [configuration profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#profile-configuration-file) to load. Takes precedence over the federation environment variables in this table. | `staging-profile` |
37| Variable | Required | Description |
38| ------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
39| `ANTHROPIC_FEDERATION_RULE_ID` | Yes | Tagged ID (`fdrl_...`) of the federation rule to evaluate. |
40| `ANTHROPIC_ORGANIZATION_ID` | Yes | UUID of your Anthropic organization. Find it on the [Organization](https://platform.claude.com/settings/organization) page in the Claude Console. |
41| `ANTHROPIC_IDENTITY_TOKEN_FILE` | One of `_TOKEN_FILE` or `_TOKEN` | Filesystem path to the JWT issued by your identity provider (IdP). The SDK rereads this file on every exchange so that projected tokens that rotate on disk are always current. `/var/run/secrets/anthropic.com/token` is an example. |
42| `ANTHROPIC_IDENTITY_TOKEN` | One of `_TOKEN_FILE` or `_TOKEN` | The literal JWT as a string. Use when your platform injects the token as an environment variable rather than a file. `eyJhbGciOiJSUzI1NiIs...` is an example. |
43| `ANTHROPIC_SERVICE_ACCOUNT_ID` | No | Tagged ID (`svac_...`) of the rule’s target service account. The rule, not this variable, determines which account the token acts as. If you set the variable, it must be that account’s ID. |
44| `ANTHROPIC_WORKSPACE_ID` | Conditional | Tagged ID (`wrkspc_...`) of the workspace to scope the minted token to. Required when the federation rule is enabled for all workspaces or for more than one. Optional when the rule is bound to a single workspace. |
45| `ANTHROPIC_PROFILE` | No | Name of a [configuration profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#profile-configuration-file) to load. Takes precedence over the federation environment variables in this table. `staging-profile` is an example. |
4646 
47The direct environment-variable federation path activates only when `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID`, `ANTHROPIC_SERVICE_ACCOUNT_ID`, and one of `ANTHROPIC_IDENTITY_TOKEN_FILE` or `ANTHROPIC_IDENTITY_TOKEN` are all set. The SDK also reads `ANTHROPIC_WORKSPACE_ID`, but this path activates with or without it.
47The direct environment-variable federation path activates only when `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID`, and one of `ANTHROPIC_IDENTITY_TOKEN_FILE` or `ANTHROPIC_IDENTITY_TOKEN` are all set. The SDK also reads `ANTHROPIC_WORKSPACE_ID`, but this path activates with or without it.
4848 
49The exchange scopes the minted token to the workspace that `ANTHROPIC_WORKSPACE_ID` names, so switching workspaces requires a new exchange. Without a profile, the `ant` CLI does not pass this variable into the exchange. With the `ant` CLI, set `workspace_id` in a federation profile and set `ANTHROPIC_PROFILE` to its name. `ANTHROPIC_WORKSPACE_ID` also accepts the literal `default` for the Default Workspace, but that form is deprecated. Use the workspace’s `wrkspc_...` ID.
50 
4951<Warning>
5052 A variable that is set to an empty string can occupy its slot in the credential precedence chain. Unset unused credential variables rather than blanking them.
5153</Warning>
from line 61
5961| 1 | Constructor argument (API key, auth token, or credentials) | Always overrides everything else. |
6062| 2 | `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` | Overrides federation entirely. Unset these when migrating from API keys. |
6163| 3 | `ANTHROPIC_PROFILE` | Loads `<config_dir>/configs/<name>.json`. If the named profile is missing, the SDK reports an error instead of trying the next source. |
62| 4 | Federation environment variables | `ANTHROPIC_FEDERATION_RULE_ID` + `ANTHROPIC_ORGANIZATION_ID` + `ANTHROPIC_SERVICE_ACCOUNT_ID` + `ANTHROPIC_IDENTITY_TOKEN[_FILE]`. |
64| 4 | Federation environment variables | `ANTHROPIC_FEDERATION_RULE_ID` + `ANTHROPIC_ORGANIZATION_ID` + `ANTHROPIC_IDENTITY_TOKEN[_FILE]`. |
6365| 5 | Active profile | Resolved from `<config_dir>/active_config`, falling back to a profile named `default`. |
6466 
6567In the `ant` CLI, the settings for [Claude Models on Google Cloud (Anthropic managed)](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#authentication) rank after the federation environment variables and before the active profile. The settings are the project, the workspace ID, and the location. You set them with the `--google-cloud-*` flags or the `ANTHROPIC_GOOGLE_CLOUD_*` variables. The CLI uses these settings when any one of them is set. With these settings, the CLI gets its credential from Google Application Default Credentials.
from line 178
176178 
177179| Constraint | Detail |
178180| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
179| Maximum size | The `assertion` JWT must be at most 16 KiB. |
181| Maximum size | The `assertion` JWT must be at most 16 KiB. |
180182| Signing algorithm | Anthropic accepts only asymmetric algorithms (RSA and ECDSA families: ES256, ES384, ES512, RS256, RS384, RS512, PS256, PS384, PS512). It rejects HMAC (`HS256`, `HS384`, `HS512`) and `none`. |
181183| Key ID | The JWT header must carry a `kid` that matches a key in the issuer’s JWKS. Anthropic rejects tokens without `kid`. |
182184| Required claims | `sub` must be present. `iat` must be present and not in the future. `exp` must be present and in the future. |
from line 221
219221 
220222`POST /v1/oauth/token` returns errors in the standard [API error shape](https://platform.claude.com/docs/en/api/errors). The SDK reports an exchange failure as `WorkloadIdentityError` (ruby: `Anthropic::Credentials::WorkloadIdentityError`; go: `error`; java: `UnexpectedStatusCodeException`; csharp: `WorkloadIdentityException`; php: `OAuthException`), which gives the HTTP status and the error details from the response body. Except in C# and PHP, the SDK also gives the request ID: on the error, in the exception’s response headers, or in the error’s message.
221223 
222| Status | Error | Cause | Resolution |
223| ------ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
224| 400 | `invalid_request_error` | `federation_rule_id` is malformed or a required request field is missing. | Check the `fdrl_` ID and that the request body includes all required fields. |
225| 400 | `invalid_request_error` | `workspace_id` is present but is not a well-formed `wrkspc_...` ID or the literal `default`. | Fix the `workspace_id` value. The response message names the expected format. |
226| 401 | `authentication_error` | The JWT `iss` claim does not equal the registered `issuer_url` exactly. | Compare byte-for-byte, including trailing slashes and scheme: `jq -rR 'split(".")[1] \| gsub("-";"+") \| gsub("_";"/") \| @base64d \| fromjson \| .iss' <<< "$JWT"`. |
227| 401 | `authentication_error` | JWKS fetch failed, JWKS is stale, or the JWT was signed with a key not in the JWKS. | For `inline` mode, update the issuer with the rotated keys. For `discovery` and `explicit_url`, confirm the JWKS endpoint is reachable on port 443. If the issuer recently rotated its signing key, see [Key rotation and caching](https://platform.claude.com/docs/en/manage-claude/wif-reference#key-rotation-and-caching). |
228| 401 | `authentication_error` | The JWT `exp` claim is in the past (beyond the 30-second skew window). | Confirm your identity provider is projecting a fresh token and the SDK is rereading the token file. |
229| 401 | `authentication_error` | The JWT was verified but its claims do not satisfy the rule’s `match` block. | Decode the JWT and compare each claim against the rule. `subject_prefix` is case-sensitive. `audience` requires an exact element match. |
230| 401 | `authentication_error` | The `federation_rule_id` does not exist or is archived, or the JWT is not authorized for it (one error covers these cases to prevent enumeration). | Confirm the rule ID in the Claude Console and that the rule has not been archived. |
231| 401 | `authentication_error` | The federation rule is enabled for more than one workspace and the request omits `workspace_id`. The authentication history entry shows reason `workspace_id_required`. | Set `ANTHROPIC_WORKSPACE_ID` (or the `workspace_id` body field on a raw request) to the `wrkspc_...` ID you want the token scoped to. With the `ant` CLI, set `workspace_id` in a federation profile and set `ANTHROPIC_PROFILE` to its name. See [Token exchange request](https://platform.claude.com/docs/en/manage-claude/wif-reference#token-exchange-request). |
224| Status | Error | Cause | Resolution |
225| ------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
226| 400 | `invalid_request_error` | `federation_rule_id` is malformed or a required request field is missing. | Check the `fdrl_` ID and that the request body includes all required fields. |
227| 400 | `invalid_request_error` | `workspace_id` is present but is not a well-formed `wrkspc_...` ID or the literal `default`. | Fix the `workspace_id` value. The response message names the expected format. |
228| 401 | `authentication_error` | The JWT `iss` claim does not equal the registered `issuer_url` exactly. | Compare byte-for-byte, including trailing slashes and scheme: `jq -rR 'split(".")[1] \| gsub("-";"+") \| gsub("_";"/") \| @base64d \| fromjson \| .iss' <<< "$JWT"`. |
229| 401 | `authentication_error` | JWKS fetch failed, JWKS is stale, or the JWT was signed with a key not in the JWKS. | For `inline` mode, update the issuer with the rotated keys. For `discovery` and `explicit_url`, confirm the JWKS endpoint is reachable on port 443. If the issuer recently rotated its signing key, see [Key rotation and caching](https://platform.claude.com/docs/en/manage-claude/wif-reference#key-rotation-and-caching). |
230| 401 | `authentication_error` | The JWT `exp` claim is in the past (beyond the 30-second skew window). | Confirm your identity provider is projecting a fresh token and the SDK is rereading the token file. |
231| 401 | `authentication_error` | The JWT was verified but its claims do not satisfy the rule’s `match` block. | Decode the JWT and compare each claim against the rule. `subject_prefix` is case-sensitive. `audience` requires an exact element match. |
232| 401 | `authentication_error` | The `federation_rule_id` does not exist or is archived, or the JWT is not authorized for it (one error covers these cases to prevent enumeration). | Confirm the rule ID in the Claude Console and that the rule has not been archived. |
233| 401 | `authentication_error` | The federation rule is enabled for all workspaces or for more than one, and the request omits `workspace_id`. The authentication history entry shows the reason `workspace_id_required`. | Set `ANTHROPIC_WORKSPACE_ID` (or the `workspace_id` body field on a raw request) to the `wrkspc_...` ID you want the token scoped to. With the `ant` CLI, set `workspace_id` in a federation profile and set `ANTHROPIC_PROFILE` to its name. See [Token exchange request](https://platform.claude.com/docs/en/manage-claude/wif-reference#token-exchange-request). |
232234 
233235Every assertion denial returns the same opaque `401` `authentication_error` with the fixed message `Authentication failed`, regardless of which check failed. A distinguishable error would let a caller probe rule configuration. The [authentication history](https://platform.claude.com/settings/workload-identity-federation?tab=history) in the Claude Console records the deny reason on the attempt’s entry. For example, it shows `match_subject_prefix` when the `sub` claim fails the rule’s `subject_prefix`, or `workspace_id_required` when the rule spans multiple workspaces and the request names none. Requests rejected before the rule’s organization is confirmed (the `400 invalid_request_error` family in the previous table) leave no history entry. Their response messages name the problem directly. A `401` with no matching history entry usually means that Anthropic did not recognize the `federation_rule_id`.
234236 
235237### Common SDK-side failures
236238 
237| Symptom | Cause | Resolution |
238| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
239| SDK reports missing credentials instead of exchanging | One of `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID`, `ANTHROPIC_SERVICE_ACCOUNT_ID`, or `ANTHROPIC_IDENTITY_TOKEN[_FILE]` is unset and no profile is active. | Set all four variables, or configure a profile. |
240| SDK authenticates with an API key instead of federating | `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` is set and wins precedence. | Unset the key or token variable. |
241| File-not-found error on first request | The path in `ANTHROPIC_IDENTITY_TOKEN_FILE` does not exist. The SDK opens the file lazily at exchange time. | Confirm the projected-token volume is mounted and the path matches. |
242| Token exchange succeeds but a Claude API request returns 403 | The minted token’s scope does not grant access to that endpoint. | Check the rule’s `oauth_scope` against [OAuth scopes](https://platform.claude.com/docs/en/manage-claude/wif-reference#oauth-scopes). |
243| Authentication fails with empty credential | A credential environment variable is exported but set to an empty string. Empty values can win their precedence slot. | Unset the variable with `unset VAR` rather than `VAR=""`. |
239| Symptom | Cause | Resolution |
240| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
241| SDK reports missing credentials instead of exchanging | One of `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID`, or `ANTHROPIC_IDENTITY_TOKEN[_FILE]` is unset and no profile is active. | Set all three variables, or configure a profile. |
242| SDK authenticates with an API key instead of federating | `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` is set and wins precedence. | Unset the key or token variable. |
243| File-not-found error on first request | The path in `ANTHROPIC_IDENTITY_TOKEN_FILE` does not exist. The SDK opens the file lazily at exchange time. | Confirm the projected-token volume is mounted and the path matches. |
244| Token exchange succeeds but a Claude API request returns 403 | The minted token’s scope does not grant access to that endpoint. | Check the rule’s `oauth_scope` against [OAuth scopes](https://platform.claude.com/docs/en/manage-claude/wif-reference#oauth-scopes). |
245| Authentication fails with empty credential | A credential environment variable is exported but set to an empty string. Empty values can win their precedence slot. | Unset the variable with `unset VAR` rather than `VAR=""`. |
244246 
245247## Troubleshoot a failed exchange
246248 

managed-agents/scheduled-deployments Changed · +8 / -2 lines

from line 50
5050* In the `schedule` (csharp, go: `Schedule`), you define a cron `expression` (csharp, go: `Expression`) and a `timezone` (csharp, go: `Timezone`). Maximum granularity supported is at the minute level.
5151 
5252<Note>
53 On [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws), each run creates its session as an IAM role in your AWS account. Before you create the deployment, set `execution_identity` on the agent to `{"type": "aws_role", "role_arn": "arn:aws:iam::123456789012:role/example-role"}`. Creating a deployment for an agent without this field returns a 400 error.
53 On [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws), each run creates its session as an IAM role in your AWS account. When you create the agent, set `execution_identity` to `{"type": "aws_role", "role_arn": "arn:aws:iam::123456789012:role/example-role"}`. You can set the role only when you create the agent, and not in the Claude Console. If an agent has no role, create another agent with one. Creating a deployment for an agent without this field returns a 400 error.
5454 
5555 * **Trust policy:** Allow the `aws-external-anthropic.amazonaws.com` service principal to call `sts:AssumeRole` and `sts:SetSourceIdentity`.
5656 * **Role permissions:** Allow `aws-external-anthropic:CreateSession`, `sts:GetWebIdentityToken`, and `sts:TagGetWebIdentityToken`.
from line 759
759759 
760760Session creation rate-limit responses are recorded immediately as a `session_rate_limited_error` run without retry; the schedule attempts again at the next scheduled occurrence. Rate limits on underlying API calls within a session are handled by the session itself.
761761 
762If a deployment’s agent has been archived, the deployment is automatically archived in the same operation. If the agent has been deleted, the next scheduled trigger detects the missing agent and automatically archives the deployment. In both cases no deployment run is recorded. If a subagent referenced by the agent has been archived, the next trigger records a failed run with `error.type: "agent_archived_error"` and the deployment is automatically paused so you can update the agent and resume. Other unrecoverable session-creation errors, such as an archived environment or vault, behave the same way: the trigger records a failed run and the deployment is automatically paused. The deployment’s `paused_reason.error.type` mirrors the failed run’s `error.type`.
762If a deployment’s agent is archived, the same operation archives the deployment. If the agent is deleted, the next scheduled trigger detects the missing agent and archives the deployment. Neither records a deployment run. If the agent references an archived subagent, the next trigger records a failed run with `error.type: "agent_archived_error"` and pauses the deployment. Other unrecoverable session-creation errors, such as an archived environment or vault, behave the same way: the trigger records a failed run and pauses the deployment. The deployment’s `paused_reason.error.type` mirrors the failed run’s `error.type`.
763 
764If a deployment is paused because the agent has an archived subagent:
765 
7661. Remove or replace the archived subagent when you [update the agent](https://platform.claude.com/docs/en/api/beta/agents/update).
7672. Move the deployment to the agent’s latest version: [update the deployment](https://platform.claude.com/docs/en/api/beta/deployments/update) and pass the same agent ID again in `agent` (csharp, go: `Agent`). A deployment runs one version of its agent and keeps it even when the agent changes.
7683. Unpause the deployment, as [Managing deployment lifecycle](https://platform.claude.com/docs/en/managed-agents/scheduled-deployments#managing-deployment-lifecycle) describes.
763769 
764770## Trigger a manual run
765771 

manage-claude/ip-allowlist Changed · +2 / -2 lines

from line 69
6969 <Step title="Turn on the toggle">
7070 Go to your organization’s settings page:
7171 
72 * **Claude Platform:** The [Identity and access](https://platform.claude.com/settings/identity) page in the Claude Console
72 * **Claude Platform:** The [Security](https://platform.claude.com/settings/identity) page in the Claude Console
7373 * **Claude Enterprise:** [claude.ai > Organization settings > Organization and access](https://claude.ai/admin-settings/organization#ip-allowlist)
7474 
7575 Turn on the **IP allowlist** toggle. Nothing changes until you save.
from line 102
102102 
1031031. **Reconnect from a listed network:** Connect to your office network or VPN, and then click **Try again**. If there is no **Try again** button, reload the page.
1041042. **Ask another admin or owner:** An admin or owner on a listed network can add your address.
1053. **Fix the list from where you are:** If you are an admin or owner and the checkbox under [Keep a way back in](https://platform.claude.com/docs/en/manage-claude/ip-allowlist#avoid-locking-yourself-out) is selected, open the Claude Console or Claude in a browser and click **Open IP allowlist**, or go to the [Identity and access](https://platform.claude.com/settings/identity) page ([Organization and access](https://claude.ai/admin-settings/organization#ip-allowlist) in claude.ai). Click **Add it** to add your current address, or turn off the allowlist, and then click **Save** and confirm. Access can take up to 15 minutes to return.
1053. **Fix the list from where you are:** If you are an admin or owner and the checkbox under [Keep a way back in](https://platform.claude.com/docs/en/manage-claude/ip-allowlist#avoid-locking-yourself-out) is selected, you can still reach the settings page. Open the Claude Console or Claude in a browser and click **Open IP allowlist**, or go to the [Security](https://platform.claude.com/settings/identity) page ([Organization and access](https://claude.ai/admin-settings/organization#ip-allowlist) in claude.ai). Click **Add it** to add your current address, or turn off the allowlist, and then click **Save** and confirm. Access can take up to 15 minutes to return.
1061064. **Contact Anthropic:** If no admin or owner can reach the page, ask [Anthropic support](https://support.claude.com) to turn off the allowlist.
107107 

managed-agents/permission-policies Changed · +2 / -2 lines

from line 659
659659 
660660## Let the server evaluate each call with `auto`
661661 
662With the `auto` permission policy, the server evaluates each call before it runs. Because the evaluation considers the tool, the call’s input, and the session’s content up to that point, the server can treat two calls to the same tool differently. Each call has one of three outcomes:
662With the `auto` permission policy, the server evaluates each call before it runs. The evaluation considers context such as the tool, the call’s input, the agent’s earlier calls, and your intent, meaning what you have asked for. As a result, the server can treat two calls to the same tool differently. Each call has one of three outcomes:
663663 
664664* **The call runs.** When the server determines that the call is safe, the tool runs as it would under `always_allow`.
665665* **The call is denied.** When the server evaluates the call as high-risk, the tool does not run. The agent receives an error tool result with the content `Permission to use {tool_name} has been denied.` and `is_error: true`. The session keeps running, and your client cannot override the denial.
from line 985
985985 ```
986986</CodeGroup>
987987 
988What you post in `user.message` events counts as your intent, and it can lead the server to allow a call it would otherwise deny. The server does not read intent from a tool result, a fetched webpage, an MCP server’s response, or a message between [session threads](https://platform.claude.com/docs/en/managed-agents/session-threads#tool-permissions-and-custom-tools). It assesses that content but does not take instructions from it. The server evaluates some calls as high-risk no matter who asks. If you relay untrusted end-user input in `user.message` events, the server reads that input as your intent too, and it can get a call allowed. Configure `always_ask` on the tools you would not let that end user run without review.
988What you post in `user.message` events counts as your intent, and it can lead the server to allow a call it would otherwise deny. The server does not read intent from a tool result, a fetched webpage, an MCP server’s response, or a message between [session threads](https://platform.claude.com/docs/en/managed-agents/session-threads#tool-permissions-and-custom-tools). The server evaluates some calls as high-risk no matter who asks. If you relay untrusted end-user input in `user.message` events, the server reads that input as your intent too, and it can get a call allowed. Configure `always_ask` on the tools you would not let that end user run without review.
989989 
990990<Warning>
991991 `auto` is not a human checkpoint. If the server determines that a call is safe, the call runs before anyone sees it, and its effects might not be reversible. If a person must review a tool’s calls before they run, configure `always_ask` on that tool.
Feedback