Everything an AI agent can do with the Terraform Cloud API.

A reference guide for building AI agents: every method, how to authenticate, and the permissions each one needs.

Endpoints41
API versionv2
Last updated23 June 2026
Orientation

How the Terraform Cloud API works.

The Terraform Cloud API is how an app or AI agent works with an organization's infrastructure: listing and locking workspaces, queuing a run, applying or cancelling it, reading state versions, and managing variables and projects. Access is granted through an API token, where the token type and the team permissions behind it decide what each call can read or write, and an organization token is barred from running plans or applies at all. There is one stable v2 API, and a workspace can send run events outward to a chosen destination so an integration learns about activity without polling.

41Endpoints
10Capability groups
19Read
22Write
10Permissions
Authentication
Every call authenticates with an API token sent as 'Authorization: Bearer '. There are four token types: a user token acting as a person, a team token for pipeline automation, an organization token for managing teams and workspaces, and an audit trails token for reading the audit log. A missing or invalid token returns 401.
Permissions
What a call can do is decided by the token type and the team permissions behind it. Workspace actions map to named settings such as read runs, queue plans, apply runs, read or write variables, read or write state versions, lock and unlock, and admin. Beyond team permissions, the token type itself is a hard boundary: an organization token cannot create, apply, discard, or cancel a run, or read the JSON execution plan, no matter its team permissions. Those actions need a user or team token.
Versioning
Terraform Cloud serves a single v2 API and does not mint new version numbers for changes. Instead it publishes dated entries in a public API changelog, covering new endpoints, new attributes, and the occasional removal, so an integration tracks the changelog rather than pinning a version.
Data model
The API follows the JSON:API specification: requests and responses use the application/vnd.api+json media type and a top-level data object with type, id, attributes, and relationships. Core resources are organizations, projects, workspaces, runs, plans, applies, state versions, configuration versions, and variables, and many actions live under an /actions/ path, such as a run's apply or a workspace's lock.
Connect & authenticate

Connection & authentication methods.

How an app or AI agent connects to Terraform Cloud determines what it can reach. There is a route for making calls, a server that exposes Terraform tools to agents, and notification configurations that send events outward, each governed by the token behind it and the team permissions that token carries.

Ways to connect

v2 API (JSON:API)

The v2 API answers at app.terraform.io under /api/v2 and follows the JSON:API specification, so requests and responses use the application/vnd.api+json media type with a top-level data object. A call authenticates with a Bearer API token.

Best forConnecting an app or AI agent to Terraform Cloud.
Governed byThe token type and the team permissions it carries.
Docs ↗

MCP server (Model Context Protocol)

HashiCorp's official Terraform MCP server lets an agent call Terraform through the Model Context Protocol. It exposes Terraform Registry provider docs, modules, and Sentinel policies, and connects to HCP Terraform to list organizations and projects and to create, update, and delete workspaces with variables, tags, and run management. It supports the stdio and streamable HTTP transports, is at v1.0, and the source is at github.com/hashicorp/terraform-mcp-server.

Best forConnecting an app or AI agent to Terraform through MCP.
Governed byThe API token configured for the server and the permissions it carries.
Docs ↗

Notification configurations

A notification configuration on a workspace POSTs a payload to a chosen destination, a generic webhook, email, Slack, or Microsoft Teams, when a run or assessment event it is subscribed to fires. This lets an integration learn about run activity without polling.

Best forReceiving run events at an app or AI agent.
Governed byAdmin access to the workspace that owns the configuration.
Docs ↗
Authentication

User API token

A user token acts as that individual and carries every permission the user has across their teams and organizations. It is the only token type, alongside team tokens, that can create runs, apply, discard, cancel runs, and read the JSON execution plan.

TokenUser API token (Bearer)
Best forPersonal automation acting as a specific user
Docs ↗

Team API token

