• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Terraform
  • Install
  • Tutorials
    • About the Docs
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • CDK for Terraform
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
  • Registry(opens in new tab)
  • Try Cloud(opens in new tab)
  • Sign up
Terraform Home

Terraform Cloud

Skip to main content
  • Terraform Cloud
  • Plans and Features
  • Getting Started
    • Overview
    • Account
    • Agent Pools
    • Agent Tokens
    • Applies
    • Audit Trails
    • Assessment Results
    • Comments
    • Configuration Versions
    • Cost Estimates
    • Feature Sets
    • Invoices
    • IP Ranges
    • Notification Configurations
    • OAuth Clients
    • OAuth Tokens
    • Organizations
    • Organization Memberships
    • Organization Tags
    • Organization Tokens
    • Plan Exports
    • Plans
    • Policies
    • Policy Checks
    • Policy Sets
    • Policy Set Parameters
    • Projects
    • Project Team Access
    • Runs
    • Run Triggers
    • SSH Keys
    • State Versions
    • State Version Outputs
    • Subscriptions
    • Team Membership
    • Team Tokens
    • Teams
    • User Tokens
    • Users
    • Variables
    • VCS Events
    • Workspaces
    • Workspace-Specific Variables
    • Workspace Team Access
    • Workspace Resources
    • Variable Sets
    • Changelog
    • Stability Policy
  • Migrating to Terraform Cloud

  • Terraform Cloud Agents

  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  • Terraform Registry
    (opens in new tab)
  1. Developer
  2. Terraform
  3. Terraform Cloud
  4. API
  5. Configuration Versions

»Configuration Versions API

Note: Before working with the runs or configuration versions APIs, read the API-driven run workflow page, which includes both a full overview of this workflow and a walkthrough of a simple implementation of it.

A configuration version (configuration-version) is a resource used to reference the uploaded configuration files. It is associated with the run to use the uploaded configuration files for performing the plan and apply.

You need read runs permission to list and view configuration versions for a workspace, and you need queue plans permission to create new configuration versions. Refer to the permissions documentation for more details.

Attributes

Configuration Version States

The configuration version state is found in data.attributes.status, and you can reference the following list of possible states.

A configuration version created through the API or CLI can only be used in runs if it is in an uploaded state. A configuration version created through a linked VCS repository may also be used in runs if it is in an archived state.

StateDescription
pendingThe initial status of a configuration version after it has been created. Pending configuration versions cannot be used to create new runs.
fetchingFor configuration versions created from a commit to a connected VCS repository, Terraform Cloud is currently fetching the associated files from VCS.
uploadedThe configuration version is fully processed and can be used in runs.
archivedAll immediate runs are complete and Terraform Cloud has discarded the files associated with this configuration version. If the configuration version was created through a connected VCS repository, it can still be used in new runs. In those cases, Terraform Cloud will re-fetch the files from VCS.
erroredTerraform Cloud could not process this configuration version, and it cannot be used to create new runs. You can try again by pushing a new commit to your linked VCS repository or creating a new configuration version with the API or CLI.

List Configuration Versions

GET /workspaces/:workspace_id/configuration-versions

ParameterDescription
:workspace_idThe ID of the workspace to list configurations from. Obtain this from the workspace settings or the Show Workspace endpoint.

Query Parameters

This endpoint supports pagination with standard URL query parameters. Remember to percent-encode [ as %5B and ] as %5D if your tooling doesn't automatically encode URLs.

ParameterDescription
page[number]Optional. If omitted, the endpoint will return the first page.
page[size]Optional. If omitted, the endpoint will return 20 configuration versions per page.

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request GET \
  https://app.terraform.io/api/v2/workspaces/ws-2Qhk7LHgbMrm3grF/configuration-versions

Sample Response

{
  "data": [
    {
      "id": "cv-ntv3HbhJqvFzamy7",
      "type": "configuration-versions",
      "attributes": {
        "error": null,
        "error-message": null,
        "source": "gitlab",
        "speculative":false,
        "status": "uploaded",
        "status-timestamps": {}
      },
      "relationships": {
        "ingress-attributes": {
          "data": {
            "id": "ia-i4MrTxmQXYxH2nYD",
            "type": "ingress-attributes"
          },
          "links": {
            "related":
              "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/ingress-attributes"
          }
        }
      },
      "links": {
        "self": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7",
        "download": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/download"
      }
    }
  ]
}

