Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One capture · api

One read of Claude Developer Platformapi-20261203T193723Z

18 pages moved out of 997 read.

Pages moved 18 significant first
Pages read 997 in this capture
Captured 19:37 UTC
Corpus hash 451b6c909acb corpus-hash

What this read moved

1-18 of 18

build-with-claude/message-threads Changed · +13 / -1 lines

### How long a thread lasts

from line 46
4646 
4747* **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`.
4848* **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.
49* **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).
49* **Replay.** If the API can no longer continue the thread, a continue request returns a 404 error with the code `thread_not_found`. Send the full conversation, including your new messages, in a new create request with `system` and `tools`. Then, continue from the new response `id`. For the causes and the full steps, see [Recover when a thread can’t be continued](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover). 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)).
5050 
5151Your 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.
52 
53### How long a thread lasts
54 
55A thread is best-effort and short-lived. Each time the API stores a response, it sets how long to keep the thread. You can’t set that time yourself.
56 
57* **Plan for 5 minutes.** Expect a thread to expire 5 minutes after the last response that the API stored.
58* **Don’t rely on more.** The API might set a longer time. That time is at most 1 hour, and it might differ from one response to the next.
59* **Be ready for less.** A thread might end within the 5 minutes.
60 
61You don’t need a timer. Send the continue request. If it returns `thread_not_found`, replay the conversation (see [Recover when a thread can’t be continued](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover)).
62 
63Whatever time the API sets, it deletes every thread no more than 1 hour after its last use. See [Data retention](https://platform.claude.com/docs/en/build-with-claude/message-threads#data-retention).
5264 
5365## Use a thread with the SDK
5466 

cli-sdks-libraries/sdks/terraform New page · 144 lines, new page

## Requirements ## Add the provider block ## Add an environment and an agent ## Sign in and apply ## Check for no changes ## Clean up ## Additional resources

A whole new page. There's nothing to diff it against, so here is what it says.

---
title: Terraform provider
url: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform
description: Install the Anthropic Terraform provider, sign in, and apply a first configuration.
---

The Anthropic Terraform provider manages Claude Platform resources as code. Changes to them go through the same review, plan, and apply workflow as your other infrastructure.

<Note>
  The Terraform provider is in beta. Resource types and their arguments can change during the beta. [Commit your lock file](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#pin-the-providers-release) to choose when you adopt the changes.
</Note>

## Requirements

* [Terraform 1.11 or later](https://developer.hashicorp.com/terraform/install)
* The [`ant` CLI](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart#installation)
* For Managed Agents resources, an organization with access to [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview)

## Add the provider block

`terraform init` installs the provider from the [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs).

In an empty directory, create `main.tf` with a `terraform` block and a provider block:

```hcl
terraform {
  required_providers {
    anthropic = {
      source = "anthropics/anthropic"
    }
  }
}

variable "organization_id" {
  type = string
}

# Pins this configuration to one organization. Every plan verifies
# that the credentials belong to it, and refuses to proceed otherwise.
provider "anthropic" {
  organization_id = var.organization_id
}
```

`anthropics/anthropic` is the only official source address for this provider. A provider runs with access to your Anthropic credentials, and one installed from any other address could read them.

## Add an environment and an agent

Add these blocks to `main.tf`.

This example is based on the [`managed-agents/quickstart`](https://github.com/anthropics/terraform-provider-anthropic/tree/main/examples/managed-agents/quickstart) example in the provider’s repository. It creates an environment with [limited networking](https://platform.claude.com/docs/en/managed-agents/environments#networking), an agent with web search and web fetch turned off, and outputs for the IDs that a session needs:

```hcl
# Where the agent's tools run: an isolated cloud container. Limited
# networking with package managers allowed lets it reach package
# registries and code hosts only.
resource "anthropic_beta_environment" "sandbox" {
  name        = "quickstart"
  description = "Cloud sandbox for the quickstart agent."

  config = {
    cloud = {
      networking = {
        limited = {
          allow_package_managers = true
        }
      }
    }
  }
}

# An agent bundles a model, a system prompt, and tools. Every change
# publishes a new server-side version, and `version` is exported for
# pinning.
resource "anthropic_beta_agent" "assistant" {
  name        = "quickstart-assistant"
  description = "General-purpose assistant with the built-in toolset."

  model = {
    id = "claude-opus-5-5"
  }

  system = "You are a concise, careful assistant."

  # The environment's limited networking applies to web search and web
  # fetch too. With no `allowed_hosts`, they would return no pages or
  # search results, so they're turned off.
  tools = [
    {
      agent_toolset_20260401 = {
        configs = [
          { web_search = { enabled = false } },
          { web_fetch = { enabled = false } },
        ]
      }
    },
  ]
}

output "agent_id" {
  value = anthropic_beta_agent.assistant.id
}

output "environment_id" {
  value = anthropic_beta_environment.sandbox.id
}
```

## Sign in and apply

At a terminal, sign in with `ant auth login`. This command saves your login in a profile, which is a named configuration file. The provider uses that profile. If your shell exports `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`, remove that variable from your shell with `unset`. Either variable overrides a login, as the [lookup order](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credential-lookup-order) shows.

Find your organization ID on the [Organization settings](https://platform.claude.com/settings/organization) page in the Claude Console, or in the output of `ant auth status`.

```bash
ant auth login
export TF_VAR_organization_id="00000000-0000-0000-0000-000000000000"

terraform init
terraform plan
terraform apply
```

## Check for no changes

After the apply, run `terraform plan` once more. It should report `No changes`. If it proposes changes that you didn’t make, [report it as a bug](https://github.com/anthropics/terraform-provider-anthropic/issues).

## Clean up

[Deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection) is on by default, so `terraform destroy` stops with an error until you turn it off. To remove what you created:

1. Add `deletion_protection = false` to both resource blocks, and run `terraform apply`.
2. Run `terraform destroy`. This deletes the environment and [archives the agent](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources).

## Additional resources

* [Authenticate the Terraform provider](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication): pipelines, terminals, and several identities
* [Example: a team’s workspace and CI identity](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#example-a-teams-workspace-and-ci-identity): organization resources, and the sign-in that they need
* [Organization resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#organization-resources): each resource, and what destroy does to it
* [Managed Agents resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources): each resource, and the Managed Agents pages that show it in Terraform
* [Operate the Terraform provider](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations): tasks after the first apply, such as imports, safe state, and logs
* [How the Terraform provider behaves](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior): credentials, what destroy does, and what state holds
* [GitHub repository](https://github.com/anthropics/terraform-provider-anthropic)
* [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs)

cli-sdks-libraries/sdks/terraform/authentication New page · 257 lines, new page

## Run Terraform from a pipeline ## Run Terraform at a terminal ## Pin the provider to one credential ## Organization credentials ### Example: a team’s workspace and CI identity ### Manage organization and workspace resources together ## Use a workspace that Terraform creates ## Multiple identities ## Pin a federation rule to its workload ## Cloud platforms ### Claude Platform on AWS ### Claude Models on Google Cloud (Anthropic managed) ### Claude Managed Agents on Amazon Bedrock

A whole new page. There's nothing to diff it against, so here is what it says.

---
title: Authenticate the Terraform provider
url: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication
description: Give the Terraform provider a credential in a pipeline or at a terminal, and use more than one identity.
---

Before you set up a credential, check [Credentials for each resource](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credentials-for-each-resource) for the scope that your resources need. Use [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) for pipelines and other automation. Use an `ant auth login` profile when you run Terraform yourself at a terminal. Provider blocks and credentials on this page are for the Claude API except for those in the [Cloud platforms](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#cloud-platforms) section.

## Run Terraform from a pipeline

1. [Set up federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#set-up-federation) to create a service account, an issuer, and a rule. To create all three with Terraform instead, first sign in with `ant auth login --profile admin --scope org:admin`. Then apply [Example: a team’s workspace and CI identity](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#example-a-teams-workspace-and-ci-identity) once at a terminal.
2. In the job, save the workload’s identity token to a file. The guide for your [identity provider](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation#identity-providers) shows where the token comes from.
3. Write a [federation profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#federation-profile-example) that names your rule, service account, organization, and token file. If the rule covers all workspaces or more than one, the profile file’s `workspace_id` setting names the workspace to use. Save it as `configs/<name>.json` in the [configuration directory](https://platform.claude.com/docs/en/manage-claude/wif-reference#configuration-directory).
4. Set `ANTHROPIC_PROFILE` to `<name>`.

If your job or shell exports `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`, remove that variable from the job or shell. Unless the provider block sets `profile`, a variable that’s set wins over a profile, and the provider prints no warning.

Use a profile rather than the [federation environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables), or `terraform apply` fails on GitHub Actions. `terraform apply` connects twice, once to plan and once to apply. By default, the API accepts a GitHub Actions identity token only one time (see [JWT verification](https://platform.claude.com/docs/en/manage-claude/wif-reference#jwt-verification)), so the second connection needs the access token that a profile saves.

## Run Terraform at a terminal

At a terminal, run [`ant auth login`](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#interactive-login). Each login makes its profile the active one, so the provider finds it with no variable to set. A variable earlier in the [lookup order](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credential-lookup-order), such as `ANTHROPIC_API_KEY`, wins over a login, so unset it.

If you can use neither federation nor a login, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication) for other ways to authenticate.

## Pin the provider to one credential

For the order in which the provider looks for a credential, see [Credential lookup order](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credential-lookup-order).

To make a configuration always use one profile, set `profile` in the provider block. The block then ignores every other credential in the environment.

Don’t write a key or token in the provider block, because anything you write there also ends up in plan files.

## Organization credentials

On the Claude API, a [Workload Identity Federation profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#profile-configuration-file) can manage the [organization resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#organization-resources), within the limits in [Permissions and constraints](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#permissions-and-constraints). The profile’s federation rule must grant the `org:admin` scope, and must target a service account whose `organization_role` is `admin`. `developer`, the default, isn’t enough. Create the `org:admin` rule in the Claude Console, as [Bootstrap a workload to manage WIF](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#bootstrap-a-workload-to-manage-wif) describes.

At a terminal, an organization admin can sign in with `ant auth login --profile admin --scope org:admin` (see [Admin access](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#admin-access)). That makes `admin` the active profile. To switch back, run `ant profile activate default`.

Don’t keep a long-lived organization admin credential on a shared runner. Provisioners, external data sources, and other providers in the same configuration can read credentials from the environment.

### Example: a team’s workspace and CI identity

This example is based on [`organization/federated-ci`](https://github.com/anthropics/terraform-provider-anthropic/tree/main/examples/organization/federated-ci) in the provider’s repository. It sets up a team: a workspace, a service account with the developer role there, a federation issuer, and a federation rule. The issuer and rule let the team’s GitHub Actions workflows act as the service account, with no stored credential.

Declare and set the variables `github_repository_id` and `github_repository_owner_id` as strings that hold the numeric IDs of the team’s GitHub repository and its owner. To find both IDs, run `gh api repos/example-org/research-agents --jq '.id, .owner.id'`, replacing `example-org/research-agents` with your repository’s full name. The command prints the repository’s ID, then its owner’s.

The example’s resource blocks use the default provider block, so sign in with `ant auth login --profile admin --scope org:admin` before you apply. You need the aliased block from [Manage organization and workspace resources together](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#manage-organization-and-workspace-resources-together) only if your configuration also manages [Managed Agents resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources) in a workspace that already exists. For a workspace that Terraform creates, see [Use a workspace that Terraform creates](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#use-a-workspace-that-terraform-creates).

If your organization already has an issuer for GitHub Actions, don’t create one. Bring it under Terraform as [Import existing resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#import-existing-resources) describes, and set `name` to the name that it has. If that issuer backs a rule with the `org:admin` scope, make any later change to the issuer in the Claude Console.

Add these resource blocks to the configuration from [Add the provider block](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform#add-the-provider-block):

```hcl
resource "anthropic_workspace" "research" {
  name = "research"
}