A team token acts as the team and carries that team's permissions, which is the recommended choice for CI and pipeline automation. Like a user token, it can queue and apply runs.

TokenTeam API token (Bearer)
Best forCI and pipeline automation scoped to a team
Docs ↗

Organization API token

An organization token is one per organization, for automating teams and workspaces. It cannot execute plans or applies, so it cannot create, apply, discard, or cancel a run, and it cannot read the JSON execution plan.

TokenOrganization API token (Bearer)
Best forManaging teams and workspaces, not running plans
Docs ↗

Audit trails token

An audit trails token is an organization-specific token used only to read the organization's audit trail of events. It does not grant access to the rest of the v2 API.

TokenAudit trails token (Bearer)
Best forReading an organization's audit trail
Docs ↗
Capability map

What an AI agent can do in Terraform Cloud.

The Terraform Cloud API is split into areas an agent can act on, such as workspaces, runs, state versions, variables, and projects. Each area has its own methods and its own permission setting, and a write here can queue, apply, or cancel real infrastructure changes.

Workspaces

7 endpoints

List, read, create, and update workspaces, lock and unlock them, force-unlock, and delete them.

Writes here change real workspace settings and can lock or remove a workspace.
View endpoints

Runs

6 endpoints

Create a run, list and read runs, and apply, discard, cancel, or force-cancel a run.

Writes here queue, apply, or stop real infrastructure changes.
View endpoints

Plans & applies

3 endpoints

Read a plan, read an apply, and retrieve the JSON execution plan for a run.

These are read-only views of what a run did or proposes to do.
View endpoints

State versions

4 endpoints

List state versions, read a state version, read the current state version, and create a new state version.

State holds resource data, and creating a version changes the workspace's current state.
View endpoints

Configuration versions

3 endpoints

List and read configuration versions and create a new one to upload Terraform configuration.

Creating a configuration version stages the code a future run will execute.
View endpoints

Variables

4 endpoints

List, create, update, and delete a workspace's Terraform and environment variables.

Variables feed real runs, and a write can change or expose configuration inputs.
View endpoints

Projects

5 endpoints

List, read, create, update, and delete projects that group workspaces.

Writes here change how workspaces are grouped and governed.
View endpoints

Organizations

3 endpoints

List organizations, read one, and update or destroy an organization.

Writes here change or remove an entire organization.
View endpoints

Teams

3 endpoints

List teams, read a team, and create, update, or delete a team.

Writes here change who has access and what they can do.
View endpoints

Notification configurations

3 endpoints

List, read, create, update, verify, and delete a workspace's run notification configurations.

Writes here change where run events are sent.
View endpoints
Endpoint reference

Every Terraform Cloud API method.

Filter by method, access, or permission, or search any path. Select a row for version detail, rate limits, the related webhook event, and the source.

MethodEndpointWhat it doesAccessPermissionVersion

Workspaces

List, read, create, and update workspaces, lock and unlock them, force-unlock, and delete them.7

Returns the workspaces the token's team can view. A 404 is returned for workspaces the token cannot access.

Acts onworkspace
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

A workspace can also be read by ID at /workspaces/:workspace_id.

Acts onworkspace
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the Manage all workspaces organization permission or an organization token.

Acts onworkspace
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Updating settings needs admin access to the workspace. A workspace can also be updated by name.

Acts onworkspace
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the lock/unlock workspace permission.

Acts onworkspace
Permission (capability)lock/unlock
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the lock/unlock workspace permission. Force-unlock, at the force-unlock action, needs admin access.

Acts onworkspace
Permission (capability)lock/unlock
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs admin access. A safe-delete action refuses to delete a workspace that still manages resources.

Acts onworkspace
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Runs

Create a run, list and read runs, and apply, discard, cancel, or force-cancel a run.6

Needs the queue plans permission. This action cannot use an organization token, only a user or team token.

Acts onrun
Permission (capability)queue plans
VersionAvailable since the API’s base version
Webhook eventrun:created
Rate limitStandard limits apply