Show a Configuration Version

GET /configuration-versions/:configuration-id

ParameterDescription
:configuration-idThe id of the configuration to show.

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request GET \
  https://app.terraform.io/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7

Sample Response

{
  "data": {
    "id": "cv-ntv3HbhJqvFzamy7",
    "type": "configuration-versions",
    "attributes": {
      "error": null,
      "error-message": null,
      "source": "gitlab",
      "speculative":false,
      "status": "uploaded",
      "status-timestamps": {}
    },
    "relationships": {
      "ingress-attributes": {
        "data": {
          "id": "ia-i4MrTxmQXYxH2nYD",
          "type": "ingress-attributes"
        },
        "links": {
          "related":
            "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/ingress-attributes"
        }
      }
    },
    "links": {
      "self": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7",
      "download": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/download"
    }
  }
}

Show a Configuration Version's Commit Information

An ingress attributes resource (ingress-attributes) is used to reference commit information for configuration versions created in a workspace with a VCS repository.

GET /configuration-versions/:configuration-id/ingress-attributes

ParameterDescription
:configuration-idThe id of the configuration to show.

Ingress attributes can also be fetched as part of a query to a particular configuration version via include:

GET /configuration-versions/:configuration-id?include=ingress-attributes

ParameterDescription
:configuration-idThe id of the configuration to show.

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request GET \
  https://app.terraform.io/api/v2/configuration-versions/cv-TrHjxIzad9Ae9i8x/ingress-attributes

Sample Response

{
  "data": {
    "id": "ia-zqHjxJzaB9Ae6i9t",
    "type": "ingress-attributes",
    "attributes": {
      "branch": "add-cool-stuff",
      "clone-url": "https://github.com/hashicorp/foobar.git",
      "commit-message": "Adding really cool infrastructure",
      "commit-sha": "1e1c1018d1bbc0b8517d072718e0d87c1a0eda95",
      "commit-url": "https://github.com/hashicorp/foobar/commit/1e1c1018d1bbc0b8517d072718e0d87c1a0eda95",
      "compare-url": "https://github.com/hashicorp/foobar/pull/163",
      "identifier": "hashicorp/foobar",
      "is-pull-request": true,
      "on-default-branch": false,
      "pull-request-number": 163,
      "pull-request-url": "https://github.com/hashicorp/foobar/pull/163",
      "pull-request-title": "Adding really cool infrastructure",
      "pull-request-body": "These are changes to add really cool stuff. We should absolutely merge this.",
      "tag": null,
      "sender-username": "chrisarcand",
      "sender-avatar-url": "https://avatars.githubusercontent.com/u/2430490?v=4",
      "sender-html-url": "https://github.com/chrisarcand"
    },
    "relationships": {
      "created-by": {
        "data": {
          "id": "user-PQk2Z3dfXAax18P6s",
          "type": "users"
        },
        "links": {
          "related": "/api/v2/ingress-attributes/ia-zqHjxJzaB9Ae6i9t/created-by"
        }
      }
    },
    "links": {
      "self": "/api/v2/ingress-attributes/ia-zqHjxJzaB9Ae6i9t"
    }
  }
}

Create a Configuration Version

POST /workspaces/:workspace_id/configuration-versions

ParameterDescription
:workspace_idThe ID of the workspace to create the new configuration version in. Obtain this from the workspace settings or the Show Workspace endpoint.

Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.

Request Body

This POST endpoint requires a JSON object with the following properties as a request payload.

Properties without a default value are required.

Key pathTypeDefaultDescription
data.attributes.auto-queue-runsbooleantrueWhen true, runs are queued automatically when the configuration version is uploaded.
data.attributes.speculativebooleanfalseWhen true, this configuration version may only be used to create runs which are speculative, that is, can neither be confirmed nor applied.

Sample Payload

{
  "data": {
    "type": "configuration-versions",
    "attributes": {
      "auto-queue-runs": true
    }
  }
}

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  --data @payload.json \
  https://app.terraform.io/api/v2/workspaces/ws-2Qhk7LHgbMrm3grF/configuration-versions