resource "anthropic_service_account" "ci" {
  name        = "research-ci"
  description = "Deploys the research team's agents from CI."

  # A rename replaces the account, and the API won't archive the old one while
  # the federation rule later in this example still targets it.
  lifecycle {
    create_before_destroy = true
  }
}

resource "anthropic_workspace_service_account" "ci" {
  workspace_id       = anthropic_workspace.research.id
  service_account_id = anthropic_service_account.ci.id
  workspace_role     = "workspace_developer"
}

# GitHub's OIDC issuer. Its signing keys come from OIDC discovery.
resource "anthropic_federation_issuer" "github" {
  name       = "github-actions"
  issuer_url = "https://token.actions.githubusercontent.com"
}

# This rule applies when a push to the repository's main branch starts a
# workflow run. The run exchanges its OIDC token for a short-lived access
# token that acts as the service account in the workspace. The rule matches
# claims, not the token's subject, because GitHub Actions writes the subject
# in more than one format.
resource "anthropic_federation_rule" "deploy" {
  name      = "research-deploy"
  issuer_id = anthropic_federation_issuer.github.id
  match = {
    claims = {
      repository_id       = var.github_repository_id
      repository_owner_id = var.github_repository_owner_id
      ref                 = "refs/heads/main"
      event_name          = "push"
    }
  }
  oauth_scope = "workspace:developer"
  target = {
    service_account = { service_account_id = anthropic_service_account.ci.id }
  }
  workspace_id = anthropic_workspace.research.id
}

# The workflow authenticates with this rule.
output "federation_rule_id" {
  value = anthropic_federation_rule.deploy.id
}
```

A service account is only an identity. What it can do comes from its workspace memberships and from the federation rules that target it. A token gets only what both the rule’s `oauth_scope` and the service account’s `organization_role` allow. `organization_role` is an optional argument that sets the account’s role in the organization. The example doesn’t set it, so the account gets the default, `developer`. For details, see [Permission boundaries](https://platform.claude.com/docs/en/manage-claude/wif-reference#permission-boundaries).

To run Terraform from the team’s workflow, follow the steps in [Run Terraform from a pipeline](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#run-terraform-from-a-pipeline). The rule’s scope is `workspace:developer`, so that workflow can manage resources inside the workspace, but not organization resources such as those in this example.

### Manage organization and workspace resources together

Give each provider block only the access it needs. [Credentials for each resource](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credentials-for-each-resource) shows which credential each resource accepts. To manage organization resources and [Managed Agents resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources) in one configuration, use two provider blocks:

* The default provider block from [Add the provider block](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform#add-the-provider-block) has no alias. Every resource without a `provider` line uses this block. At a terminal, this block uses the active profile, so make that a workspace login. Run `ant profile activate default`. If you have no profile named `default`, run `ant auth login --profile default` instead.
* A second block has an alias, and its `profile` argument names the organization-level profile. This block can’t set `workspace_id`. Each organization resource or data source names this block in its `provider` line.

This example shows the second block, and a resource that uses it:

```hcl
# The profile from `ant auth login --profile admin --scope org:admin`.
provider "anthropic" {
  alias           = "admin"
  organization_id = var.organization_id
  profile         = "admin"
}

resource "anthropic_workspace" "research" {
  provider = anthropic.admin
  name     = "research"
}
```

The default block’s Managed Agents resources go in the workspace its credential acts in, which must exist before you plan. For a workspace that Terraform creates, see [Use a workspace that Terraform creates](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#use-a-workspace-that-terraform-creates).

## Use a workspace that Terraform creates

To manage [Managed Agents resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources) in a workspace that Terraform creates, use two configurations. One `terraform apply` can’t both create the workspace and manage those resources, because the provider authenticates before it plans, and the credential determines the workspace. The first configuration creates the workspace and a federation rule for it, as [Example: a team’s workspace and CI identity](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#example-a-teams-workspace-and-ci-identity) does. The second runs with a credential for that workspace.

Set `workspace_id` in the second configuration’s provider block, so that the provider stops if the credential acts in another workspace.

## Multiple identities

To work as more than one identity in a single configuration, give each extra identity its own aliased provider block. A resource then selects a block with `provider`, and a module with `providers`:

```hcl
# Identity 1: whatever the environment provides, such as a federation
# profile in ANTHROPIC_PROFILE or the active `ant auth login` profile.
provider "anthropic" {
  organization_id = var.organization_id
}

# Identity 2: the `ant auth login --profile research` profile and
# nothing else, in a different organization.
provider "anthropic" {
  alias           = "research"
  organization_id = var.research_organization_id
  profile         = "research"
}