Runs can also be listed across an organization at /organizations/:organization_name/runs.

Acts onrun
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

The run object's relationships point to its plan and apply IDs.

Acts onrun
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the apply runs permission. Cannot use an organization token. This is the action that changes real infrastructure.

Acts onrun
Permission (capability)apply runs
VersionAvailable since the API’s base version
Webhook eventrun:applying
Rate limitStandard limits apply

Needs the apply runs permission. Cannot use an organization token.

Acts onrun
Permission (capability)apply runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the apply runs permission. Force-cancel, at the force-cancel action, needs admin access to the workspace.

Acts onrun
Permission (capability)apply runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Plans & applies

Read a plan, read an apply, and retrieve the JSON execution plan for a run.3

A plan ID comes from a run's relationships.

Acts onplan
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Cannot use an organization token. Needs a user or team token with admin access to the workspace.

Acts onplan
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

There is no endpoint to list applies; an apply ID comes from a run's relationships.

Acts onapply
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

State versions

List state versions, read a state version, read the current state version, and create a new state version.4

Needs the read state versions permission for the workspace.

Acts onstate version
Permission (capability)read state versions
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read state versions permission for the workspace.

Acts onstate version
Permission (capability)read state versions
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read state versions permission for the workspace.

Acts onstate version
Permission (capability)read state versions
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read and write state versions permission, and the workspace must be locked by the calling token.

Acts onstate version
Permission (capability)write state versions
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Configuration versions

List and read configuration versions and create a new one to upload Terraform configuration.3

Needs the read runs permission.

Acts onconfiguration version
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read runs permission.

Acts onconfiguration version
Permission (capability)read runs
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the queue plans permission. The response returns an upload URL, and the configuration archive is then uploaded to that URL with a separate PUT.

Acts onconfiguration version
Permission (capability)queue plans
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Variables

List, create, update, and delete a workspace's Terraform and environment variables.4

Needs the read variables permission. A sensitive variable's value is write-once and is never returned.

Acts onvariable
Permission (capability)read variables
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read and write variables permission.

Acts onvariable
Permission (capability)write variables
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read and write variables permission.

Acts onvariable
Permission (capability)write variables
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the read and write variables permission.

Acts onvariable
Permission (capability)write variables
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Projects

List, read, create, update, and delete projects that group workspaces.5

Returns the projects the token's team can view.

Acts onproject
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Returns the project if the token's team can view it.

Acts onproject
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the Owners or Manage projects team permission, or an organization token.

Acts onproject
Permission (capability)Manage projects
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the Owners or Manage projects team permission, or an organization token.

Acts onproject
Permission (capability)Manage projects
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the Owners or Manage projects team permission. A project must be empty before it can be deleted.

Acts onproject
Permission (capability)Manage projects
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Organizations

List organizations, read one, and update or destroy an organization.3

Returns the organizations visible to the token.

Acts onorganization
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Returns the organization if the token can view it.

Acts onorganization
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs organization owner access.

Acts onorganization
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Teams

List teams, read a team, and create, update, or delete a team.3

Any member can view visible teams; only owners see the full set of secret teams.

Acts onteam
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Only organization owners, or an owners team token, can create or modify teams.

Acts onteam
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Only organization owners can delete a team. Teams can also be read by ID and updated with PATCH.

Acts onteam
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Notification configurations

List, read, create, update, verify, and delete a workspace's run notification configurations.3

Interacting with notification configurations needs admin access to the workspace.

Acts onnotification configuration
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs admin access. The destination can be a generic webhook, email, Slack, or Microsoft Teams, and it subscribes to chosen run and assessment triggers.

Acts onnotification configuration
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs admin access. A configuration can also be read with GET, updated with PATCH, and deleted with DELETE by ID.

Acts onnotification configuration
Permission (capability)admin
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply
No endpoints match those filters.
Webhooks