Sample Response

{
  "data": {
    "id": "cv-UYwHEakurukz85nW",
    "type": "configuration-versions",
    "attributes": {
      "auto-queue-runs": true,
      "error": null,
      "error-message": null,
      "source": "tfe-api",
      "speculative":false,
      "status": "pending",
      "status-timestamps": {},
      "upload-url":
        "https://archivist.terraform.io/v1/object/9224c6b3-2e14-4cd7-adff-ed484d7294c2"
    },
    "relationships": {
      "ingress-attributes": {
        "data": null,
        "links": {
          "related":
            "/api/v2/configuration-versions/cv-UYwHEakurukz85nW/ingress-attributes"
        }
      }
    },
    "links": { "self": "/api/v2/configuration-versions/cv-UYwHEakurukz85nW" }
  }
}

Configuration Files Upload URL

Once a configuration version is created, use the upload-url attribute to upload configuration files associated with that version. The upload-url attribute is only provided in the response when creating configuration versions.

Upload Configuration Files

Note: If auto-queue-runs was either not provided or set to true during creation of the configuration version, a run using this configuration version will be automatically queued on the workspace. If auto-queue-runs was set to false explicitly, then it is necessary to create a run on the workspace manually after the configuration version is uploaded.

PUT https://archivist.terraform.io/v1/object/<UNIQUE OBJECT ID>

The URL is provided in the upload-url attribute when creating a configuration-versions resource. After creation, the URL is hidden on the resource and no longer available.

Sample Request

@filename is the name of configuration file you wish to upload.

curl \
  --header "Content-Type: application/octet-stream" \
  --request PUT \
  --data-binary @filename \
  https://archivist.terraform.io/v1/object/4c44d964-eba7-4dd5-ad29-1ece7b99e8da

Archive a Configuration Version

POST /configuration-versions/:configuration_version_id/actions/archive

ParameterDescription
configuration_version_idThe ID of the configuration version to archive.

This endpoint notifies Terraform Cloud to discard the uploaded .tar.gz file associated with this configuration version. This endpoint can only archive configuration versions that were created with the API or CLI, are in an uploaded state, and have no runs in progress. Otherwise, calling this endpoint will result in an error.

Terraform Cloud automatically archives configuration versions created through VCS when associated runs are complete and then re-fetches the files for subsequent runs.

StatusResponseReason(s)
202noneSuccessfully initiated the archive process.
409JSON API error objectConfiguration version was in a non-archivable state or the configuration version was created with VCS and cannot be archived through the API.
404JSON API error objectConfiguration version was not found or user not authorized.

Request Body

This POST endpoint does not take a request body.

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  https://app.terraform.io/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/actions/archive

Download Configuration Files

GET /configuration-versions/:configuration_version_id/download

ParameterDescription
configuration_version_idThe ID of the configuration version to download.

GET /runs/:run_id/configuration-version/download

ParameterDescription
run_idThe ID of the run whose configuration version should be downloaded.

These endpoints generate a temporary URL to the location of the configuration version in a .tar.gz archive, and then redirect to that link. If using a client that can follow redirects, you can use these endpoints to save the .tar.gz archive locally without needing to save the temporary URL. These endpoints will return an error if attempting to download a configuration version that is not in an uploaded state.

StatusResponseReason
302HTTP RedirectConfiguration version found and temporary download URL generated
404JSON API error objectConfiguration version not found, or specified configuration version is not uploaded, or user unauthorized to perform action

Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --location \
  https://app.terraform.io/api/v2/configuration-versions/cv-C6Py6WQ1cUXQX2x2/download \
  > export.tar.gz

Available Related Resources

The GET endpoints above can optionally return related resources, if requested with the include query parameter. The following resource types are available:

Resource NameDescription
ingress_attributesThe commit information used in the configuration.
runThe run created by the configuration.
Edit this page on GitHub

On this page

  1. Configuration Versions API
  2. Attributes
  3. List Configuration Versions
  4. Show a Configuration Version
  5. Show a Configuration Version's Commit Information
  6. Create a Configuration Version
  7. Upload Configuration Files
  8. Archive a Configuration Version
  9. Download Configuration Files
  10. Available Related Resources
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)