module "research" {
  source    = "./modules/research"
  providers = { anthropic = anthropic.research }
}
```

The [`managed-agents/multiple-identities`](https://github.com/anthropics/terraform-provider-anthropic/tree/main/examples/managed-agents/multiple-identities) example in the provider’s repository shows the full pattern, including a module used twice.

After `ant auth login --profile research`, the first block also uses the research profile, unless an environment variable comes earlier in the [lookup order](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credential-lookup-order). That profile belongs to a different organization, so the provider stops with an error before any plan or apply. To switch back, run `ant profile activate default`.

## Pin a federation rule to its workload

* Match on `claims` that identify the workload, such as the repository, its owner, the branch or environment, and the event that started the run. Prefer claims that hold IDs over names, because someone can reuse a name after a rename or a deletion.
* Some issuers serve many customers, such as the issuer of a hosted CI service. There, every rule must name your own organization, project, or repository on that platform. Otherwise, the rule would accept tokens from every customer of that issuer.
* The API rejects that kind of rule on certain shared issuers, such as GitHub Actions and GitLab.com. Don’t rely on that check for other issuers. On GitHub Actions, use the `repository_id` claim to identify your repository.
* Use a `subject_prefix` if your issuer always writes the subject in the same format. The prefix should name your organization or project, and the branch or environment. Without a trailing `*`, a `subject_prefix` must equal the whole subject.
* Set `audience` only if your workloads mint tokens with a custom audience.
* Prefer `workspace_id` over `applies_to_all_workspaces`, unless the rule must apply to every workspace in the organization.
* Let an issuer find its signing keys through OIDC discovery. Avoid setting inline keys in the issuer’s `jwks` attribute. Inline keys rotate only when you change the configuration.

For how each match field works, see [Rule matching semantics](https://platform.claude.com/docs/en/manage-claude/wif-reference#rule-matching-semantics).

Through the API, a rule’s `oauth_scope` can only be `workspace:developer` or `workspace:inference`. Manage rules with any other scope, such as `org:admin`, in the Claude Console. See [Permissions and constraints](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#permissions-and-constraints).

Set a rule’s `issuer_id` and `target.service_account.service_account_id` by reference, as in `issuer_id = anthropic_federation_issuer.github.id`, not as literal strings. That way, Terraform destroys the rule before the issuer or the service account. The API can’t archive an issuer or a service account while a rule that isn’t archived refers to it.

## Cloud platforms

To manage resources on a cloud platform, set `platform` in the provider block. The [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs) lists every argument. For each platform’s resources, see [Resources on each cloud platform](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#resources-on-each-cloud-platform).

### Claude Platform on AWS

Create your first workspace in the AWS Console. To find its ID, see [Obtain your workspace ID](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#obtain-your-workspace-id). Set `aws_region` to the [workspace’s AWS region](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#workspace-scoping).

All of these arguments are required:

```hcl
provider "anthropic" {
  platform       = "aws"
  aws_region     = "us-west-2"
  aws_account_id = "123456789012"
  workspace_id   = "wrkspc_01AbCdEf23GhIj"
}
```

The provider signs requests with AWS credentials from the [default AWS credential provider chain](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#sig-v4-authentication), or from the profile in `aws_profile`. It stops unless they belong to the account in `aws_account_id`. The credentials also need the permissions in [IAM policies](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#iam-policies).

`anthropic_workspace` creates a workspace in the block’s `aws_region`. To use that workspace, apply the resource in one configuration. Then put the workspace’s ID in the provider block of a second configuration.

### Claude Models on Google Cloud (Anthropic managed)

Use the Default Workspace, or [create another workspace](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#workspaces) in the Claude Console. To find a workspace’s ID, see [Find your workspace ID](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#find-your-workspace-id).

All of these arguments are required:

```hcl
provider "anthropic" {
  platform             = "google_cloud"
  google_cloud_project = "my-project-id"
  workspace_id         = "wrkspc_01AbCdEf23GhIj"
}
```

The provider authenticates with [Application Default Credentials](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#authentication). The account behind them needs an [IAM role](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#iam-roles) on the project. `anthropic_external_key` needs `roles/claude.admin`.

### Claude Managed Agents on Amazon Bedrock

To set up your AWS account, see [Claude Managed Agents for Amazon Bedrock](https://platform.claude.com/docs/en/managed-agents/amazon-bedrock#set-up-your-aws-account). Set `aws_region` to one of the [AWS regions where Claude Managed Agents is available](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock#claude-managed-agents-regions).

All of these arguments are required except `workspace_id`:

```hcl
provider "anthropic" {
  platform       = "bedrock"
  aws_region     = "us-east-1"
  aws_account_id = "123456789012"
  workspace_id   = "proj_01AbCdEf23GhIj"
}
```

`workspace_id` names the Amazon Bedrock project: `default`, or an ID that starts with `proj_`. It defaults to `default`, and the provider doesn’t check that the project exists. The provider doesn’t create IAM roles or Amazon Bedrock projects.

The provider signs requests with AWS credentials from the default AWS credential provider chain, or from the profile in `aws_profile`. It stops unless they belong to the account in `aws_account_id`. Unset `AWS_BEARER_TOKEN_BEDROCK`: Claude Managed Agents doesn’t accept an Amazon Bedrock API key, so the provider stops if it’s set.

If your AWS account doesn’t have Claude Managed Agents in `aws_region`, a run that reads or deletes a resource stops with `Cannot tell whether the resource exists`. The same happens if the project doesn’t exist. Either way, the resource stays in state. Check `aws_region` and `workspace_id`, and run the command again. Run `terraform state rm` only if the resource is gone.

These arguments aren’t available on this platform:

* `organization_id`
* `profile`
* `api_key`
* `auth_token`
* `base_url`

cli-sdks-libraries/sdks/terraform/behavior New page · 308 lines, new page

## Credential lookup order ## Organization pin ## Workspace pin ## Resources and what `terraform destroy` does ### Organization resources ### Managed Agents resources ## Credentials for each resource ## Resources on each cloud platform ### Claude Platform on AWS ### Claude Models on Google Cloud (Anthropic managed) ### Claude Managed Agents on Amazon Bedrock ## Deletion protection ### Forced replacements ### Service account name clash ## Agent versions ## Multiagent settings ### Entries that name an agent ## Skill files ### Skill versions ## Deployments ### Deployment versions ### Paused deployments ## Changes made outside Terraform ### Federation rules ### Skill versions published elsewhere ### Memory documents that agents edit ### Deleted or archived objects ## State and plan output ### Write-only arguments ### Vault credentials ## Error messages ## Semantic versioning

A whole new page. There's nothing to diff it against, so here is what it says.

---
title: How the Terraform provider behaves
url: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior
description: "Facts to look up about the Anthropic Terraform provider: where it finds credentials, what destroy does, and what state holds."
---

## Credential lookup order

The provider uses the first credential it finds, in this order:

1. `profile`, `api_key`, or `auth_token` in the provider block.
2. The `ANTHROPIC_API_KEY` environment variable.
3. The `ANTHROPIC_AUTH_TOKEN` environment variable.
4. The profile named by `ANTHROPIC_PROFILE`.
5. The [federation environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables).
6. The active profile.

## Organization pin

On the Claude API, every provider block requires `organization_id`. The cloud platforms use other arguments, as [Cloud platforms](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#cloud-platforms) describes. Find the ID on the [Organization settings](https://platform.claude.com/settings/organization) page in the Claude Console, or in the output of `ant auth status`.

Before it plans or applies anything, the provider confirms that its credentials belong to that organization, and stops if they don’t:

```text wrap
the configured credentials belong to organization 11111111-..., but the
provider is pinned to organization_id = 00000000-...; refusing to plan or
apply. Use credentials for that organization or update organization_id
```

The provider reads its `organization_id` and `workspace_id` arguments only from the provider block. The `ANTHROPIC_ORGANIZATION_ID` and `ANTHROPIC_WORKSPACE_ID` [federation environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables), and a profile file’s settings of the same names, belong to the credential. A profile’s `workspace_id`, for example, names the workspace to sign in to.

## Workspace pin

`workspace_id` is optional on the Claude API, and checks the workspace as well:

```hcl
provider "anthropic" {
  organization_id = "00000000-0000-0000-0000-000000000000"
  workspace_id    = "wrkspc_00000000000000000000000"
}
```

Find the ID under [Workspaces in the Claude Console](https://platform.claude.com/settings/workspaces).

The credential determines which workspace the provider acts in, and `workspace_id` only checks it. If the credential acts in a different workspace, the provider stops with an error.

Which workspace a credential acts in depends on its type and its [OAuth scopes](https://platform.claude.com/docs/en/manage-claude/wif-reference#oauth-scopes):

| Credential | Workspace that it acts in |
| ----- | ----- |
| Federation profile, unless its only scope is `org:admin` | Its rule’s workspace. If the rule covers all workspaces or more than one, the workspace in the profile file’s own `workspace_id` setting, not the provider block’s. |
| Login, unless its only scope is `org:admin` | The workspace that you picked when you signed in. Otherwise, the organization’s default workspace. To use another workspace, see [Switch between workspaces](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#switch-between-workspaces). |
| Workspace-scoped [Developer API key](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) | The workspace it’s scoped to. |
| Federation or login token whose only scope is `org:admin` | None. |
| Admin API key | None. |

The last two rows are organization-level credentials. A block that uses one can’t set `workspace_id`. Some [personal keys and service account keys](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) are scoped to the organization, not to one workspace. The provider treats such a key as an organization-level credential.

A login with only `org:admin` isn’t tied to a workspace. A federation token with only that scope is tied to one, but you can’t pin it with `workspace_id`. For such a token to manage [organization webhooks](https://platform.claude.com/docs/en/manage-claude/organization-webhooks#before-you-begin), that workspace must be your organization’s [default workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#how-workspaces-work). The table’s first row says how a federation token gets its workspace.

## Resources and what `terraform destroy` does

For each resource’s arguments and attributes, see its reference page on the [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs). The provider has more resource types than these docs cover, and the Registry lists them all. Some resources have [deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection), which is on by default. While it’s on, `terraform destroy` stops with an error instead of doing what the following tables say.

### Organization resources

The organization resources manage your organization’s [workspaces](https://platform.claude.com/docs/en/manage-claude/workspaces) and their members, its [service accounts and federation rules](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation), its [encryption keys](https://platform.claude.com/docs/en/manage-claude/cmek), and its [OpenTelemetry destinations](https://platform.claude.com/docs/en/manage-claude/opentelemetry/api). They call the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api). For the rest of the Admin API, such as Developer API keys, invites, and usage reports, call it directly. For a full example, see [Example: a team’s workspace and CI identity](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#example-a-teams-workspace-and-ci-identity).

| Resource | `terraform destroy` |
| ----- | ----- |
| `anthropic_workspace` | Archives the workspace and its Developer API keys permanently. |
| `anthropic_workspace_member` | Removes the user from the workspace. |
| `anthropic_service_account` | Archives the service account permanently. |
| `anthropic_workspace_service_account` | Removes the service account from the workspace. In the [default workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#how-workspaces-work), destroy only sets the account’s role back to `workspace_user`. |
| `anthropic_federation_issuer` | Archives the issuer permanently. |
| `anthropic_federation_rule` | Archives the rule permanently. |
| `anthropic_federation_rule_workspace` | Disables the rule in that workspace. A rule with `applies_to_all_workspaces` set to `true` stays enabled there, as [Federation rules](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#federation-rules) describes. |
| `anthropic_external_key` | Deletes the key configuration, but only while no workspace, archived or not, uses the key. Attaching the key to a workspace is one-way. To stop managing the key, use a `removed` block with `lifecycle { destroy = false }`. |
| `anthropic_beta_telemetry_destination` | Deletes the destination. |

Use `anthropic_workspace_member` for people with an organization role such as user or developer. Organization admins and billing members already hold a role in every workspace. The API rejects adding them to a workspace or removing them from one.

### Managed Agents resources

These resources set up Claude Managed Agents in the workspace that the provider acts in. You create them once, and they last across sessions. For the concepts, see the [Claude Managed Agents overview](https://platform.claude.com/docs/en/managed-agents/overview).

| Resource | `terraform destroy` | Pages that show it in Terraform |
| ----- | ----- | ----- |
| `anthropic_beta_agent` | Archives the agent permanently, and its deployments with it. | [Define your agent](https://platform.claude.com/docs/en/managed-agents/agent-setup), [Tools](https://platform.claude.com/docs/en/managed-agents/tools), [MCP connector](https://platform.claude.com/docs/en/managed-agents/mcp-connector), [Multiagent orchestration](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration) |
| `anthropic_beta_environment` | Deletes the environment. | [Cloud environment setup](https://platform.claude.com/docs/en/managed-agents/environments) |
| `anthropic_beta_vault` | Deletes the vault. | [Authenticate with vaults](https://platform.claude.com/docs/en/managed-agents/vaults) |
| `anthropic_beta_vault_credential` | Deletes the credential. | [Authenticate with vaults](https://platform.claude.com/docs/en/managed-agents/vaults) |
| `anthropic_skill` | Deletes the skill and all of its versions. | [Skills](https://platform.claude.com/docs/en/managed-agents/skills) |
| `anthropic_beta_memory_store` | Deletes the store. | [Using agent memory](https://platform.claude.com/docs/en/managed-agents/memory) |
| `anthropic_beta_memory` | Deletes the document. | [Using agent memory](https://platform.claude.com/docs/en/managed-agents/memory) |
| `anthropic_beta_deployment` | Archives the deployment permanently, which ends its schedule. | [Scheduled deployments](https://platform.claude.com/docs/en/managed-agents/scheduled-deployments) |

Each `beta_` type calls a beta API. The provider sends that API’s [beta header](https://platform.claude.com/docs/en/api/beta-headers) on every call.

## Credentials for each resource

This table shows which credentials the resources on this page accept on the Claude API.

| Resources | Federation profile | Login | Workspace-scoped [Developer API key](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) | [Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys) |
| ----- | ----- | ----- | ----- | ----- |
| [Managed Agents resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources) | [Rule with `workspace:developer`](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#run-terraform-from-a-pipeline). No other scope works. | With the default scopes, as [Run Terraform at a terminal](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#run-terraform-at-a-terminal) describes.<br />`--scope org:admin` replaces them. | Yes | No |
| [Organization resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#organization-resources): workspaces, workspace members, external keys, OpenTelemetry destinations, and organization user data sources | [Rule with `org:admin`](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | [`--scope org:admin`](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | No | Yes |
| [Organization resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#organization-resources): service accounts, workspace service accounts, federation issuers, federation rules, and federation rule workspaces | [Rule with `org:admin`](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | [`--scope org:admin`](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | No | No. These endpoints need an `org:admin` token. |

In this table, a token from the [federation environment variables](https://platform.claude.com/docs/en/manage-claude/wif-reference#environment-variables) counts as a federation profile. A token in `ANTHROPIC_AUTH_TOKEN` or the block’s `auth_token` counts as the credential that it came from.

A login acts with your own role. To create, change, or destroy agents, deployments, vaults, vault credentials, or environments, you need at least a developer role. That role can be in the organization or in the workspace that the login acts in, where Workspace Limited Developer also counts. With a lower role, such as user or billing, you can read these resources, but the API refuses those changes. A login needs no developer role for memory stores and memories. For skills, it needs at least a developer role, even to read them. A [personal key](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) scoped to a workspace is limited by your role too, including on skills and on reading environments.

Some changes need the Claude Console even with `org:admin`, such as managing a federation rule that grants that scope. For the list, see [Permissions and constraints](https://platform.claude.com/docs/en/manage-claude/wif-admin-api#permissions-and-constraints).

If your federation profile or login lacks `org:admin`, the API returns “not found” for service accounts, workspace service accounts, and federation resources. You get the same answer if your login holds `org:admin` but the person it belongs to is no longer an organization admin. An API key gets a clear refusal instead.

If Terraform already manages any of these resources, it can’t tell whether they still exist. `terraform plan`, `terraform apply`, and `terraform destroy` stop with an error such as “Cannot tell whether the resource exists” and keep the resources in state.

To fix the error, give the provider block that manages the resources a credential with `org:admin`, and then run the command again. The credential’s user or service account needs the admin organization role. For instructions, see [Organization credentials](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials).

A [personal or service account key](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) scoped to the organization can’t manage Managed Agents resources through the provider. It also can’t manage service accounts, workspace service accounts, or federation resources. To manage workspaces, workspace members, external keys, and OpenTelemetry destinations, its user or service account needs the admin organization role.

## Resources on each cloud platform

On Claude Models on Google Cloud (Anthropic managed) and Claude Platform on AWS, the provider block’s `workspace_id` names the workspace that the provider acts in, in place of `organization_id`. That workspace must exist before you run `terraform plan`. Your cloud’s IAM, not `workspace_id`, determines what your cloud credentials can reach.

### Claude Platform on AWS

Of the resources in the tables under [Resources and what `terraform destroy` does](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#resources-and-what-terraform-destroy-does), you can use these on this platform, and any data sources they have:

* `anthropic_workspace`
* `anthropic_external_key`
* `anthropic_beta_telemetry_destination`
* `anthropic_beta_agent`
* `anthropic_beta_environment`
* `anthropic_beta_vault`
* `anthropic_beta_vault_credential`
* `anthropic_skill`
* `anthropic_beta_memory_store`
* `anthropic_beta_memory`

You can also use these:

* `anthropic_beta_skill`
* `anthropic_compliance_settings`
* The `anthropic_models` data source

### Claude Models on Google Cloud (Anthropic managed)

Of the resources in the tables under [Resources and what `terraform destroy` does](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#resources-and-what-terraform-destroy-does), you can use these on this platform, and any data sources they have:

* `anthropic_external_key`
* `anthropic_beta_agent`
* `anthropic_beta_environment`
* `anthropic_beta_vault`
* `anthropic_beta_vault_credential`
* `anthropic_skill`
* `anthropic_beta_memory_store`
* `anthropic_beta_memory`
* `anthropic_beta_deployment`

You can also use these:

* `anthropic_beta_skill`
* `anthropic_compliance_settings`
* The `anthropic_models` data source
* The `anthropic_rate_limits` data source
* The `anthropic_workspace_rate_limits` data source
* The `anthropic_workspaces` data source

### Claude Managed Agents on Amazon Bedrock

On this platform, you can use these resources and their data sources:

* `anthropic_beta_bedrock_agent`
* `anthropic_beta_bedrock_memory_store`
* `anthropic_beta_bedrock_memory`

Here, `workspace_id` names an Amazon Bedrock project, as [Claude Managed Agents on Amazon Bedrock](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#claude-managed-agents-on-amazon-bedrock) describes. `terraform destroy` archives an agent permanently and deletes a memory store or a memory. Agents and memory stores have [deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection).

## Deletion protection

While `deletion_protection` is on, the provider stops with an error instead of destroying or replacing a resource. If `terraform destroy` or a deleted resource block would destroy a protected resource, the plan fails and nothing is destroyed. Resources such as `anthropic_workspace`, `anthropic_service_account`, `anthropic_federation_rule`, and `anthropic_skill` have this argument, and each one’s page on the [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs) shows it. It defaults to `true`, including for a resource that you import or that an earlier provider build created.

The provider reads the setting from state, so one apply can’t both turn protection off and destroy the resource. For the same reason, and unlike `lifecycle { prevent_destroy = true }`, protection still holds after you delete the resource block. For the steps, see [Destroy or replace a protected resource](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#destroy-or-replace-a-protected-resource).

### Forced replacements

Some changes to your configuration replace a resource. While protection is on, a plan that includes such a change fails.

Terraform doesn’t tell the provider when it forces a replacement through `-replace`, `replace_triggered_by`, or a tainted resource. While protection is on, the apply fails even if the plan ran without errors. Before the apply stops, it can destroy resources that depend on the protected resource. To turn protection off first, see [Destroy or replace a protected resource](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#destroy-or-replace-a-protected-resource).

### Service account name clash

In a forced replacement of a service account that has `create_before_destroy`, Terraform creates the new account before it archives the old one. Two service accounts that aren’t archived can’t share a name, so creating the new account fails. Give the new account a different `name` in the apply that replaces the old one. To rename an account, see [Rename a service account](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#rename-a-service-account).

## Agent versions

Every change to an agent publishes a new version. The `version` attribute starts at 1 and increases with each apply that changes the agent. A session that names only the agent’s ID uses the latest version. A session that also names a version stays on that version.

## Multiagent settings

An agent’s `multiagent` argument takes an object whose one key is a dated type name: `multiagent = { multiagent_20261001 = { ... } }`. With the `multiagent_20261001` type, an agent can hand work to subagents, start workflow runs, and consult an advisor model. The type’s settings, `subagents`, `workflows`, and `advisor`, go inside the `multiagent_20261001` object. See [Multiagent orchestration](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration) for what each setting does.

`subagents.enabled.predefined_agents` lists the agents that the agent can delegate to, and `workflows.enabled.predefined_agents` lists the agents that a workflow can use. Both settings take the same shape: `subagents = { enabled = { predefined_agents = [...] } }`.

To turn a setting off, write `disabled = {}` inside it, as in `workflows = { disabled = {} }`. If you remove `subagents`, `workflows`, or `advisor` from your Terraform configuration, the agent keeps the value that it has.

### Entries that name an agent

An entry that names an agent takes the shape `{ agent = { id = ..., version = ... } }`. Each entry in either list determines which version of its agent runs:

* An entry such as `{ agent = { id = anthropic_beta_agent.researcher.id, version = anthropic_beta_agent.researcher.version } }` tracks the researcher, so an apply that changes the researcher also updates the list.
* An entry with only an `id` gets the agent’s latest version when you first apply the entry. It gets the latest version again whenever the entry’s position in the list changes, as when you add or remove an entry above it. It stays on its version when the agent gets a new one.
* An entry with a literal `version` stays pinned to that version.

A `{ self = {} }` entry lets the agent delegate to copies of itself.

## Skill files

`anthropic_skill` publishes a folder of files as a skill. Each `file` block sets `path`, the file’s path in the skill, and exactly one of these:

* `source`, the path of a file on disk. Binary files work.
* `content`, text written in the configuration.

Every `file` block’s `path` starts with the same top-level folder, and `SKILL.md` sits directly inside it, as in `my-skill/SKILL.md`. The folder’s name must match the `name` in the `SKILL.md` frontmatter.

Changing `display_name` or the `name` in `SKILL.md` replaces the skill, which deletes all of its versions. Turn off [deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection) before you make either change.

### Skill versions

Each apply that changes a file publishes a new version, and `latest_version_id` shows the newest one. An agent that lists the skill in its `skills` argument without a `version` uses the latest version.

## Deployments

### Deployment versions

`agent` names the agent and, optionally, its version, as in `agent = { agent = { id = anthropic_beta_agent.reporter.id, version = anthropic_beta_agent.reporter.version } }`. With `version` set this way, an apply that changes the agent also moves the deployment to the new version. Without `version`, the deployment stays on its version when the agent gets a new one.

### Paused deployments

A run of an `anthropic_beta_deployment` can fail in a way that retrying won’t fix, such as when its environment or vault was archived or deleted. The API then pauses the deployment, and Terraform doesn’t resume it. The read-only `status` shows `paused`, with the reason in `paused_reason`. Fix the cause, and then unpause the deployment, as [Managing deployment lifecycle](https://platform.claude.com/docs/en/managed-agents/scheduled-deployments#managing-deployment-lifecycle) describes.

## Changes made outside Terraform

### Federation rules

A rule’s own `workspace_id` enables the rule in one workspace. Each `anthropic_federation_rule_workspace` enables the rule in one more workspace.

While `applies_to_all_workspaces` is `true`, a rule is enabled in every workspace, whatever its `workspace_ids` list holds. Creating or destroying an `anthropic_federation_rule_workspace` then only edits that list, and so do the changes in the following table.

To limit the rule to specific workspaces, set `applies_to_all_workspaces` to `false` and set the rule’s own `workspace_id` in the same apply. The rule is then enabled only in the workspaces on its `workspace_ids` list, which can hold more than the one that you set.

| Change that someone makes outside Terraform | What Terraform does |
| ----- | ----- |
| Someone disables the rule in the workspace that an `anthropic_federation_rule_workspace` names. | The next `terraform plan` shows the change. The next `terraform apply` enables the rule in that workspace again. |
| Someone enables the rule in another workspace. | Terraform does nothing, so the rule stays enabled in that workspace. A plain `terraform plan` reports no changes. `terraform plan -refresh-only` shows the added workspace in the rule’s `workspace_ids` attribute. The next `terraform apply` saves the new list in state, so no later plan shows the change. |

The [Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api) records each of these changes and who made it.

### Skill versions published elsewhere

If someone publishes a version of the skill outside Terraform, the next plan shows a “Skill changed outside Terraform” warning. The plan can’t show what changed in the skill’s files. Terraform proposes to publish your declared files as a new version, and the next apply does that. See [Skills](https://platform.claude.com/docs/en/managed-agents/skills).

### Memory documents that agents edit

Because agents edit documents during sessions, a configuration that also manages a document’s content can overwrite their edits. For documents that agents own, add `lifecycle { ignore_changes = [content] }` to their `anthropic_beta_memory` resources. See [Using agent memory](https://platform.claude.com/docs/en/managed-agents/memory).

### Deleted or archived objects

If someone deletes or archives an object outside Terraform, the next plan warns that the object is gone and proposes to create it again. For service accounts, workspace service accounts, and federation resources, a federation profile or login without `org:admin` gets an error instead. See [Credentials for each resource](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#credentials-for-each-resource).

## State and plan output

Terraform stores everything you configure in plain text in its state, and plan output shows the same values, including in pull-request comments and CI logs. Marking a value as sensitive hides it from plan output, but Terraform still stores it in state.

For organization resources, state holds:

* The layout of your workspaces and service accounts
* Your federation issuers and rules
* The identifiers of your encryption keys
* Your OpenTelemetry destinations’ endpoint URLs and header names
* Members’ names, emails, and roles, if you use the `anthropic_organization_user` or `anthropic_organization_users` data source

It holds no secrets, but it shows which people and which service accounts can act in your organization.

For Managed Agents resources, state holds agent system prompts, custom tool schemas, memory content, and skill files written as `content`. For a skill file given as `source`, state stores only its hash. Vault credential secrets and a deployment’s GitHub repository token are the exceptions: they’re write-only arguments.

### Write-only arguments

The secret arguments of an `anthropic_beta_vault_credential`, such as `token_wo` and `secret_value_wo`, are write-only. Terraform sends a write-only value to the API but never stores it in state or plans. Declare the variables that supply these arguments with `ephemeral = true`, as [Keep state and plans safe](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#keep-state-and-plans-safe) explains.

Terraform can’t detect when a write-only value changes, and the API never returns secrets.

Each write-only argument has a companion `_wo_version` argument, such as `token_wo_version`. To send a new value, for example after you rotate a secret, change its `_wo_version`.

### Vault credentials

The API matches a vault credential to an agent’s MCP server by URL alone, so the credential’s `mcp_server_url` must be the same URL as the agent’s `mcp_servers` entry. Where a service supports OAuth, prefer an `mcp_oauth` credential with a refresh token over a long-lived static token.

Cut at 300 lines. The page has the rest.

cli-sdks-libraries/sdks/terraform/operations New page · 109 lines, new page

## Pin the provider’s release ## Use the provider in a module ## Destroy or replace a protected resource ## Refactor without archiving ## Rename a service account ## Attach an encryption key to a workspace ## Import existing resources ## Recover after a failed create ## Keep state and plans safe ## Start a session from Terraform outputs ## Catch changes made outside Terraform ## Turn on logs

A whole new page. There's nothing to diff it against, so here is what it says.

---
title: Operate the Terraform provider
url: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations
description: "Tasks for after the first apply: import existing resources, keep state and plans safe, and turn on logs."
---

## Pin the provider’s release

`terraform init` selects the newest release and records it in `.terraform.lock.hcl`. Commit that file, so that every machine uses the same release until you run `terraform init -upgrade`.

## Use the provider in a module

Any module that uses the provider’s resources or data sources needs `source = "anthropics/anthropic"` in its own `required_providers` block. Without it, Terraform searches for `hashicorp/anthropic`, and `terraform init` fails.

## Destroy or replace a protected resource

To destroy or replace a protected resource, first set `deletion_protection = false` and apply that change on its own.

Then destroy or replace the resource. After a replacement, set `deletion_protection = true` again, and apply. [Deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection) explains why turning protection off needs its own apply.

## Refactor without archiving

Change a resource’s address with `moved` blocks, and stop managing one with a `removed` block with `lifecycle { destroy = false }`. Add `lifecycle { prevent_destroy = true }` to anything that a mistaken plan must never archive.

## Rename a service account

A rename replaces a service account. To rename one that a federation rule targets:

1. Add `lifecycle { create_before_destroy = true }` to the service account.
2. Turn off [deletion protection](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection) on the service account, and apply that change on its own.
3. Change the account’s name, and apply.
4. Set `deletion_protection = true` again, and apply.

With `create_before_destroy`, Terraform creates the new account and updates the rule before it archives the old account.

## Attach an encryption key to a workspace

Once you attach a key to a workspace, you can’t detach or replace it.

[Grant Anthropic access to the key](https://platform.claude.com/docs/en/manage-claude/cmek#set-it-up) before you attach it to a workspace. How you attach it depends on the platform that your provider block uses, not on where the key lives:

* On the Claude API, apply the `anthropic_external_key` resource on its own and [validate the key](https://platform.claude.com/docs/en/manage-claude/cmek-admin-api#create-validate-attach). Then set `external_key_id` on the `anthropic_workspace`.
* On Claude Platform on AWS, declare the `anthropic_external_key` resource, and set `external_key_id` on an `anthropic_workspace`. Attaching checks the key, as [Set up CMEK on Claude Platform on AWS](https://platform.claude.com/docs/en/manage-claude/cmek-claude-platform-on-aws#register-the-key-with-anthropic) describes.
* On Claude Models on Google Cloud (Anthropic managed), apply the `anthropic_external_key` resource. Then verify the key and attach it in the Claude Console, as [Set up CMEK with Google Cloud KMS](https://platform.claude.com/docs/en/manage-claude/cmek-google-cloud-kms#register-the-key-with-anthropic) describes.

Once any workspace uses an `anthropic_external_key`, you can’t change that resource’s `provider_config`. To use a different key, create a new workspace with it, as [Change keys or stop using CMEK](https://platform.claude.com/docs/en/manage-claude/cmek-key-lifecycle#change-keys) describes.

## Import existing resources

You can import every resource that [How the Terraform provider behaves](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#resources-and-what-terraform-destroy-does) lists. Each resource’s reference page on the [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs) shows its import ID. Add an `import` block, and then generate the resource block:

```hcl
import {
  to = anthropic_workspace.research
  id = "wrkspc_01AbCdEf23GhIj"
}
```

```bash
terraform plan -generate-config-out=generated.tf
```

The generated configuration is missing some values inside the resources that you import:

* Secrets, which can’t be imported. They go in the write-only arguments of vault credentials and of a deployment’s GitHub repository. Those arguments’ names end in `_wo`.
* Skill files, which can’t be imported. They go in each skill’s `file` blocks.
* URLs, which are sensitive, so the generated configuration leaves them `null`. They go in each agent’s `mcp_servers`, and in vault credentials’ `mcp_server_url` and `token_endpoint`.

Add these values in `generated.tf`.

An imported `anthropic_beta_telemetry_destination` keeps the request headers it sends to your observability platform, such as the platform’s API key. The generated configuration doesn’t have `headers_wo`, because the API never returns the header values. To manage them in Terraform, set `headers_wo` and a new `headers_wo_version` in the same apply.

Then run `terraform plan` to check the result, and run `terraform apply` to finish the import.

## Recover after a failed create

After a server error or a dropped connection, the provider doesn’t retry most creates, to avoid duplicates. After either one, or an interrupted apply, the object might exist but be missing from Terraform state.

Check for the object, and if it exists, import it as [Import existing resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/operations#import-existing-resources) describes. If you don’t import it, the next apply can create a duplicate or fail.

## Keep state and plans safe

* Store state in an encrypted, versioned, access-logged, access-controlled remote backend with locking, readable only by the pipeline that applies it. For example, use S3 with a KMS key and least-privilege IAM, GCS with a customer-managed key, or HCP Terraform.
* Never commit `.tfstate` files, and treat saved plans, and any state or plan artifacts in CI, as secrets.
* Declare the variables that supply write-only arguments with `ephemeral = true`, because a saved plan records the value of every variable that isn’t ephemeral.

HashiCorp’s [Manage sensitive data](https://developer.hashicorp.com/terraform/language/manage-sensitive-data) guide covers the rest.

## Start a session from Terraform outputs

Sessions aren’t resources. To start sessions on a schedule, use a [scheduled deployment](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#deployments) instead.

A session needs the agent’s `id` and the `environment_id`. It can also name the agent’s `version`, the `vault_ids`, and any memory stores to mount as `resources`. Output those values from your configuration.

The [`managed-agents/coding-agent`](https://github.com/anthropics/terraform-provider-anthropic/tree/main/examples/managed-agents/coding-agent) example renders the whole request body as a `session_request` output. Run `terraform output -raw session_request` to print a body that you can pass to the SDK’s method for creating a session. See [Start a session](https://platform.claude.com/docs/en/managed-agents/sessions).

## Catch changes made outside Terraform

Run `terraform plan` on a schedule to catch drift. Also run `terraform plan -refresh-only` on the same schedule. That command shows [a federation rule that someone enabled in another workspace](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#federation-rules), but only if no `terraform apply` has run since the change.

## Turn on logs

To log every request and response, set `TF_LOG_PROVIDER=DEBUG`:

```bash
TF_LOG_PROVIDER=DEBUG terraform apply 2> provider.log
```

The log redacts API keys, tokens, and every field that the schema marks as sensitive.

manage-claude/opentelemetry/api Changed · +25 / -0 lines

from line 223
223223 
224224 puts destination.id
225225 ```
226 
227 <CodeGroupItem>
228 ```hcl Terraform
229 variable "observability_api_key" {
230 type = string
231 sensitive = true
232 ephemeral = true
233 }
234 
235 resource "anthropic_beta_telemetry_destination" "otel" {
236 endpoint_url = "https://gateway.example.com/otlp"
237 headers_wo = {
238 authorization = "Bearer ${var.observability_api_key}"
239 }
240 # Increase to send changed headers
241 headers_wo_version = 1
242 traces = {
243 content_mode = "metadata_only"
244 }
245 workspaces = {
246 all = {}
247 }
248 }
249 ```
250 </CodeGroupItem>
226251</CodeGroup>
227252 
228253A create request takes the Console’s settings except **Provider**, so enter your observability platform’s endpoint URL and headers yourself. Set `traces.max_content_bytes` (csharp, go: `Traces.MaxContentBytes`; java, php: `traces.maxContentBytes`), in bytes, to fit what your observability platform accepts (see [Content limits](https://platform.claude.com/docs/en/manage-claude/opentelemetry#content-limits)). To list, change, or delete destinations, or to add or remove one workspace, use the other methods of the [telemetry destinations API](https://platform.claude.com/docs/en/api/beta/organization/telemetry_destinations).

managed-agents/environments Changed · +51 / -0 lines

from line 172
172172 
173173 puts "Environment ID: #{environment.id}"
174174 ```
175 
176 ```hcl Terraform
177 resource "anthropic_beta_environment" "python_dev" {
178 name = "python-dev"
179 config = {
180 cloud = {
181 networking = {
182 limited = {
183 allow_package_managers = true
184 }
185 }
186 }
187 }
188 }
189 ```
175190</CodeGroup>
176191 
177192Use a unique, descriptive `name` (csharp, go: `Name`) so you can tell environments apart. This example uses `limited` [networking](https://platform.claude.com/docs/en/managed-agents/environments#networking) with package managers allowed, so the sandbox can reach the package registries and code hosts. To let it reach other hosts, add them to `allowed_hosts` (java, php: `allowedHosts`; csharp, go: `AllowedHosts`).
from line 435
420435 }
421436 )
422437 ```
438 
439 ```hcl Terraform
440 resource "anthropic_beta_environment" "data_analysis" {
441 name = "data-analysis"
442 config = {
443 cloud = {
444 packages = {
445 pip = ["pandas", "numpy", "scikit-learn"]
446 npm = ["express"]
447 }
448 networking = {
449 limited = {
450 allow_package_managers = true
451 }
452 }
453 }
454 }
455 }
456 ```
423457</CodeGroup>
424458 
425459Supported package managers:
from line 638
604638 }
605639 }
606640 )
641 ```
642 
643 ```hcl Terraform
644 resource "anthropic_beta_environment" "api_access" {
645 name = "api-access"
646 config = {
647 cloud = {
648 networking = {
649 limited = {
650 allowed_hosts = ["api.example.com"]
651 allow_mcp_servers = true
652 allow_package_managers = true
653 }
654 }
655 }
656 }
657 }
607658 ```
608659</CodeGroup>
609660 

managed-agents/mcp-connector Changed · +51 / -0 lines

from line 237
237237 ]
238238 )
239239 ```
240 
241 ```hcl Terraform
242 resource "anthropic_beta_agent" "github_assistant" {
243 name = "GitHub Assistant"
244 model = { id = "claude-opus-5-5" }
245 mcp_servers = [
246 { url = { name = "github", url = "https://api.githubcopilot.com/mcp/" } },
247 ]
248 tools = [
249 { agent_toolset_20260401 = {} },
250 {
251 mcp_toolset = {
252 mcp_server_name = "github"
253 }
254 },
255 ]
256 }
257 ```
240258</CodeGroup>
241259 
242260<Tip>
from line 295
277295}
278296```
279297 
298With the Terraform provider, this entry goes in the `tools` argument of an `anthropic_beta_agent` resource:
299 
300```hcl
301tools = [
302 {
303 mcp_toolset = {
304 mcp_server_name = "github"
305 default_config = { enabled = false }
306 configs = [
307 { name = "get_issue", enabled = true },
308 { name = "list_issues", enabled = true },
309 { name = "add_issue_comment", enabled = true },
310 ]
311 }
312 },
313]
314```
315 
280316This pattern is useful when a server exposes many tools but the agent only needs a few, or when you want tools added by the server operator to stay off until you review them.
281317 
282318To disable specific tools while keeping the rest enabled, omit `default_config` (java, php: `defaultConfig`; csharp, go: `DefaultConfig`) and set `enabled: false` on individual entries:
from line 323
287323 "mcp_server_name": "github",
288324 "configs": [{ "name": "delete_repository", "enabled": false }]
289325}
326```
327 
328With the Terraform provider, this entry goes in the `tools` argument of an `anthropic_beta_agent` resource:
329 
330```hcl
331tools = [
332 {
333 mcp_toolset = {
334 mcp_server_name = "github"
335 configs = [
336 { name = "delete_repository", enabled = false },
337 ]
338 }
339 },
340]
290341```
291342 
292343See [Configuring the toolset](https://platform.claude.com/docs/en/managed-agents/tools#configuring-the-toolset) for the general `default_config` (java, php: `defaultConfig`; csharp, go: `DefaultConfig`) / `configs` (csharp, go: `Configs`) pattern, and [MCP toolset permissions](https://platform.claude.com/docs/en/managed-agents/permission-policies#mcp-toolset-permissions) for setting `permission_policy` (java, php: `permissionPolicy`; csharp, go: `PermissionPolicy`) on MCP tools and handling confirmation requests.

managed-agents/memory Changed · +20 / -0 lines

from line 157
157157 )
158158 puts store.id # memstore_01Hx...
159159 ```
160 
161 ```hcl Terraform
162 resource "anthropic_beta_memory_store" "user_preferences" {
163 name = "User Preferences"
164 description = "Per-user preferences and project context."
165 }
166 ```
160167</CodeGroup>
161168 
162169The memory store `id` (csharp, go: `ID`) (`memstore_...`) is what you pass when attaching the store to a session.
from line 249
242249 path: "/formatting_standards.md",
243250 content: "All reports use GAAP formatting. Dates are ISO-8601..."
244251 )
252 ```
253 
254 ```hcl Terraform
255 resource "anthropic_beta_memory" "formatting_standards" {
256 memory_store_id = anthropic_beta_memory_store.user_preferences.id
257 path = "/formatting_standards.md"
258 content = "All reports use GAAP formatting. Dates are ISO-8601..."
259 
260 # Agents edit memories during sessions; keep their changes.
261 lifecycle {
262 ignore_changes = [content]
263 }
264 }
245265 ```
246266</CodeGroup>
247267 