Webhook events.

Terraform Cloud can notify an app or AI agent when a run changes state, instead of the app repeatedly asking. A notification configuration on a workspace sends a payload to a chosen destination for the run and assessment events it is subscribed to.

EventWhat it signalsTriggered by
run:createdFires when a run enters the pending stage, after it has been queued./runs
run:planningFires when a run acquires the workspace lock and begins planning./runs
run:needs_attentionFires when a plan has changes and the run is paused awaiting confirmation./runs
run:applyingFires when a run enters the apply stage and begins changing infrastructure./runs/:run_id/actions/apply
run:completedFires when a run completes successfully./runs/:run_id/actions/apply
run:erroredFires when a run ends because of an error or a cancellation./runs
/runs/:run_id/actions/apply
assessment:driftedFires when a health assessment detects drift between real infrastructure and the recorded state.In-app only
assessment:check_failureFires when continuous validation checks fail during a health assessment.In-app only
assessment:failedFires when a health assessment itself fails to run.In-app only
No events match that search.
Rate limits & pagination

Rate limits, pagination & request size.

Terraform Cloud limits how fast an app or AI agent can call, through a per-second request rate that is counted per user or per IP address rather than per token.

Request rate

Terraform Cloud allows up to 30 requests per second to most endpoints, whether a request is authenticated or not. The limit is counted per user, or per IP address for unauthenticated calls, rather than per token, so several tokens belonging to the same user share one budget. Going over returns HTTP 429 with a JSON:API error. A few endpoints have their own lower thresholds, such as SMS operations at 5 requests per minute.

Pagination

List endpoints take page[number] and page[size] query parameters. The page size defaults to 20 and tops out at 100. Each response carries a links object with first, prev, next, and last URLs where they apply, and a meta.pagination object with the current page, page size, and total counts.

Request size

Responses are JSON:API documents using the application/vnd.api+json media type. Pages return at most 100 records. Configuration is uploaded as a .tar.gz archive to a separate upload URL returned when a configuration version is created, rather than in the JSON body.

Errors

Status codes & error handling.

The status codes an agent should handle, and what to do about each.

StatusCodeMeaningWhat to do
401UnauthorizedThe API token is absent or invalid.Send a valid Bearer token in the Authorization header.
404Not FoundThe resource does not exist, or the token's team cannot see it. Terraform Cloud returns 404 rather than 403 for resources a user cannot access, so it does not confirm a hidden resource exists.Confirm the path is correct and that the token's team has permission to reach the resource.
422Unprocessable EntityThe request was understood but failed validation, such as a malformed JSON:API body or an invalid attribute. The JSON:API errors array names what failed.Read the errors array, correct the named field, and resend.
429Too Many RequestsThe rate limit was exceeded. Limits are counted per user, or per IP address for unauthenticated calls, not per token.Slow the request rate to within 30 requests per second and retry.
Versioning & freshness

Version history.

Terraform Cloud serves a single v2 API and ships dated changes through a public API changelog rather than minting new version numbers.

Version history

What changed, and when

Latest versionv2
v2Current version
The stable v2 API, updated through a dated changelog

Terraform Cloud serves a single v2 API and ships changes through a public, dated API changelog rather than minting new version numbers. The entries below are recent notable changes from that changelog.

What changed
  • 2026-05-14: removed the concurrency-override attribute from feature set responses.
  • 2026-05-13: added the Actions API for listing actions and inspecting their invocation history by run.
  • 2026-04-24: added Metrics Service tokens.
  • 2026-04: added project-level notification configuration endpoints.
2025-12-18Feature update
Stack registry components

Documented new /registry-components endpoints for reading, publishing, updating, and deleting Stack component configurations in an organization's private registry.

What changed
  • Added /registry-components endpoints for Stack component configurations.
  • 2025-10-31: added filtering parameters when listing projects.
