openapi: 3.1.0 info: title: HCP Terraform API description: >- The HCP Terraform API provides programmatic access to HCP Terraform features including workspace management, runs, state versions, policies, teams, and organizations. The API follows the JSON API specification. version: '2.0' contact: name: HashiCorp Support url: https://support.hashicorp.com license: name: Business Source License 1.1 url: https://github.com/hashicorp/terraform/blob/main/LICENSE servers: - url: https://app.terraform.io/api/v2 description: HCP Terraform Production API security: - bearerAuth: [] tags: - name: Organizations description: Manage HCP Terraform organizations - name: Workspaces description: Manage infrastructure workspaces - name: Runs description: Manage Terraform runs and plan/apply lifecycle - name: State Versions description: Manage workspace state versions - name: Teams description: Manage teams and memberships - name: Policies description: Manage Sentinel and OPA policies - name: Variables description: Manage workspace and variable sets - name: Projects description: Manage projects within organizations paths: /organizations: get: operationId: ListOrganizations summary: List Organizations description: Lists all organizations accessible by the current token. tags: - Organizations parameters: - name: page[number] in: query schema: type: integer description: Page number for pagination - name: page[size] in: query schema: type: integer description: Number of results per page (max 100) - name: q in: query schema: type: string description: Search query to filter organizations by name responses: '200': description: A list of organizations content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationList' post: operationId: CreateOrganization summary: Create an Organization description: Creates a new organization. tags: - Organizations requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationCreateRequest' responses: '201': description: Organization created content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationResponse' /organizations/{organization_name}: get: operationId: GetOrganization summary: Get an Organization description: Retrieves details for a specific organization. tags: - Organizations parameters: - name: organization_name in: path required: true schema: type: string description: The name of the organization responses: '200': description: Organization details content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationResponse' patch: operationId: UpdateOrganization summary: Update an Organization description: Updates settings for an existing organization. tags: - Organizations parameters: - name: organization_name in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationUpdateRequest' responses: '200': description: Organization updated content: application/vnd.api+json: schema: $ref: '#/components/schemas/OrganizationResponse' delete: operationId: DeleteOrganization summary: Delete an Organization description: Destroys an organization. tags: - Organizations parameters: - name: organization_name in: path required: true schema: type: string responses: '204': description: Organization deleted /organizations/{organization_name}/workspaces: get: operationId: ListWorkspaces summary: List Workspaces description: Lists workspaces within an organization. tags: - Workspaces parameters: - name: organization_name in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer - name: search[name] in: query schema: type: string description: Filter workspaces by name - name: search[tags] in: query schema: type: string description: Filter workspaces by tags - name: filter[project][id] in: query schema: type: string description: Filter workspaces by project ID responses: '200': description: List of workspaces content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceList' post: operationId: CreateWorkspace summary: Create a Workspace description: Creates a new workspace within an organization. tags: - Workspaces parameters: - name: organization_name in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceCreateRequest' responses: '201': description: Workspace created content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceResponse' /workspaces/{workspace_id}: get: operationId: GetWorkspace summary: Get a Workspace description: Retrieves details for a specific workspace. tags: - Workspaces parameters: - name: workspace_id in: path required: true schema: type: string responses: '200': description: Workspace details content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceResponse' patch: operationId: UpdateWorkspace summary: Update a Workspace description: Updates settings for an existing workspace. tags: - Workspaces parameters: - name: workspace_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceUpdateRequest' responses: '200': description: Workspace updated content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceResponse' delete: operationId: DeleteWorkspace summary: Delete a Workspace description: Destroys a workspace and all its contents. tags: - Workspaces parameters: - name: workspace_id in: path required: true schema: type: string responses: '204': description: Workspace deleted /workspaces/{workspace_id}/actions/lock: post: operationId: LockWorkspace summary: Lock a Workspace description: Locks a workspace to prevent runs. tags: - Workspaces parameters: - name: workspace_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: type: object properties: reason: type: string responses: '200': description: Workspace locked content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceResponse' /workspaces/{workspace_id}/actions/unlock: post: operationId: UnlockWorkspace summary: Unlock a Workspace description: Unlocks a workspace to allow runs. tags: - Workspaces parameters: - name: workspace_id in: path required: true schema: type: string responses: '200': description: Workspace unlocked content: application/vnd.api+json: schema: $ref: '#/components/schemas/WorkspaceResponse' /runs: post: operationId: CreateRun summary: Create a Run description: Creates a new run for a workspace. tags: - Runs requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/RunCreateRequest' responses: '201': description: Run created content: application/vnd.api+json: schema: $ref: '#/components/schemas/RunResponse' /runs/{run_id}: get: operationId: GetRun summary: Get a Run description: Retrieves details for a specific run. tags: - Runs parameters: - name: run_id in: path required: true schema: type: string responses: '200': description: Run details content: application/vnd.api+json: schema: $ref: '#/components/schemas/RunResponse' /runs/{run_id}/actions/apply: post: operationId: ApplyRun summary: Apply a Run description: Applies a run that is paused waiting for confirmation. tags: - Runs parameters: - name: run_id in: path required: true schema: type: string requestBody: content: application/vnd.api+json: schema: type: object properties: comment: type: string responses: '202': description: Run apply initiated /runs/{run_id}/actions/discard: post: operationId: DiscardRun summary: Discard a Run description: Discards a run that has not yet been applied. tags: - Runs parameters: - name: run_id in: path required: true schema: type: string requestBody: content: application/vnd.api+json: schema: type: object properties: comment: type: string responses: '202': description: Run discarded /runs/{run_id}/actions/cancel: post: operationId: CancelRun summary: Cancel a Run description: Cancels a run that is currently in progress. tags: - Runs parameters: - name: run_id in: path required: true schema: type: string requestBody: content: application/vnd.api+json: schema: type: object properties: comment: type: string responses: '202': description: Run cancelled /workspaces/{workspace_id}/runs: get: operationId: ListWorkspaceRuns summary: List Workspace Runs description: Lists all runs for a given workspace. tags: - Runs parameters: - name: workspace_id in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer - name: filter[status] in: query schema: type: string description: Filter runs by status responses: '200': description: List of runs content: application/vnd.api+json: schema: $ref: '#/components/schemas/RunList' /workspaces/{workspace_id}/state-versions: get: operationId: ListStateVersions summary: List State Versions description: Lists state versions for a workspace. tags: - State Versions parameters: - name: workspace_id in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer responses: '200': description: List of state versions content: application/vnd.api+json: schema: $ref: '#/components/schemas/StateVersionList' post: operationId: CreateStateVersion summary: Create a State Version description: Creates a new state version for a workspace. tags: - State Versions parameters: - name: workspace_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/StateVersionCreateRequest' responses: '200': description: State version created content: application/vnd.api+json: schema: $ref: '#/components/schemas/StateVersionResponse' /state-versions/{state_version_id}: get: operationId: GetStateVersion summary: Get a State Version description: Retrieves details for a specific state version. tags: - State Versions parameters: - name: state_version_id in: path required: true schema: type: string responses: '200': description: State version details content: application/vnd.api+json: schema: $ref: '#/components/schemas/StateVersionResponse' /organizations/{organization_name}/teams: get: operationId: ListTeams summary: List Teams description: Lists all teams in an organization. tags: - Teams parameters: - name: organization_name in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer responses: '200': description: List of teams content: application/vnd.api+json: schema: $ref: '#/components/schemas/TeamList' post: operationId: CreateTeam summary: Create a Team description: Creates a new team within an organization. tags: - Teams parameters: - name: organization_name in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/TeamCreateRequest' responses: '201': description: Team created content: application/vnd.api+json: schema: $ref: '#/components/schemas/TeamResponse' /teams/{team_id}: get: operationId: GetTeam summary: Get a Team description: Retrieves details for a specific team. tags: - Teams parameters: - name: team_id in: path required: true schema: type: string responses: '200': description: Team details content: application/vnd.api+json: schema: $ref: '#/components/schemas/TeamResponse' delete: operationId: DeleteTeam summary: Delete a Team description: Deletes a team. tags: - Teams parameters: - name: team_id in: path required: true schema: type: string responses: '204': description: Team deleted /organizations/{organization_name}/policies: get: operationId: ListPolicies summary: List Policies description: Lists all policies in an organization. tags: - Policies parameters: - name: organization_name in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer responses: '200': description: List of policies content: application/vnd.api+json: schema: $ref: '#/components/schemas/PolicyList' post: operationId: CreatePolicy summary: Create a Policy description: Creates a new Sentinel or OPA policy. tags: - Policies parameters: - name: organization_name in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/PolicyCreateRequest' responses: '201': description: Policy created content: application/vnd.api+json: schema: $ref: '#/components/schemas/PolicyResponse' /policies/{policy_id}: get: operationId: GetPolicy summary: Get a Policy description: Retrieves details for a specific policy. tags: - Policies parameters: - name: policy_id in: path required: true schema: type: string responses: '200': description: Policy details content: application/vnd.api+json: schema: $ref: '#/components/schemas/PolicyResponse' delete: operationId: DeletePolicy summary: Delete a Policy description: Deletes a policy. tags: - Policies parameters: - name: policy_id in: path required: true schema: type: string responses: '204': description: Policy deleted /organizations/{organization_name}/projects: get: operationId: ListProjects summary: List Projects description: Lists all projects within an organization. tags: - Projects parameters: - name: organization_name in: path required: true schema: type: string - name: page[number] in: query schema: type: integer - name: page[size] in: query schema: type: integer - name: filter[name] in: query schema: type: string responses: '200': description: List of projects content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectList' post: operationId: CreateProject summary: Create a Project description: Creates a new project within an organization. tags: - Projects parameters: - name: organization_name in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectCreateRequest' responses: '201': description: Project created content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectResponse' /projects/{project_id}: get: operationId: GetProject summary: Get a Project description: Retrieves details for a specific project. tags: - Projects parameters: - name: project_id in: path required: true schema: type: string responses: '200': description: Project details content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectResponse' patch: operationId: UpdateProject summary: Update a Project description: Updates an existing project. tags: - Projects parameters: - name: project_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectUpdateRequest' responses: '200': description: Project updated content: application/vnd.api+json: schema: $ref: '#/components/schemas/ProjectResponse' delete: operationId: DeleteProject summary: Delete a Project description: Deletes a project. tags: - Projects parameters: - name: project_id in: path required: true schema: type: string responses: '204': description: Project deleted /workspaces/{workspace_id}/vars: get: operationId: ListWorkspaceVariables summary: List Workspace Variables description: Lists all variables for a workspace. tags: - Variables parameters: - name: workspace_id in: path required: true schema: type: string responses: '200': description: List of variables content: application/vnd.api+json: schema: $ref: '#/components/schemas/VariableList' post: operationId: CreateWorkspaceVariable summary: Create a Workspace Variable description: Creates a new variable for a workspace. tags: - Variables parameters: - name: workspace_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/VariableCreateRequest' responses: '201': description: Variable created content: application/vnd.api+json: schema: $ref: '#/components/schemas/VariableResponse' /workspaces/{workspace_id}/vars/{variable_id}: patch: operationId: UpdateWorkspaceVariable summary: Update a Workspace Variable description: Updates an existing workspace variable. tags: - Variables parameters: - name: workspace_id in: path required: true schema: type: string - name: variable_id in: path required: true schema: type: string requestBody: required: true content: application/vnd.api+json: schema: $ref: '#/components/schemas/VariableUpdateRequest' responses: '200': description: Variable updated content: application/vnd.api+json: schema: $ref: '#/components/schemas/VariableResponse' delete: operationId: DeleteWorkspaceVariable summary: Delete a Workspace Variable description: Deletes a workspace variable. tags: - Variables parameters: - name: workspace_id in: path required: true schema: type: string - name: variable_id in: path required: true schema: type: string responses: '204': description: Variable deleted components: securitySchemes: bearerAuth: type: http scheme: bearer description: Bearer token authentication. Use organization, team, or user tokens. schemas: OrganizationList: type: object properties: data: type: array items: $ref: '#/components/schemas/Organization' meta: $ref: '#/components/schemas/PaginationMeta' OrganizationResponse: type: object properties: data: $ref: '#/components/schemas/Organization' Organization: type: object properties: id: type: string type: type: string enum: [organizations] attributes: type: object properties: name: type: string email: type: string created-at: type: string format: date-time session-timeout: type: integer session-remember: type: integer collaborator-auth-policy: type: string plan-expired: type: boolean plan-is-trial: type: boolean plan-is-enterprise: type: boolean OrganizationCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [organizations] attributes: type: object required: [name, email] properties: name: type: string email: type: string OrganizationUpdateRequest: type: object properties: data: type: object properties: type: type: string enum: [organizations] attributes: type: object properties: email: type: string session-timeout: type: integer WorkspaceList: type: object properties: data: type: array items: $ref: '#/components/schemas/Workspace' meta: $ref: '#/components/schemas/PaginationMeta' WorkspaceResponse: type: object properties: data: $ref: '#/components/schemas/Workspace' Workspace: type: object properties: id: type: string type: type: string enum: [workspaces] attributes: type: object properties: name: type: string description: type: string auto-apply: type: boolean locked: type: boolean execution-mode: type: string enum: [remote, local, agent] terraform-version: type: string working-directory: type: string created-at: type: string format: date-time updated-at: type: string format: date-time WorkspaceCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [workspaces] attributes: type: object required: [name] properties: name: type: string description: type: string auto-apply: type: boolean execution-mode: type: string terraform-version: type: string WorkspaceUpdateRequest: type: object properties: data: type: object properties: type: type: string enum: [workspaces] attributes: type: object properties: name: type: string description: type: string auto-apply: type: boolean execution-mode: type: string RunList: type: object properties: data: type: array items: $ref: '#/components/schemas/Run' meta: $ref: '#/components/schemas/PaginationMeta' RunResponse: type: object properties: data: $ref: '#/components/schemas/Run' Run: type: object properties: id: type: string type: type: string enum: [runs] attributes: type: object properties: status: type: string enum: [pending, fetching, planning, planned, applying, applied, discarded, canceled, errored, policy_checked, policy_override, force_canceled] message: type: string is-destroy: type: boolean auto-apply: type: boolean created-at: type: string format: date-time RunCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [runs] attributes: type: object properties: message: type: string is-destroy: type: boolean auto-apply: type: boolean relationships: type: object properties: workspace: type: object properties: data: type: object properties: type: type: string id: type: string StateVersionList: type: object properties: data: type: array items: $ref: '#/components/schemas/StateVersion' meta: $ref: '#/components/schemas/PaginationMeta' StateVersionResponse: type: object properties: data: $ref: '#/components/schemas/StateVersion' StateVersion: type: object properties: id: type: string type: type: string enum: [state-versions] attributes: type: object properties: vcs-commit-sha: type: string vcs-commit-url: type: string created-at: type: string format: date-time serial: type: integer size: type: integer hosted-state-download-url: type: string StateVersionCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [state-versions] attributes: type: object required: [serial, md5, state] properties: serial: type: integer md5: type: string state: type: string description: Base64-encoded state file TeamList: type: object properties: data: type: array items: $ref: '#/components/schemas/Team' meta: $ref: '#/components/schemas/PaginationMeta' TeamResponse: type: object properties: data: $ref: '#/components/schemas/Team' Team: type: object properties: id: type: string type: type: string enum: [teams] attributes: type: object properties: name: type: string users-count: type: integer visibility: type: string TeamCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [teams] attributes: type: object required: [name] properties: name: type: string visibility: type: string PolicyList: type: object properties: data: type: array items: $ref: '#/components/schemas/Policy' meta: $ref: '#/components/schemas/PaginationMeta' PolicyResponse: type: object properties: data: $ref: '#/components/schemas/Policy' Policy: type: object properties: id: type: string type: type: string enum: [policies] attributes: type: object properties: name: type: string description: type: string enforcement-level: type: string enum: [advisory, soft-mandatory, hard-mandatory] kind: type: string enum: [sentinel, opa] PolicyCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [policies] attributes: type: object required: [name] properties: name: type: string description: type: string enforcement-level: type: string kind: type: string ProjectList: type: object properties: data: type: array items: $ref: '#/components/schemas/Project' meta: $ref: '#/components/schemas/PaginationMeta' ProjectResponse: type: object properties: data: $ref: '#/components/schemas/Project' Project: type: object properties: id: type: string type: type: string enum: [projects] attributes: type: object properties: name: type: string description: type: string ProjectCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [projects] attributes: type: object required: [name] properties: name: type: string description: type: string ProjectUpdateRequest: type: object properties: data: type: object properties: attributes: type: object properties: name: type: string description: type: string VariableList: type: object properties: data: type: array items: $ref: '#/components/schemas/Variable' VariableResponse: type: object properties: data: $ref: '#/components/schemas/Variable' Variable: type: object properties: id: type: string type: type: string enum: [vars] attributes: type: object properties: key: type: string value: type: string description: type: string category: type: string enum: [terraform, env] hcl: type: boolean sensitive: type: boolean VariableCreateRequest: type: object required: [data] properties: data: type: object properties: type: type: string enum: [vars] attributes: type: object required: [key, category] properties: key: type: string value: type: string description: type: string category: type: string enum: [terraform, env] hcl: type: boolean sensitive: type: boolean VariableUpdateRequest: type: object properties: data: type: object properties: attributes: type: object properties: key: type: string value: type: string description: type: string PaginationMeta: type: object properties: pagination: type: object properties: current-page: type: integer prev-page: type: integer nullable: true next-page: type: integer nullable: true last-page: type: integer total-count: type: integer