managed-agents/migration Changed · +11 / -0 lines

from line 1366
13661366 model: "claude-opus-5-5"
13671367 )
13681368 ```
1369 
1370 ```hcl Terraform
1371 resource "anthropic_beta_agent" "task_runner" {
1372 name = "Task Runner"
1373 model = { id = "claude-opus-5-5" } # change this, then terraform apply
1374 tools = [
1375 { agent_toolset_20260401 = {} },
1376 ]
1377 system = "You are a task automation agent. Complete the task you are given end to end."
1378 }
1379 ```
13691380</CodeGroup>
13701381 
13711382Most model-level behavior changes documented in the [Migration guides](https://platform.claude.com/docs/en/about-claude/models/migration-guide) do not require action on your side:

models/fable-5-2/migration-guide Changed · +20 / -6 lines

from line 4
44description: Switch to Claude Fable 5.2 and Claude Mythos 5.2 from Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, or an earlier Claude Fable, Claude Mythos, or Claude Opus model with this migration guide. The guidance to enable Claude Fable 5.2 and Claude Mythos 5.2 includes model IDs, breaking changes, and migration checklists.
55---
66 
7<Note>
8 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
9</Note>
7Let Claude help you migrate your code
108 
11Let Claude Code migrate your code for you
9Migrate an existing project:
1210 
1311```text
1412/claude-api migrate this project to claude-fable-5-2
1513```
14 
15Check what would break:
16 
17```text
18/claude-api list what breaks moving to claude-fable-5-2. Don’t edit code.
19```
20 
21Explain it:
22 
23```text
24Read https://platform.claude.com/docs/en/models/fable-5-2/migration-guide and explain what changes moving to Claude Fable 5.2
25```
26 
27<Note>
28 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
29</Note>
1630 
1731If your Claude Managed Agents agent has an advisor, the advisor’s `model` is a second model name to update: set it to `claude-fable-5-2` or `claude-mythos-5-2` when you change the agent’s model. See [A Claude Fable 5.2 executor needs a Claude Fable 5.2 or Claude Mythos 5.2 advisor](https://platform.claude.com/docs/en/models/fable-5-2/migration-guide#fable-5-2-advisor-pairs). If the agent’s `model` object sets `speed: "fast"`, remove that setting too.
1832 

models/haiku-5-5/migration-guide Changed · +18 / -4 lines

from line 4
44description: Switch to Claude Haiku 5.5 from earlier Haiku models with this migration guide. The guidance to enable Claude Haiku 5.5 includes the new model ID, settings that return errors, thinking changes, and a checklist for each starting model.
55---
66 
7<Note>
8 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
9</Note>
7Let Claude help you migrate your code
108 
11Let Claude Code migrate your code for you
9Migrate an existing project:
1210 
1311```text
1412/claude-api migrate this project to claude-haiku-5-5
1513```
14 
15Check what would break:
16 
17```text
18/claude-api list what breaks moving to claude-haiku-5-5. Don’t edit code.
19```
20 
21Explain it:
22 
23```text
24Read https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide and explain what changes moving to Claude Haiku 5.5
25```
26 
27<Note>
28 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
29</Note>
1630 
1731This guide covers moving code that calls Claude Haiku 4.5 to Claude Haiku 5.5. For code that calls Claude Haiku 3.5 or Claude Haiku 3, also make the changes in [Migrating to Claude Haiku 5.5 from Claude Haiku 3.5 and earlier Haiku models](https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide#migrating-from-haiku-35). To move up to a Sonnet or Opus model instead, see [Migration guides](https://platform.claude.com/docs/en/about-claude/models/migration-guide). For how long Claude Haiku 4.5 stays available, see [Model deprecations](https://platform.claude.com/docs/en/about-claude/model-deprecations).
1832 

models/opus-5-5/migration-guide Changed · +20 / -6 lines

from line 4
44description: Switch to Claude Opus 5.5 from earlier Opus models or Claude Sonnet 5 with this migration guide. The guidance to enable Claude Opus 5.5 includes request settings that return errors, thinking blocks in every response, and a checklist for each starting model.
55---
66 
7<Note>
8 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
9</Note>
7Let Claude help you migrate your code
108 
11Let Claude Code migrate your code for you
9Migrate an existing project:
1210 
1311```text
1412/claude-api migrate this project to claude-opus-5-5
1513```
14 
15Check what would break:
16 
17```text
18/claude-api list what breaks moving to claude-opus-5-5. Don’t edit code.
19```
20 
21Explain it:
22 
23```text
24Read https://platform.claude.com/docs/en/models/opus-5-5/migration-guide and explain what changes moving to Claude Opus 5.5
25```
26 
27<Note>
28 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
29</Note>
1630 
1731This page lists the code changes for moving to Claude Opus 5.5 from [Claude Opus 5](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migrating-from-claude-opus-5), [Claude Opus 4.8](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migrating-from-claude-opus-4-8), [Claude Opus 4.7](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migrating-from-claude-opus-47), [Claude Opus 4.6 and earlier Opus models](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migrating-from-claude-opus-46), or [Claude Sonnet 5](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migrating-from-claude-sonnet-5). Every reader needs [What every request to Claude Opus 5.5 must satisfy](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#request-requirements) and [Handle thinking in every response](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#thinking-in-every-response). Then go to the section for your current model: its first sentence names the other sections that apply to you. The [migration checklist](https://platform.claude.com/docs/en/models/opus-5-5/migration-guide#migration-checklist) lists every change by starting model.
1832 

models/sonnet-5-5/migration-guide Changed · +20 / -6 lines

from line 6
66 
77This guide lists the code changes for moving to Claude Sonnet 5.5 from Claude Sonnet 5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Sonnet 4, Claude Sonnet 3.7, or Claude Haiku 4.5. Read the first two sections, then read down to the section for your current model. The [migration checklist](https://platform.claude.com/docs/en/models/sonnet-5-5/migration-guide#migration-checklist) lists every change by starting model.
88 
9<Note>
10 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
11</Note>
9Let Claude help you migrate your code
1210 
13Let Claude Code migrate your code for you
11Migrate an existing project:
1412 
1513```text
1614/claude-api migrate this project to claude-sonnet-5-5
1715```
16 
17Check what would break:
18 
19```text
20/claude-api list what breaks moving to claude-sonnet-5-5. Don’t edit code.
21```
22 
23Explain it:
24 
25```text
26Read https://platform.claude.com/docs/en/models/sonnet-5-5/migration-guide and explain what changes moving to Claude Sonnet 5.5
27```
28 
29<Note>
30 This guide covers migrating [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) code. If you use [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), you usually change only your agent’s `model` field. The [Migrating between model versions](https://platform.claude.com/docs/en/managed-agents/migration#migrating-between-model-versions) section of the Managed Agents Migration page has the details.
31</Note>
1832 
1933Claude Sonnet 5.5 has the same prices as Claude Sonnet 5, except for prompt cache reads, which cost $0.10 USD per million tokens, half the Claude Sonnet 5 rate. See [Pricing](https://platform.claude.com/docs/en/about-claude/pricing). For its context window and output limits, see the [Claude Sonnet 5.5](https://platform.claude.com/docs/en/models/sonnet-5-5/overview) model page. For features and prompting, see [What’s new in Claude Sonnet 5.5](https://platform.claude.com/docs/en/models/sonnet-5-5/whats-new-sonnet-5-5#feature-support) and [Prompting Claude Sonnet 5.5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-sonnet-5-5).
2034 

release-notes/overview Changed · +4 / -0 lines

### December 3, 2026

from line 12
1212 For updates to Claude Code, see the [complete CHANGELOG.md](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) in the `claude-code` repository.
1313</Tip>
1414 
15### December 3, 2026
16 
17* We’ve launched the [Terraform provider](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform) in beta, so you can manage Claude Platform resources as code. It manages organization resources, such as workspaces, service accounts, Workload Identity Federation issuers, and federation rules. It also manages Claude Managed Agents resources, such as agents, environments, vaults, and skills. On [Claude Models on Google Cloud (Anthropic managed)](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#claude-models-on-google-cloud-anthropic-managed) and [Claude Platform on AWS](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#claude-platform-on-aws), you can manage [many of these resources](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/behavior#resources-on-each-cloud-platform). On [Claude Managed Agents on Amazon Bedrock](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/terraform/authentication#claude-managed-agents-on-amazon-bedrock), you can manage agents, memory stores, and memories. Install it from the Terraform Registry with the source address `anthropics/anthropic`.
18 
1519### December 1, 2026
1620 
1721* We’ve launched [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview) in beta on Amazon Bedrock. AWS operates it and bills your usage, and AWS IAM controls access. See [Claude Managed Agents for Amazon Bedrock](https://platform.claude.com/docs/en/managed-agents/amazon-bedrock).

about-claude/models/optimizing-for-cost-and-intelligence Changed · +1 / -1 lines

from line 57
5757* Caching does not stop the resending, but each resend costs about a tenth as much (a twentieth on Claude Opus 5.5 and Claude Sonnet 5.5, a fortieth on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, and Claude Mythos 5.1) and processes faster.
5858* The prefix is billed at the [cache-read rate](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pricing) instead of the input price, and each turn pays the 1.25x cache-write rate only for what is new.
5959 
60[Message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, stop the resending while a thread lasts, until 5 minutes after its last request. They lower time to first token, not cost: the model still reads the whole conversation, so keep `cache_control` on every request. Threads don’t support compaction on demand or most context editing. On the Claude API, Claude Platform on AWS, and Claude in Microsoft Foundry, they accept one form of threshold compaction (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
60[Message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, stop the resending while a thread lasts. They lower time to first token, not cost: the model still reads the whole conversation, so keep `cache_control` on every request. Threads don’t support compaction on demand or most context editing. On the Claude API, Claude Platform on AWS, and Claude in Microsoft Foundry, they accept one form of threshold compaction (see [Features that threads don’t support](https://platform.claude.com/docs/en/build-with-claude/message-threads#unsupported)).
6161 
6262**What good looks like.**
6363 

build-with-claude/working-with-messages Changed · +1 / -1 lines

from line 352
352352}
353353```
354354 
355With [message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, the API can keep the conversation, so that each later request sends only the new messages. A thread expires 5 minutes after its last request and is deleted no more than 1 hour after its last use.
355With [message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, the API can keep the conversation so that each later request sends only the new messages. A thread is best-effort and short-lived, so your application still keeps the whole conversation. Plan for a thread to expire 5 minutes after the last response that the API stored. The API deletes every thread no more than 1 hour after its last use (see [How long a thread lasts](https://platform.claude.com/docs/en/build-with-claude/message-threads#lifetime)).
356356 
357357### System role in messages
358358 

claude_api_primer Changed · +1 / -1 lines

from line 102
102102 ```
103103</CodeGroup>
104104 
105With [message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, the API can keep the conversation, so that each later request sends only the new messages. A thread expires 5 minutes after its last request and is deleted no more than 1 hour after its last use.
105With [message threads](https://platform.claude.com/docs/en/build-with-claude/message-threads), in beta, the API can keep the conversation so that each later request sends only the new messages. A thread is best-effort and short-lived. Plan for it to expire 5 minutes after the last response that the API stored. The API deletes every thread no more than 1 hour after its last use. Keep your own copy of the conversation. If a later request returns a 404 error with `error.details.error_code` set to `thread_not_found`, send the full conversation again and start a new thread.
106106 
107107### Prefilling Claude’s response
108108 
Feedback