2025-07-11Feature update
Workspace and project defaults, agent pool scoping

Updated workspace defaults to match project settings rather than the organization default, and extended agent pool scoping with allowed projects and workspace exclusions.

What changed
  • A workspace's default execution mode now matches its project, not the organization.
  • Agent pools gained allowed-project scoping and workspace exclusions.
  • 2025-05: added an agent-pool relationship to the run task API and enabled module version revocation.
2025-03-20Feature update
Multiple team tokens

Documented support for multiple team tokens per team, distinguished from the single legacy team token.

What changed
  • A team can now hold multiple, named API tokens.
  • 2024-11-19: clarified tag-bindings and effective-tag-bindings and added PATCH endpoints for tag binding management.

The v2 API is stable, and notable additions and changes are published with dates in the changelog.

HCP Terraform API changelog ↗
Questions

Terraform Cloud API, answered.

What are the token types, and which can run a plan or apply?+
There are four: user, team, organization, and audit trails tokens, all sent as a Bearer token. A user or team token can create a run and apply, discard, or cancel it. An organization token cannot execute plans or applies, so it is for managing teams and workspaces rather than running infrastructure changes, and an audit trails token only reads the audit log.
Why am I getting a 404 when the workspace exists?+
A 404 is usually a permissions problem rather than a missing resource. Terraform Cloud returns 404 Not Found for resources a user does not have access to, as well as for resources that do not exist, so that it does not confirm a hidden resource exists. The fix is to confirm the token's team has the right permission, such as read runs for the workspace.
What are the rate limits?+
Most endpoints allow up to 30 requests per second, for both authenticated and unauthenticated calls. The count is per user, or per IP address when there is no token, not per token, so several tokens for the same user share one budget. Exceeding it returns HTTP 429. A few endpoints, such as SMS operations, have their own lower limits.
How does the API handle versioning?+
There is one stable v2 API, and HashiCorp does not issue new version numbers for changes. New endpoints, attributes, and removals are announced with dates in the public API changelog, so an integration follows the changelog rather than pinning a version string. Newer features that are not yet generally available are noted as beta in the docs.
How do I receive run events instead of polling?+
A notification configuration on a workspace POSTs a payload to a destination, a generic webhook, email, Slack, or Microsoft Teams, when a subscribed event fires. The run triggers are run:created, run:planning, run:needs_attention, run:applying, run:completed, and run:errored, plus assessment triggers for drift and check failures. Creating or changing a notification configuration needs admin access to the workspace.
Is there an official MCP server for AI agents?+
Yes. HashiCorp publishes an official Terraform MCP server, at v1.0, that lets an AI agent reach the Terraform Registry for provider docs, modules, and Sentinel policies, and connects to HCP Terraform to list organizations and projects and to create, update, and delete workspaces with their variables, tags, and runs. It runs over the stdio or streamable HTTP transport and authenticates with an API token.
How do I upload Terraform configuration through the API?+
First create a configuration version on the workspace, which needs the queue plans permission and returns an upload URL. Then upload the configuration as a .tar.gz archive to that URL with a separate request. A run can then execute against the uploaded configuration version. Reading and listing configuration versions only needs the read runs permission.
Related

More developer API guides for agents

What is Bollard AI?

Control what every AI agent can do in Terraform Cloud.

Bollard AI sits between a team's AI agents and Terraform Cloud. Grant each agent exactly the access it needs, read or write, resource by resource, and every call is checked and logged.

  • Set read, write, or full access per agent, never a shared Terraform Cloud token.
  • Denied by default, so an agent reaches only what has been explicitly allowed.
  • Every call recorded in plain English: who, what, where, and the decision.
Terraform Cloud
Infra Agent
Read workspaces and runs ResourceOffReadFull use
Apply a run ActionOffReadFull use
Manage variables ResourceOffReadFull use
Per-agent access, set in Bollard AI, not in Terraform Cloud