content large_stringlengths 3 20.5k | url large_stringlengths 54 193 | branch large_stringclasses 4 values | source large_stringclasses 42 values | embeddings listlengths 384 384 | score float64 -0.21 0.65 |
|---|---|---|---|---|---|
[vcs]: /terraform/cloud-docs/vcs # Add public providers and modules to the HCP Terraform private registry You can add providers and modules from the public [Terraform Registry](/terraform/registry) to your HCP Terraform private registry. The private registry stores a pointer to these public providers and modules so that you can view their data from within HCP Terraform. This lets you clearly designate which public providers and modules are recommended for the organization and makes their supporting documentation and examples centrally accessible. -> \*\*Note:\*\* Your Terraform Enterprise instance must allow access to `registry.terraform.io` and `https://yy0ffni7mf-dsn.algolia.net/`. [permissions-citation]: #intentionally-unused---keep-for-maintainers You can add providers and modules through the UI as detailed below or through the [Registry Providers API](/terraform/cloud-docs/api-docs/private-registry/providers) and the [Registry Modules API](/terraform/cloud-docs/api-docs/private-registry/modules#create-a-module-with-no-vcs-connection-). ## Requirements All members of an organization can view and use public providers and modules. Members on the [owners team](/terraform/cloud-docs/users-teams-organizations/permissions/organization#organization-owners) and teams with [Manage Private Registry permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-private-registry) can add and delete them from the private registry. When adding modules from the public registry to the private registry on Terraform Enterprise, you can only add modules hosted on GitHub that use IPv4 addresses. This is because GitHub does not support IPv6. Refer to the [Terraform Enterprise deployment overview](/terraform/enterprise/deploy) for additional information. ## Adding a Public Provider or Module > \*\*Hands-on:\*\* Try the [Add Public Providers and Modules to your Private Registry](/terraform/tutorials/modules/private-registry-add) tutorial and [Share Modules in the Private Registry](/terraform/tutorials/modules/module-private-registry-share) tutorials. To add a public provider or module: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization you want to add a public provider or module to. 1. Select \*\*Registry\*\* from the sidebar. The organization's private registry appears with a list of available providers and modules. 1. Click \*\*Search public registry\*\*. The \*\*Public Registry Search\*\* page appears. 1. Enter any combination of namespaces (such as hashicorp), and module or provider names into the search field. You can click \*\*Providers\*\* and \*\*Modules\*\* to toggle between lists of providers and modules that meet the search criteria. 1. Do one of the following to add a provider or module to your private registry: - Hover over the provider or module and click \*\*+ Add\*\*. - Click the provider or module to view its details and then click \*\*Add to HCP Terraform\*\*. 1. Click \*\*Add to organization\*\* in the dialog box. Members of your organization can now begin using it from the private registry. ## Enabling and Disabling No-Code Provisioning @include 'tfc-package-callouts/nocode.mdx' You can enable no-code provisioning for public modules after adding them to your registry. To support the auto-apply workflow, ensure that downstream users can automatically load provider credentials into their new no-code workspaces. You can enable access by either creating a [global or project-scoped variable set](/terraform/cloud-docs/variables/managing-variables#variable-sets) with the credentials for the module's provider, or by accessing outputs with credentials from other workspaces. Refer to [Provider Credentials](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design#provider-credentials) for more details. To enable no-code provisioning: 1. Verify that the module meets the [requirements for no-code provisioning](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design#requirements). 1. Click the module to view its details. 1. Select \*\*Enable no-code provisioning\*\* from the \*\*Manage Module for Organization\*\* dropdown. Your module’s details page now has a \*\*No-Code Ready\*\* badge to indicate that it supports no-code provisioning. To disable no-code provisioning, select \*\*Disable no-code provisioning\*\* from the \*\*Manage Module for Organization\*\* dropdown. Disabling also removes the \*\*No-Code Ready\*\* badge from the module’s details page. ## Removing a Public Provider or Module Removing a public provider or module from a private registry does not remove it from the public Terraform Registry. Users in the organization can still use the removed provider or module without changing their configurations. To remove a public provider or module from an organization's private registry: 1. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/add.mdx | main | terraform | [
-0.018309690058231354,
0.005596498027443886,
-0.03149046003818512,
-0.0047791143879294395,
0.023150471970438957,
0.04949188977479935,
-0.02667195536196232,
-0.026427891105413437,
-0.01371083501726389,
0.031324781477451324,
0.001563466154038906,
-0.07118190824985504,
-0.009487620554864407,
... | 0.064383 |
or Module Removing a public provider or module from a private registry does not remove it from the public Terraform Registry. Users in the organization can still use the removed provider or module without changing their configurations. To remove a public provider or module from an organization's private registry: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization whose registry you want to remove a provider or module from. 1. Select \*\*Registry\*\* from the sidebar. The organization's private registry appears with a list of available providers and modules. 1. Select the provider or module to view its details, open the \*\*Manage for Organization\*\* menu, and click \*\*Remove from organization\*\* (providers) or \*\*Delete module\*\* (modules). 1. Enter the provider or module name in the dialog box to confirm and then click \*\*Remove\*\* (providers) or \*\*Delete\*\* (modules). The provider or module no longer appears in the organization's private registry. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/add.mdx | main | terraform | [
-0.04993986710906029,
0.037276994436979294,
-0.021153569221496582,
0.007252970244735479,
0.034158218652009964,
0.00036487754550762475,
-0.0019636680372059345,
-0.11177784204483032,
0.0030492807272821665,
0.018389498814940453,
0.05850328132510185,
0.007292882073670626,
0.011354375630617142,
... | 0.016625 |
# Publish Stack component configurations to the private registry @include 'beta.mdx' Publish Stack component configurations to your organization's private registry to simplify sharing and versioning configurations with your teams. ## Background Stacks are made up of individual `component` blocks that each source a Terraform module. You define components in `.tfcomponent.hcl` files, which contain the component configuration for your Stack. You can publish a component configuration to the HCP Terraform private registry to share a Stack across your organization. When you publish a component configuration, other teams can create a new Stack using that configuration by sourcing it in a `stack` block in their own `.tfcomponent.hcl` file. Refer to [Use artifacts from the HCP Terraform private registry](/terraform/cloud-docs/registry/using#use-a-stack-component-configuration) to learn more about using the `stack` block. You can also publish component configurations to your private registry using the HCP Terraform API. To learn more, refer to the [Stack component configurations reference](/terraform/cloud-docs/api-docs/private-registry/stack-component-configurations#create-a-stack-component-configuration) ## Prerequisites To publish a Stack component configuration file you must meet the following requirements: - You must be a member of the [owners team](/terraform/cloud-docs/users-teams-organizations/permissions/organization#organization-owners) or a team with [\*\*Manage Stack component configurations\*\* permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-private-registry). - You must configure a VCS provider connection. Refer to [Connect to VCS Providers](/terraform/cloud-docs/vcs) for more information. Your VCS provider connection and repository must also meet the following requirements: - Your HCP Terraform user account must have admin access to your connected VCS repository. - GitLab repositories must be in the main organization or group, and not in any subgroups. - Your repository must contain a `.tfcomponent.hcl` file that defines your Stack's components. - Your repository must have at least one [Git release tag using semantic versioning](#tag-versions). ### Tag versions The HCP Terraform private registry uses Git tags to identify component configuration versions. After the [tag prefix](#publish-multiple-configurations-from-one-repository), tags must follow semantic versioning, such as `1.2.3`. The registry ignores tags that don't match this format. When you push a new semantic version tag to your repository, the registry automatically imports it as a new version. ## Publish a component configuration To publish a Stack component configuration, complete the following steps: 1. In HCP Terraform, navigate to your organization. 1. Select \*\*Registry\*\* from the sidebar, then \*\*Private Library\*\*. 1. Click \*\*Publish\*\* and choose \*\*Stack component configuration\*\* from the menu. 1. Select your VCS provider from the list. 1. Choose the repository that contains your component configuration. You can also search by typing part of the repository name. 1. If your component configuration is not at your repository's root, you can optionally specify a path in the \*\*Source Directory\*\* field. 1. You can optionally specify \*\*Tag Prefix\*\* if you are publishing [multiple component configurations from the same repository](#publish-multiple-configurations-from-one-repository). 1. Click \*\*Next\*\*. 1. In the \*\*Stack component configuration source address\*\* field, enter a name for the component configuration. Users reference this name in [stack blocks](/terraform/language/block/stack/tfcomponent/stack#source). 1. Click \*\*Create\*\*. HCP Terraform imports your component configuration and redirects you back to the main private registry page. Click the name of your component configuration to view its details page. ### Publish multiple configurations from one repository If your repository contains multiple component configurations, use tag prefixes to publish them individually. For example, you can add GitHub tags such as `database-v1.0.0` and `network-v1.0.0`, then specify `database-` or `network-` as tag prefixes when you publish each component configuration. Without a tag prefix, HCP Terraform publishes new versions for all component configurations whenever you create a new tag in GitHub. ## Release new versions To release a new version of a component configuration, push a new release tag to the associated VCS repository. The HCP Terraform private registry automatically imports the configuration and creates a new version | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/publish-stack-configuration.mdx | main | terraform | [
-0.009651091881096363,
-0.06241840496659279,
-0.031661197543144226,
-0.014332499355077744,
-0.024194439873099327,
0.011058648116886616,
-0.07452176511287689,
-0.024215862154960632,
0.031789977103471756,
0.01925942488014698,
-0.023245759308338165,
-0.06421846896409988,
0.04038352891802788,
... | 0.015521 |
versions for all component configurations whenever you create a new tag in GitHub. ## Release new versions To release a new version of a component configuration, push a new release tag to the associated VCS repository. The HCP Terraform private registry automatically imports the configuration and creates a new version for that tag. Refer to [Tag versions](#tag-versions) to learn about tag requirements. ## View and manage published configurations You can view the following information about a component configuration on its details page: - Versions - Source repository - Providers - Inputs - Outputs - Components - Documentation from a `README` file in the repository Refer to [Define configuration](/terraform/language/stacks/component/config) to learn more about Stack component configurations. You can use the \*\*Manage component configuration\*\* menu to perform the following actions: - View version history - Delete a specific version of the component configuration - Delete the entire component configuration | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/publish-stack-configuration.mdx | main | terraform | [
0.012696830555796623,
-0.04110031947493553,
0.030887939035892487,
-0.022803105413913727,
0.03061431460082531,
0.01672474667429924,
-0.08608625084161758,
-0.034350331872701645,
-0.003042328404262662,
0.028552789241075516,
0.019086165353655815,
0.0024877649266272783,
-0.009233014658093452,
-... | -0.00206 |
# Use artifacts from the HCP Terraform private registry All users in an organization can view the HCP Terraform private registry and use the available providers, Stack component configurations, and modules. A private registry has some key requirements and differences from the [public Terraform Registry](/terraform/registry): - \*\*Location:\*\* Search for providers, modules, Stacks, and usage examples in the HCP Terraform private registry UI. - \*\*Stacks support:\*\* The private registry supports publishing and using Stack component configurations. - \*\*Provider and Module block `source` argument:\*\* Private providers and modules use a different format. - \*\*Terraform version:\*\* HCP Terraform workspaces and Stacks using version 0.11 and higher can automatically access private modules during Terraform runs. Workspaces and Stacks using version 0.13 and higher can also automatically access private providers. - \*\*Authentication:\*\* If you run Terraform on the command line, you must [authenticate](#authentication) to HCP Terraform or your instance to use artifacts in your organization’s private registry. HCP Terraform supports using modules in written configuration or through the [no-code provisioning workflow](/terraform/cloud-docs/workspaces/no-code-provisioning/provisioning). ## Find artifacts To find available providers, Stack component configurations, and modules, select \*\*Registry\*\* from the side navigation in your organization. Click \*\*Providers\*\*, \*\*Stack component configurations\*\*, or \*\*Modules\*\* to toggle between lists of available artifacts in the private registry. You can also use the search field to filter for titles that contain a specific keyword. The search does not include `README`s or resource details. ### Shared providers and modules in Terraform Enterprise On Terraform Enterprise, your [registry sharing](/terraform/enterprise/admin/application/registry-sharing) configuration may grant you access to another organization's providers and modules. Providers and modules that are shared with your current organization have a \*\*Shared\*\* badge in the private registry (below). Providers and modules in your current organization that are shared with other organizations have a badge that says \*\*Sharing\*\*. ### View artifact details and versions Click an artifact to view its details page. Use the \*\*Versions\*\* menu in the upper right to switch between the available versions, and use the \*\*Readme\*\*, \*\*Inputs\*\*, \*\*Outputs\*\*, \*\*Dependencies\*\*, and \*\*Resources\*\* or \*\*Components\*\* tabs to view more information about the selected version. ### View nested modules and examples Use the \*\*Submodules\*\* menu to navigate to the detail pages for any nested modules. Use the \*\*Examples\*\* menu to navigate to the detail pages for any available example modules. ## Provision infrastructure from no-code ready modules You can use modules marked \*\*No-Code Ready\*\* to create a new workspace and automatically provision the module's resources without writing any Terraform configuration. Refer to [Provisioning No-Code Infrastructure](/terraform/cloud-docs/workspaces/no-code-provisioning/provisioning) for details. ## Use providers and modules in workspaces > \*\*Hands-on:\*\* Try the [Use Modules from the Registry](/terraform/tutorials/modules/module-use) tutorial. For Terraform configurations, the syntax to define public providers in a private registry is the same as for providers that you use directly from the public Terraform Registry. The syntax for the [provider block](/terraform/language/providers/configuration#provider-configuration-1) `source` argument is `/`. ```hcl terraform { required\_providers { google = { source = "hashicorp/google" version = "4.0.0" } } } ``` The syntax for referencing public modules in the [module block](/terraform/language/modules/syntax) `source` argument is `//`. ```hcl module "subnets" { source = "hashicorp/subnets/cidr" version = "1.0.0" } ``` ### Use private providers and modules The syntax for referencing private providers in the [provider block](/terraform/language/providers/configuration#provider-configuration-1) `source` argument is `//`. For the SaaS version of HCP Terraform, the hostname is `app.terraform.io`. ```hcl terraform { required\_providers { random = { source = "app.terraform.io/demo-custom-provider/random" version = "1.1.0" } } } ``` The syntax for referencing private modules in the [module block](/terraform/language/modules/syntax) `source` argument is `///`. - \*\*Hostname:\*\* For the SaaS version of HCP Terraform, use `app.terraform.io`. In Terraform Enterprise, use the hostname for your instance or the [generic hostname](/terraform/cloud-docs/registry/using#generic-hostname-terraform-enterprise). - | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/using.mdx | main | terraform | [
-0.03697849065065384,
0.0049161044880747795,
-0.04202680289745331,
-0.021923016756772995,
-0.009191161021590233,
-0.0015266123227775097,
-0.025371646508574486,
-0.03217899426817894,
-0.01944376341998577,
0.03666365146636963,
0.028715187683701515,
-0.08519845455884933,
0.03310126066207886,
... | 0.059268 |
{ source = "app.terraform.io/demo-custom-provider/random" version = "1.1.0" } } } ``` The syntax for referencing private modules in the [module block](/terraform/language/modules/syntax) `source` argument is `///`. - \*\*Hostname:\*\* For the SaaS version of HCP Terraform, use `app.terraform.io`. In Terraform Enterprise, use the hostname for your instance or the [generic hostname](/terraform/cloud-docs/registry/using#generic-hostname-terraform-enterprise). - \*\*Organization:\*\* If you are using a shared module with Terraform Enterprise, the module's organization name may be different from your organization's name. Check the source string at the top of the module's registry page to find the proper organization name. ```hcl module "vpc" { source = "app.terraform.io/example\_corp/vpc/aws" version = "1.0.4" } ``` ### Generic Hostname - HCP Terraform and Terraform Enterprise You can use the generic hostname `localterraform.com` in module sources to reference modules without modifying the HCP Terraform or Terraform Enterprise instance. When you run Terraform, it automatically requests any `localterraform.com` modules from the instance it runs on. ```hcl module "vpc" { source = "localterraform.com/example\_corp/vpc/aws" version = "1.0.4" } ``` ~> \*\*Important\*\*: CLI-driven workflows require Terraform CLI v1.4.0 or above. To test configurations on a developer workstation without the remote backend configured, you must replace the generic hostname with a literal hostname in all module sources and then change them back before committing to VCS. We are working on making this workflow smoother, but we only recommend `localterraform.com` for large organizations that use multiple Terraform Enterprise instances. ### Version Requirements Terraform version 0.11 or later is required to use private modules in HCP Terraform workspaces and to use the CLI to apply configurations with private modules. Terraform version 0.13 and later is required to use private providers in HCP Terraform workspaces and apply configurations with private providers. ## Use providers and modules in Stack components Stack components can source providers and modules from the following: - Remote addresses - Git Addresses - HTTP/HTTPS Addresses - HCP Terraform private registry - Terraform public registry ### Providers To source a provider from Github, use the following syntax: `git::ssh://github.com//repository.git/`: ```hcl required\_providers { my\_provider\_name = { source = "git::ssh://github.com//repository.git/" version = "~> 5.59.0" } } ``` To source a provider from a remote address, use a URL that points to a `tar.gz` file: ```hcl required\_providers { my\_provider\_name = { source = "https://example.com/infra/compute?archive=tar.gz" version = "~> 1.0.0" } } ``` To source a provider from the public [Terraform registry](https://registry.terraform.io/), use `/` syntax and reference that provider's documentation for the specifics. The following example sources the public `kubernetes` provider and configures it: ```hcl required\_providers { kubernetes = { source = "hashicorp/kubernetes" version = "~> 2.32.0" } } provider "kubernetes" "main" { config { host = component.cluster.cluster\_url cluster\_ca\_certificate = component.cluster.cluster\_ca token = component.cluster.cluster\_token } } ``` The syntax for referencing a provider from the HCP Terraform private registry is `app.terraform.io///`. The following example sources a provider named `my-random` from the private registry: ```hcl required\_providers { my-random = { source = "app.terraform.io/my-cool-org/demo-module/my-random" version = "~> 2.32.0" } } provider "my-random" "main" { config { # ... } } ``` To learn more about specific syntax for providers in components, refer to [`provider` block](/terraform/language/block/stack/tfcomponent/provider). To learn more about defining providers in Stacks, refer to [Declare providers](/terraform/language/stacks/component/declare-providers). ### Modules Each `component` block specifies the Terraform module to use as the source for that component. To source a module from a Remote Git address, use the following syntax: `git:::///.git//path/to/dir?ref=`. Additional Details: - Supported protocols are HTTP/HTTPS and SSH. - Userinfo is not allowed in the URL (username & password). - Valid Refs (`?ref=`) include: Full commit sha, Git Tag, and Branch name. The following example sources a module named `kube` from a GitHub repository: ```hcl component "my-component" { source = | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/using.mdx | main | terraform | [
-0.03534133359789848,
0.009802146814763546,
-0.01942349039018154,
0.0018527660286054015,
-0.009339084848761559,
-0.009131005965173244,
-0.009473131969571114,
-0.0373091846704483,
0.04145387187600136,
0.030834080651402473,
-0.011917689815163612,
-0.11971288919448853,
0.056992776691913605,
-... | 0.027855 |
Details: - Supported protocols are HTTP/HTTPS and SSH. - Userinfo is not allowed in the URL (username & password). - Valid Refs (`?ref=`) include: Full commit sha, Git Tag, and Branch name. The following example sources a module named `kube` from a GitHub repository: ```hcl component "my-component" { source = "git::https://github.com/my-cool-gh-org/kube.git?ref=0.1.0" # ... } ``` To source a module from a remote address, use a URL that points to a `tar.gz` file: ```hcl component "my-component" { source = "https://example.com/infra/compute?archive=tar.gz" # ... } ``` To source a module from the public [Terraform registry](https://registry.terraform.io/), use `/` syntax and reference that module's documentation for the specific syntax. The following example component sources the public `iam` module: ```hcl component "auth" { source = "terraform-aws-modules/iam/aws" version = "6.2.1" # ... } ``` The syntax for referencing a module from the HCP Terraform private registry is `app.terraform.io//`. The following example sources a module named `demo-module` from the private registry: ```hcl component "demo" { source = "app.terraform.io/my-cool-org/demo-module" version = "~> 2.32.0" # ... } ``` To learn more about components syntax, refer to the [`component` block reference](/terraform/language/block/stack/tfcomponent/component). ## Use a Stack component configuration @include 'beta.mdx' You can [publish component configurations](/terraform/cloud-docs/registry/publish-stack-configuration) to your private registry to let other users in your organization create a new Stack using that configuration. To use a component configuration published in the private registry, do the following: 1. In HCP Terraform, navigate to your organization. 1. Select \*\*Registry\*\* from the sidebar, then \*\*Private Library\*\*. 1. Click the name of the component configuration you want to use. 1. Copy the `stack` code block snippet from \*\*Usage instructions\*\*. The `stack` block includes the source address, version constraint, and any required input variables. 1. Create a `.tfcomponent.hcl` file and paste the `stack` block snippet. 1. Add a `required\_providers` block and specify the provider versions for your Stack. To learn more, refer to [Declare providers](/terraform/language/stacks/component/declare-providers). 1. If your `stack` block specifies any input variables, such as `var.`, define `variable` blocks to pass in those values. To learn more, refer to the[`variable` block reference](/terraform/language/block/stack/tfcomponent/variable). 1. Add a `.terraform-version` file and specify a Terraform version for your Stack, you must specify Terraform v1.14.2 or above. 1. Run `terraform stacks init` to create a provider lock file and install your providers. 1. Create a [deployment file](/terraform/language/stacks/deploy/config), `.tfdeploy.hcl`, and specify values for each required input variable. You can refer to the \*\*Inputs\*\* tab on the component configuration's details page to learn more about the required variables. 1. [Create your Stack](/terraform/cloud-docs/stacks/create) in HCP Terraform. Defining a `stack` block in a `.tfcomponent.hcl` file sources a Stack's entire component configuration, including all of the Stack's components and providers. To learn more about the `stack` block, refer to the [`stack` block reference](/terraform/language/block/stack/tfcomponent/stack). ## Provider and module availability A workspace or Stack can only use private providers and modules from its own organization's registry. When using providers or modules from multiple organizations in the same configuration, we recommend: - \*\*HCP Terraform:\*\* [Add providers and modules to the registry](/terraform/cloud-docs/registry/publish-modules#sharing-modules-across-organizations) for each organization that requires access. - \*\*Terraform Enterprise:\*\* Check your site's [registry sharing](/terraform/enterprise/admin/application/registry-sharing) configuration for workspaces. Workspaces can also use private providers and modules from organizations that are sharing with the workspace's organization. ## Authentication configurations with private providers and modules To authenticate with HCP Terraform, you can use either a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or a [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens). The type of token you choose may grant different permissions. - \*\*User Token\*\*: Allows you to access providers and modules from any organization in which you are a member. You are a member of an organization if you belong to any team in that organization. You can also access modules | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/using.mdx | main | terraform | [
-0.04501564800739288,
0.036853134632110596,
-0.023717179894447327,
-0.019046833738684654,
-0.014408338814973831,
-0.030144911259412766,
0.005260422360152006,
0.0016744383610785007,
0.05032171308994293,
0.05982140451669693,
-0.013367339968681335,
-0.11380690336227417,
0.05834063142538071,
-... | -0.023177 |
The type of token you choose may grant different permissions. - \*\*User Token\*\*: Allows you to access providers and modules from any organization in which you are a member. You are a member of an organization if you belong to any team in that organization. You can also access modules from any organization that is sharing modules with any of your organizations. -> \*\*Note:\*\* When SAML SSO is enabled, there is a [session timeout for user API tokens](/terraform/enterprise/saml/login#api-token-expiration), requiring you to periodically re-authenticate through the web UI. Expired tokens produce a \_401 Unauthorized\_ error. A SAML SSO account with [IsServiceAccount](/terraform/enterprise/saml/attributes#isserviceaccount) is treated as a service account and will not have the session timeout. - \*\*Team Token\*\*: Allows you to access the private registry of that team's organization and the registries from any other organizations that have configured sharing. \_Permissions Example\_ A user belongs to three organizations (1, 2, and 3), and organizations 1 and 2 share access with each other. In this case, the user's token gives them access to the private registries for all of the organizations they belong to: 1, 2, and 3. However, a team token from a team in organization 1 only gives the user access to the private registry in organizations 1 and 2. #### Configure authentication To configure authentication to HCP Terraform or your Terraform Enterprise instance, you can: - (Terraform 0.12.21 or later) Use the [`terraform login`](/terraform/cli/commands/login) command to obtain and save a user API token. - Create a token and [manually configure credentials in the CLI config file][cli-credentials]. Make sure the hostname matches the hostname you use in provider and module sources because if the same HCP Terraform server is available at two hostnames, Terraform will not know that they reference the same server. To support multiple hostnames for provider and module sources, use the `terraform login` command multiple times and specify a different hostname each time. [user-token]: /terraform/cloud-docs/users-teams-organizations/users#api-tokens [cli-credentials]: /terraform/cli/config/config-file#credentials [permissions-citation]: #intentionally-unused---keep-for-maintainers | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/using.mdx | main | terraform | [
-0.08431144058704376,
0.007763002999126911,
-0.05576407164335251,
0.037697676569223404,
0.0073814173229038715,
-0.002170757157728076,
0.04738149791955948,
-0.07123782485723495,
0.07806667685508728,
0.03260918706655502,
-0.015815865248441696,
0.010557233355939388,
0.017380548641085625,
0.08... | 0.13763 |
# Test private modules in the HCP Terraform private registry You can configure HCP Terraform to automatically run tests for modules in your private registry. When enabled, HCP Terraform will run tests for every commit to the designated branch. This lets you verify that it is safe to publish new module versions. ## Enable testing If your module uses the [branch-based publishing workflow](/terraform/cloud-docs/registry/publish-modules#branch-based-publishing) and its source code includes [tests](/terraform/language/v1.6.x/tests), you can enable testing at any time. To enable testing when publishing a new module: - Choose the \*\*Branch\*\* module publishing type - Assign a branch and a module version - Under testing, click the \*\*Enable testing for module\*\* checkbox - Click \*\*Publish module\*\* To enable testing for an existing module: - Navigate to the module overview screen - Click \*\*Configure Tests\*\* to open the \*\*Tests Settings\*\* screen - Click \*\*Enable testing for module\*\* ## Run tests remotely from the CLI After publishing and enabling testing for your module, you can use the Terraform CLI locally to trigger remotely-executed tests in HCP Terraform. This lets you test your module changes using the credentials configured in HCP Terraform without committing your changes to version control. To run your tests remotely, use the `-cloud-run` flag with the path to your module in your private registry. ```shell terraform test -cloud-run=app.terraform.io/:ORG/:MODULE\_NAME/:PROVIDER ``` ## Configure environment variables You can define test-specific environment variables that HCP Terraform will use for testing. If your tests provision infrastructure, you must configure provider credentials for the module. To add environment variables to your module's tests: 1. On the module overview screen, click \*\*Configure Tests\*\*. 1. In the \*\*Variables\*\* section on the \*\*Tests Settings\*\* screen, click \*\*+ Add variable\*\*. 1. Provide a \*\*Key\*\* and \*\*Value\*\* for your environment variable, and if you want to protect the variable's value, click the \*\*Sensitive\*\* checkbox. `TF\_VAR\_x` variables of a string type that are not defined in a config must be wrapped in double-quotes. 1. Click \*\*Add variable\*\* to save it. ## Configure providers You can define test-specific provider configurations for HCP Terraform to use while testing. For guidance on implementing test-specific provider configuration, refer to [Terraform test](/terraform/language/tests#providers). ## Generated module tests @include 'tfc-package-callouts/tests.mdx' HCP Terraform can generate [test files](/terraform/language/tests) for any private module in your registry. You can only generate tests one time per module. To generate tests for your module: 1. On the module overview screen, click \*\*Generate tests\*\*. 1. Click \*\*Confirm\*\*. It will take a few minutes to generate your module tests. 1. HCP Terraform displays generated configuration. To download all of the test files, click \*\*Download generated tests\*\*. 1. Create a `tests` directory in your configuration. 1. Unzip the downloaded files into the new `tests` directory. Generated test files remain available on the module overview page for later retrieval. Click \*\*View test files\*\* to view and download any previously generated tests. Organization owners can control this feature on the organization's [General Settings](/terraform/cloud-docs/users-teams-organizations/organizations#organization-settings) page. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/registry/test.mdx | main | terraform | [
0.010766732506453991,
-0.03723530098795891,
-0.011004078201949596,
0.023597920313477516,
0.0066809807904064655,
0.013015887700021267,
-0.12219604849815369,
-0.09338053315877914,
-0.038595087826251984,
0.06728512793779373,
0.02871575765311718,
-0.02725987695157528,
0.047108668833971024,
0.0... | -0.00106 |
# Encrypt your state and plan files The hold your own key (HYOK) feature lets you authenticate a key management system with HCP Terraform to encrypt HCP Terraform state and plan data with a key that you provide and control. ## Introduction @include 'tfc-package-callouts/hyok.mdx' Terraform artifacts can contain sensitive information, such as resource IDs, IP addresses, credentials, and other configuration details that Terraform uses to manage infrastructure. HCP Terraform uses a HashiCorp-managed key to encrypt sensitive data such as state and plan files before storage. For most users, the default level of security that HCP Terraform provides is sufficient. However, the side effect of default encryption is that HCP Terraform maintains access to your Terraform artifacts. You cannot monitor or revoke HCP Terraform's access to your artifacts, which might be insufficient for your compliance requirements. The hold your own key (HYOK) feature gives you control over your sensitive data by letting you provide your own encryption key to safeguard that data. HYOK lets you configure HCP Terraform artifact encryption using a key from a key management system (KMS) that you control. Use HYOK to retain control of the keys HCP Terraform uses to encrypt data in state and plan files, enhance your security, and meet your compliance requirements. When you enable HYOK, the [HCP Terraform agent](/terraform/cloud-docs/agents) secures certain Terraform artifacts using your key before uploading those artifacts to HCP Terraform storage. To accomplish this, the HCP Terraform agent authenticates with your key management service, then encrypts the necessary artifacts. You can run the HCP Terraform agent on your own infrastructure, meaning that neither your key nor unencrypted secrets are ever uploaded to HCP Terraform, and no out-of-network traffic needs to connect to your key management service. The artifacts that HCP Terraform agents encrypt with HYOK are: - [State files](/terraform/language/state) and [JSON state files](/terraform/internals/json-format) - [Plan files](/terraform/cli/commands/plan#out-filename) and [JSON plan files](/terraform/internals/json-format#plan-representation) The hold your own key feature supports the following key management services: - AWS Key Management Service - Azure Key Vault - Google Cloud Key Management - Vault transit secrets engine To learn how to configure HYOK for your organization, refer to [Configure and manage keys](/terraform/cloud-docs/hold-your-own-key/configure). The hold your own key feature also produces sanitized versions of artifacts which redact secrets from the artifacts it encrypts. Sanitized state and plan files let HCP Terraform continue running policy checks, run tasks, cost estimation, and assessments without accessing sensitive data. Refer to [How hold your own key concepts](/terraform/cloud-docs/hold-your-own-key/concepts) to learn more about the details of how HYOK encryption and decryption works. ## Workflow To create a key configuration for HYOK, you must perform the following steps: 1. Configure your key management system to accept OIDC requests from HCP Terraform, and create a key that your KMS will use to encrypt and decrypt the keys HYOK uses to secure your data. 1. Configure your key in HCP Terraform. 1. Enable HYOK on one or more workspaces. ### Configure your KMS and create a key Begin by [configuring your KMS](/terraform/cloud-docs/hold-your-own-key/configure#create-key-configuration) to accept OIDC requests from HCP Terraform. Then, set up your key and grant the necessary roles and permissions in your KMS. Specific configuration instructions differ between cloud providers. ### Configure the key in HCP Terraform After configuring your KMS with the trust relationship and creating a key, you can [create an HYOK configuration](/terraform/cloud-docs/hold-your-own-key/configure#configure-hyok-in-hcp-terraform) for your HCP Terraform organization. An HYOK configuration in HCP Terraform configures the following: - How to authenticate to your KMS using OIDC. - Which key HCP Terraform uses for this configuration. - The name to identify of the configuration within HCP Terraform. After configuring a key, HCP Terraform will | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/index.mdx | main | terraform | [
-0.0030395316425710917,
0.10530729591846466,
-0.02641674131155014,
-0.06076623871922493,
-0.03430244326591492,
0.012700608931481838,
0.014911575242877007,
-0.005871259141713381,
-0.015280642546713352,
0.006814951542764902,
-0.04428514093160629,
-0.05656418949365616,
0.07180973887443542,
-0... | 0.044449 |
for your HCP Terraform organization. An HYOK configuration in HCP Terraform configures the following: - How to authenticate to your KMS using OIDC. - Which key HCP Terraform uses for this configuration. - The name to identify of the configuration within HCP Terraform. After configuring a key, HCP Terraform will automatically test the connection to your KMS to ensure it can use the key to secure your data. ### Enable HYOK on your workspaces If you enable hold your own key encryption for a workspace, you cannot disable that encryption. After setting up a key configuration in HCP Terraform, you can enable hold your own key encryption on your workspaces. Choose one configuration to act as your primary configuration. HCP Terraform automatically uses the primary HYOK configuration to encrypt all sensitive Terraform artifacts for that workspace. Refer to [How hold your own key concepts](/terraform/cloud-docs/hold-your-own-key/concepts) to learn more about the details of encryption and decryption. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/index.mdx | main | terraform | [
0.000376299925846979,
0.06680663675069809,
-0.01227858942002058,
0.003414517967030406,
-0.03402041643857956,
0.00009579845209373161,
-0.00016453170974273235,
-0.06648313254117966,
0.0215016957372427,
0.02222605235874653,
-0.033293962478637695,
-0.03791842982172966,
0.07604961842298508,
-0.... | 0.010356 |
# Hold your own key concepts The hold your own key (HYOK) feature lets you authenticate a key management system with HCP Terraform to encrypt HCP Terraform state and plan data with a key that you provide and control. @include 'tfc-package-callouts/hyok.mdx' Terraform artifacts can contain sensitive information, such as resource IDs, IP addresses, credentials, and other configuration details that Terraform uses to manage infrastructure. To secure sensitive data, HCP Terraform uses a HashiCorp-managed key to encrypt sensitive data such as state and plan files before storage. The hold your own key (HYOK) feature gives you control over your sensitive data by letting you provide your own encryption key to safeguard that data. HYOK lets you configure HCP Terraform artifact encryption using a key from a key management system (KMS) that you control. When you enable hold your own key encryption, the HCP Terraform agent encrypts specific Terraform artifacts using a data encryption key (DEK) before uploading those files to HCP Terraform storage. To ensure you retain control of the DEK, the HCP Terraform agent authenticates with your key management service (KMS) and uses a key encryption key (KEK) to encrypt the DEK. You can run the HCP Terraform agent on your own infrastructure, meaning that neither your KEK nor unencrypted secrets are uploaded to HCP Terraform, and no out-of-network traffic needs to connect to your KMS. ## What is encrypted The artifacts that HCP Terraform agents encrypt with HYOK are: - [State files](/terraform/language/state) and [JSON state files](/terraform/internals/json-format). - [Plan files](/terraform/cli/commands/plan#out-filename) and [JSON plan files](/terraform/internals/json-format#plan-representation). ### Sensitive values in state Terraform marks attributes in state as sensitive when they are: - Dependent on [sensitive input variables](/terraform/language/values/variables#suppressing-values-in-cli-output). - Marked as [sensitive in a provider schema](/terraform/plugin/framework/handling-data/attributes/string#sensitive). - Marked as sensitive in the configuration using the [sensitive() helper function](/terraform/language/functions/sensitive). - Refer to another sensitive attribute. For example, if a resource references a sensitive input variable, Terraform also marks that resource argument as sensitive. Learn more about [Sensitive data in state](/terraform/language/state/sensitive-data). ## Sanitized state and plan files The hold your own key (HYOK) feature also produces sanitized versions of artifacts that redact secrets from the artifacts it encrypts. Sanitized state and plan files let HCP Terraform continue running policy checks, run tasks, cost estimation, and assessments without using sensitive data. The sanitized state and sanitized plan artifacts are JSON files with the same content and format as the `json-state` and `json-plan` outputs, with sensitive data redacted. HCP Terraform produces sanitized files for two reasons: - To let you download or view state or plan files from the API or Terraform CLI. - To pass artifacts to HCP Terraform features that rely on state and plan data. The following HCP Terraform features read data from sanitized state and plan files: - The [explorer](/terraform/cloud-docs/workspaces/explorer) - Workspace resources - Policy checks - Cost estimation - Run tasks - Assessments - Plan export (Sentinel mocks) The above features do not have access to the sensitive information in your state and plan files in workspaces you configure to use HYOK. HCP Terraform features that depend on sensitive information can no longer access sensitive data after you enable HYOK on a workspace. To use sensitive data in policies, you can get around this limitation by using the [agent execution mode for that policy set](/terraform/cloud-docs/policy-enforcement/manage-policy-sets#policy-evaluations). When you enable agent execution mode, the HCP Terraform agent decrypts plan data before running your policies, ensuring your policies continue to run as expected. ## Encryption process HYOK uses a process called [envelope encryption](https://cloud.ibm.com/docs/key-protect?topic=key-protect-envelope-encryption#envelope-encryption-overview) to secure artifacts using a KMS. Your key is stored in the KMS, and is referred to as a key encryption key | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/concepts.mdx | main | terraform | [
-0.030555682256817818,
0.09522267431020737,
-0.052130065858364105,
-0.03622562065720558,
-0.005800633225589991,
-0.05508573353290558,
0.025034219026565552,
-0.007348712999373674,
0.01406256016343832,
0.016878897324204445,
0.02452119253575802,
-0.028267795220017433,
0.058669205754995346,
-0... | 0.146161 |
HCP Terraform agent decrypts plan data before running your policies, ensuring your policies continue to run as expected. ## Encryption process HYOK uses a process called [envelope encryption](https://cloud.ibm.com/docs/key-protect?topic=key-protect-envelope-encryption#envelope-encryption-overview) to secure artifacts using a KMS. Your key is stored in the KMS, and is referred to as a key encryption key (KEK). When you enable HYOK for a workspace, HCP Terraform creates a data encryption key (DEK) for that workspace. HCP Terraform uses an agent with [request forwarding](/terraform/cloud-docs/agents/request-forwarding#hold-your-own-key) enabled to generate a new random DEK, and encrypts that DEK using the KEK. HCP Terraform then stores the encrypted DEK. During an HCP Terraform run, the agent downloads the DEK and calls your KMS to decrypt it using the KEK, and uses the DEK to decrypt your workspace's state. Then, when Terraform creates artifacts during the run, the agent uses the DEK to encrypt those artifacts before uploading them to HCP Terraform. The HCP Terraform agent creates sanitized plan and state files before encrypting the unsanitized files and uploading them to HCP Terraform. HCP Terraform stores the encrypted DEK and the encrypted artifacts. For HCP Terraform to read the artifacts and any secrets they may contain, your KMS needs to decrypt the DEK, which your agent uses decrypt the associated artifacts. Access to Terraform artifacts are controlled by the KEK on the KMS without needing to directly send artifacts to your KMS for encryption or decryption. ### JWT Claims The JWT issued by HCP Terraform and used to authenticate to the KMS has the following format: ```json { "typ": "JWT", "kid": "d8c1fcfdfeb3348cdf0b7c89945f0dbd0714710be34a781e42e6b13e91b77f0e", "alg": "RS256" } ``` ```json { "jti": "9f7ff698-77c9-4e1f-a893-cde34d920c50", "iss": "https://app.terraform.io", "aud": "api://AzureADTokenExchange", "iat": 1746534340, "nbf": 1746534340, "exp": 1746537940, "sub": "organization:hyok-org:hyok\_config:hyok-config-name" } ``` When you configure your KMS's trust policy, you will match the following claims: - `iss`: the issuer is always `https://app.terraform.io` - `sub`: the subject claim for HYOK JWTs is: `organization::hyok\_config:` - `aud`: the audience is the following, depending on your KMS provider: - Vault: `vault.workload.identity` - AWS: `aws.workload.identity` - GCP: `//iam.googleapis.com/` - Azure: `api://AzureADTokenExchange` ### Data key encryption When you enable HYOK on a workspace, HCP Terraform generates a new data encryption key (DEK) for that workspace. The DEK is a random 256-bit string. HCP Terraform sends the DEK to your KMS for that key configuration. Encryption of the DEK is delegated to the KMS, so details vary depending on the key configuration: - [Vault Transit Secrets Engine Encrypt](/vault/api-docs/secret/transit#encrypt-data) - [AWS KMS Encrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API\_Encrypt.html) - [GCP Cloud KMS cryptroKeys.encrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/encrypt) - [Azure Key Vault Encrypt](https://learn.microsoft.com/en-us/rest/api/keyvault/keys/encrypt/encrypt?view=rest-keyvault-keys-7.4&tabs=HTTP) When you revoke an HYOK configuration in HCP Terraform, it sends the encrypted DEK to the HCP Terraform agent. The agent first decrypts the DEK using the KMS configuration you are revoking, and then re-encrypts the key using your primary HYOK configuration before uploading the new encrypted DEK to HCP Terraform.  ### Artifact encryption During an HCP Terraform run on an HYOK-enabled workspace, the HCP Terraform agent runs a proxy between the Terraform CLI, which produces and consumes artifacts, and HCP Terraform's artifact storage service, "Archivist". This proxy watches for the download of encrypted state files, and uses stream decryption to pass the decrypted state files to the Terraform CLI without reading the entirety of the file into the agent's memory. Similarly, when the Terraform CLI uploads a state file, the agent proxy detects the upload, which stream-encrypts the artifact with your workspace's DEK on its way to HCP Terraform's storage service. All HCP Terraform artifacts are encrypted using AES256-GCM, with AEAD based on the ID of the artifact to be encrypted: - Key size: 32 bytes - HKDF algo: | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/concepts.mdx | main | terraform | [
-0.029179884120821953,
0.07259228080511093,
-0.010487344115972519,
-0.012638850137591362,
-0.01614348031580448,
-0.06942969560623169,
0.03193988651037216,
-0.05484049394726753,
0.051687877625226974,
0.04732512682676315,
-0.008618541993200779,
-0.04319734871387482,
0.05239207670092583,
-0.0... | 0.101647 |
the agent proxy detects the upload, which stream-encrypts the artifact with your workspace's DEK on its way to HCP Terraform's storage service. All HCP Terraform artifacts are encrypted using AES256-GCM, with AEAD based on the ID of the artifact to be encrypted: - Key size: 32 bytes - HKDF algo: `HMAC-SHA256` - Size of AES-GCM derived keys: 32 bytes - Ciphertext segment size: 1048576 bytes (1 MB) Reference the following diagram for a visual representation of key handling and communication between HCP Terraform services and services inside your network during an HCP Terraform apply:  HCP Terraform plans follow the same flow, except they decrypt a state file and produce and encrypt a plan file instead of the apply workflow. ### Download decrypted files You can download decrypted state files from the HCP Terraform API or using the Terraform CLI. When you attempt to download a decrypted state version in an HYOK-enabled workspace, HCP Terraform creates a temporary download link for its artifact storage service, archivist, then returns that link with an HTTP redirect response. To access the link, follow the redirect through your browser or your CLI tool. After the redirect, archivist requests a decrypted data encryption key from HCP Terraform for artifact decryption. HCP Terraform uses a short-lived JWT that it issues during the link generation process which is valid only for the specific artifact you request. HCP Terraform then requests the decryption of the relevant data key for the artifact, using a [request forwarding agent](/terraform/cloud-docs/agents/request-forwarding#hold-your-own-key) running inside your network. The agent decrypts the provided DEK using your KMS, and returns the decrypted DEK to HCP Terraform, which sends it to archivist. Archivist then begins streaming the Terraform state file to the client, using the DEK to decrypt the file as it is streamed. At no point are the decrypted DEK or the decrypted state file stored to disk in HCP Terraform or in archivist. HCP Terraform does not let you download decrypted JSON state, JSON plan, or plan files, because these files are not required for out-of-band operations. An out-of-band operation is any operation outside of a Terraform run, meaning that the Terraform CLI does not interact with these artifacts outside of a Terraform run. Refer to the following diagram for a visual representation of the decrypted download flow during a `terraform init` using the Terraform CLI and a request forwarding agent within your network :  Note that neither the decrypted state file nor the decrypted key are ever stored to disk. ## Authentication with key management systems An HCP Terraform agent sends all HYOK communication with a KMS using OpenID Connect (OIDC). Before using HYOK, you will establish a trust relationship between HCP Terraform and your chosen KMS. To do so, you configure your KMS to accept HCP Terraform's identity tokens, telling your KMS to allow token bearers signed by HCP Terraform to encrypt and decrypt data with the key you specify. HCP Terraform's identity tokens are in the "JWT" (JSON Web Token) format. Learn more about the format of the JWT in [JWT Claims](#jwt-claims). When HCP Terraform starts a run, or requires the generation or re-encryption of a DEK, it issues a new JWT. HCP Terraform passes the JWT to the HCP Terraform agent to make the necessary requests to your KMS. The HCP Terraform agent uses the KMS's encryption-as-a-service functionality to encrypt and decrypt the necessary data encryption key(s) without accessing the KEK. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/concepts.mdx | main | terraform | [
-0.015593179501593113,
0.08773704618215561,
0.02819051407277584,
-0.06528790295124054,
-0.008237199857831001,
-0.03864835947751999,
-0.0047441450878977776,
-0.07175861299037933,
0.0253065787255764,
0.04222040995955467,
-0.041456352919340134,
-0.05479547381401062,
0.04891561344265938,
-0.05... | 0.011276 |
necessary requests to your KMS. The HCP Terraform agent uses the KMS's encryption-as-a-service functionality to encrypt and decrypt the necessary data encryption key(s) without accessing the KEK. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/concepts.mdx | main | terraform | [
-0.020915117114782333,
0.08685299754142761,
0.004712685011327267,
-0.05860888585448265,
-0.004188058897852898,
0.004944830201566219,
0.00610645255073905,
-0.0858590379357338,
0.04333267733454704,
0.025337345898151398,
-0.013391315005719662,
-0.08654507249593735,
0.045653749257326126,
-0.08... | 0.096607 |
# Configure and manage keys Configure your key management system (KMS) and HCP Terraform to use the hold your own key (HYOK) feature to encrypt your sensitive Terraform artifacts. ## Background HCP Terraform lets you configure multiple HYOK configurations for an organization. Each HYOK configuration corresponds to a single key in a KMS. Additional HYOK configurations can point to different keys in the same KMS, or keys in others KMSs. When you set up HYOK, you designate one configuration as your organization's \*\*primary\*\* configuration. When you enable HYOK on a workspace, HCP Terraform automatically secures that workspace's artifacts using your organization's primary HYOK configuration. Refer to [How hold your own key concepts](/terraform/cloud-docs/hold-your-own-key/concepts) to learn more about the details of encryption and decryption. ## Requirements @include 'tfc-package-callouts/hyok.mdx' To use hold your own key, first ensure you meet the following requirements: - Your organization has at least one agent pool, and you [enable request forwarding on at least one agent in that pool](/terraform/cloud-docs/agents/request-forwarding#hold-your-own-key). - Configure healthy key management policies on your KMS to prevent data loss. Otherwise, if a key is deleted from a KMS while HCP Terraform is using it, you can experience state loss. - Configure your workspaces to use Terraform 1.3+. ## Create key configuration To configure hold your own key, begin by letting your key management system accept the necessary OpenID Connect (OIDC) requests from HCP Terraform. Then, set up your keys and grant the necessary roles and permissions in your cloud provider. To use Azure with HYOK, you need to configure the following: - A Key Vault and encryption key. - An Entra ID Application which trusts the OIDC credentials issued by HCP Terraform. - A service principal in the application with permission to use your key. ### Create a Key Vault and an encryption key Create a Key Vault and key to secure your sensitive HCP Terraform artifacts: - If you do not already have one, [create a Key Vault using the Azure portal](https://learn.microsoft.com/en-us/azure/key-vault/general/quick-create-portal). - Then, [add a key to the Key Vault](https://learn.microsoft.com/en-us/azure/key-vault/keys/quick-create-portal#add-a-key-to-key-vault) to use to secure your sensitive Terraform artifacts. Take note of the key URI, which is in the format: `https://.vault.azure.net/keys/`. You will use this URI later to configure your key in HCP Terraform. ### Create an Entra ID Application Next, follow the steps to [create the Application and Service Principal](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service\_principal\_oidc#creating-the-application-and-service-principal). Do not proceed to the \*\*Configure Microsoft Entra ID Application to Trust a GitHub Repository\*\* step, and set your \*\*Application Redirect URI\*\* type to \*\*Web\*\*. Also, take note of the `client\_id` and `tenant\_id` for your application. You use these values to configure your key in HCP Terraform. ### Configure Entra ID to trust HCP Terraform Next, create federated identity credentials in your application, which validate the contents of the token sent to Azure from HCP Terraform. Follow the steps in the AzureRM provider docs: [Configure Azure Microsoft Entra ID Application to Trust a Generic Issuer](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service\_principal\_oidc#configure-azure-active-directory-application-to-trust-a-generic-issuer), and use the values below when you add the credential. Specify the following information in the \*\*Add a credential\*\* step: - \*\*Federated credential scenario\*\*: Set to \*\*Other issuer\*\*. - \*\*Issuer\*\*: The address of HCP Terraform, `https://app.terraform.io`. - \*\*Subject identifier\*\*: The subject identifier from HCP Terraform that this credential will match. This is in the form `organization::hyok\_config:`. The HYOK configuration name can contain letters, numbers, hyphens, and underscores. - \*\*Audience\*\*: Leave this as the default value, `api://AzureADTokenExchange`. Make a note of the HYOK config name you choose here, you will use it later when you configure HCP Terraform. To use AWS with HYOK, you need to configure the following: - An OIDC Identity Provider for HCP Terraform. - An | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
0.0034295981749892235,
0.05436639115214348,
-0.039177797734737396,
-0.031138379126787186,
-0.03758782148361206,
-0.04265345260500908,
0.01202654279768467,
-0.02412886917591095,
-0.0028691869229078293,
0.01737978868186474,
0.0010556173510849476,
-0.07309167087078094,
0.06672101467847824,
-0... | 0.055079 |
\*\*Audience\*\*: Leave this as the default value, `api://AzureADTokenExchange`. Make a note of the HYOK config name you choose here, you will use it later when you configure HCP Terraform. To use AWS with HYOK, you need to configure the following: - An OIDC Identity Provider for HCP Terraform. - An IAM role with a trust policy that lets the HCP Terraform agent assume it. - An AWS KMS key that your IAM role can use. ### Create an OIDC Identity Provider Follow the steps for [Creating OpenID Connect (OIDC) identity providers - AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/id\_roles\_providers\_create\_oidc.html) through the AWS console or API. Set your provider URL to the address of HCP Terraform (`https://app.terraform.io`) and the audience to `aws.workload.identity`. ### Create an IAM Role and Trust Policy Next, configure a role and corresponding trust policy by following: [Creating a role for web identity or OpenID Connect Federation (console) - AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/id\_roles\_create\_for-idp\_oidc.html). Use the following trust policy as a template: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "app.terraform.io:aud": "aws.workload.identity" }, "StringLike": { "app.terraform.io:sub": "organization::hyok\_config:" } } } ] } ``` The \*\*Condition\*\* field matches against the subject claim of HCP Terraform's JWT. For HYOK, the subject claim is: `organization::hyok\_config:`. Wildcards are allowed when matching claims. For example, if you want to use the same role for all keys within your HCP Terraform organization, you can configure your subject claim to match all HYOK configurations in your organization: `organization::hyok\_config:\*`. For additional security we recommend that you choose a configuration name now, so that only the specified HYOK configuration may assume this role: `organization::hyok\_config:`. The HYOK configuration name can contain letters, numbers, hyphens, and underscores. Take note of the HYOK configuration name you specify here, you will use it when you create your HYOK configuration in HCP Terraform. ### Create an AWS KMS Key You must choose or create a symmetric AWS KMS key to use to encrypt and decrypt your data encryption keys. Use the AWS console or API and the steps in [Create a symmetric encryption KMS key](https://docs.aws.amazon.com/kms/latest/developerguide/create-symmetric-cmk.html). Add the IAM role you created in the previous step as a key user, so that the HCP Terraform agent can use it to perform cryptographic operations. To use GCP with HYOK, you will configure the following: - A key ring and a key to encrypt your sensitive HCP Terraform artifacts. - A Workload Identity Pool and Provider configured to trust OIDC tokens issued by HCP Terraform. - A service account that can be assumed with the workload identity provider and has permission to use the key. ### Create a Key Ring and Key To begin, [Create a key ring](https://cloud.google.com/kms/docs/create-key-ring) and a [Create a symmetric encryption key](https://cloud.google.com/kms/docs/create-key#create-symmetric) in Google Cloud KMS. Make a note of the \*\*key name\*\* and the \*\*key ring name\*\*. You use these values later when you create your HYOK configuration in HCP Terraform. ### Create a Service Account Next, [create a service account](https://cloud.google.com/iam/docs/service-accounts-create) with permissions to encrypt and decrypt data with the key you created. The HCP Terraform Agent will assume the role of this service account in order to use this key to encrypt and decrypt your data encryption keys. Ensure that you grant the service account the necessary IAM permissions to encrypt and decrypt data using your key. For example, you could use the \*\*Cloud KMS CryptoKey Encrypter/Decrypter\*\* role, though you may want further scope access to only your key. ### Create a Workload Identity Pool and Provider Create a workload identity pool and provider by following the steps in [Configure | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
-0.014526886865496635,
0.07323529571294785,
-0.04169277474284172,
0.022084522992372513,
-0.020065966993570328,
0.011936572380363941,
0.047826699912548065,
-0.03724642097949982,
-0.005953759886324406,
0.04661215841770172,
-0.011223536916077137,
-0.13013942539691925,
0.08534274250268936,
-0.... | 0.06682 |
encrypt and decrypt data using your key. For example, you could use the \*\*Cloud KMS CryptoKey Encrypter/Decrypter\*\* role, though you may want further scope access to only your key. ### Create a Workload Identity Pool and Provider Create a workload identity pool and provider by following the steps in [Configure Workload Identity Federation](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#configure). Make a note of the name you choose for the \*\*Workload Identity Pool\*\*, you will use it when you create your HYOK configuration in HCP Terraform. When creating the Identity Provider, specify the following details: - \*\*Provider type\*\*: Must be "OpenID Connect (OIDC)". - \*\*Issuer (URL)\*\*: The address of HCP Terraform, `https://app.terraform.io`. - \*\*Audience\*\*: Leave the default value. - \*\*Provider attributes mapping\*\*: Set the `google.subject` value to `assertion.sub`. - \*\*Attribute Conditions\*\*: Restrict which identity tokens this provider authenticates by matching on the subject claim of the JWT minted by HCP Terraform. For HYOK, this would be: `organization::hyok\_config:`. If you want to use the same provider to access all keys within your organization, you may use wildcard matching in the condition: `assertion.sub.startsWith("organization::hyok\_config:")` For additional security, we recommend choosing a configuration name now so that only workloads requiring a particular key may assume this role: `assertion.sub.startsWith("organization::hyok\_config:")`. The HYOK configuration name can contain letters, numbers, hyphens, and underscores. Note the \*\*HYOK\_CONFIG\_NAME\*\* value you choose here, as well as the \*\*pool name\*\* and \*\*provider name\*\*. You use these values when you create your HYOK configuration in HCP Terraform. GCP has a limit of 127 characters for subject claims. This means `organization::hyok\_config:` must be under 127 characters. Make sure to choose your HYOK config name accordingly, based on the length of ORG\_NAME. ### Grant Service Account Access to the Identity Pool Finally, you need to grant the workload identity pool access to the service account by following the steps in [Allow the external workload to impersonate the service account](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#access). To use Vault with HYOK, you need to configure the following: - Mount and configure a JWT Authentication backend. - Mount a transit secrets engine and add a key. - Add a role for [the `tfc-agent`](/terraform/cloud-docs/agents) to assume and policies that let it use the key. ## Mount and Configure a JWT Authentication backend If you already have a JWT Authentication backend set up, use that existing backend. If not, enable it as shown below. ```shell-session $ vault auth enable -path=jwt-prod jwt Success! Enabled jwt auth method at: jwt-prod/ ``` Configure Vault to trust HCP Terraform's identity tokens and verify them using HCP Terraform's public key. The following command configures the JWT authentication backend in Vault to trust HCP Terraform as an OIDC identity provider: ```shell-session $ vault write auth/jwt-prod/config \ oidc\_discovery\_url="https://app.terraform.io" \ bound\_issuer="https://app.terraform.io" Success! Data written to: auth/jwt-prod/config ``` Do not include any trailing slashes from the HCP Terraform URL. ### Create a key Set up the resource you want to access, which is the key encryption key you will create in the next step. To do this, enable Vault's transit secrets engine if it is not already enabled, as shown below: ```shell-session $ vault secrets enable transit Success! Enabled the transit secrets engine at: transit/ ``` Next, create the key which Vault will use to encrypt and decrypt your data encryption keys. To do this, give your key a unique name, as shown below. In the example below, the key name is `unique-prod`: ```shell-session $ vault write -f transit/keys/unique-prod Key Value --- ----- allow\_plaintext\_backup false auto\_rotate\_period 0s deletion\_allowed false derived false exportable false imported\_key false keys map[1:1738617996] latest\_version 1 min\_available\_version 0 min\_decryption\_version 1 min\_encryption\_version 0 name unique-prod supports\_decryption true supports\_derivation true supports\_encryption true supports\_signing false type aes256-gcm96 ``` Take note of | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
-0.020447785034775734,
0.08604907989501953,
-0.007294611074030399,
-0.02038138546049595,
-0.031948190182447433,
-0.02941046841442585,
0.061834052205085754,
-0.02425399050116539,
0.009343545883893967,
0.04834038391709328,
-0.013723318465054035,
-0.10455506294965744,
0.09160235524177551,
-0.... | 0.037248 |
is `unique-prod`: ```shell-session $ vault write -f transit/keys/unique-prod Key Value --- ----- allow\_plaintext\_backup false auto\_rotate\_period 0s deletion\_allowed false derived false exportable false imported\_key false keys map[1:1738617996] latest\_version 1 min\_available\_version 0 min\_decryption\_version 1 min\_encryption\_version 0 name unique-prod supports\_decryption true supports\_derivation true supports\_encryption true supports\_signing false type aes256-gcm96 ``` Take note of the key name you chose, as you will need to refer to the value later. ### Configure roles and policies To add roles and policies, grant entities authenticating with the JWT the ability to encrypt and decrypt with your newly created key encryption key. This requires a role and an access policy that grants access to the key. Create a new `encrypt-decrypt-policy.hcl` file with the following contents: ```hcl path "transit/encrypt/" { capabilities = [ "create", "update" ] } path "transit/decrypt/" { capabilities = [ "create", "update" ] } ``` Replace `` with the name of the key you created in the previous step. ```shell-session $ vault policy write hyok-encrypt-prod encrypt-decrypt-policy.hcl Success! Uploaded policy: hyok-encrypt-prod ``` Next, create a role that you will grant the policy above to, and that can also be assumed by the JWT authentication endpoint when given a valid HCP Terraform HYOK JWT. Choose a unique name for the role, as outlined in the example below: ```hcl { "policies": ["hyok-encrypt-prod"], "bound\_audiences": ["vault.workload.identity"], "bound\_claims\_type": "glob", "bound\_claims": { "sub": "organization::hyok\_config:" }, "user\_claim": "sub", "role\_type": "jwt", "token\_ttl": "20m" } ``` Replace the following values in the above role configuration: - The policies list needs to include the name of the policy you created. - The `bound\_audiences` list needs to be `vault.workload.identity`. - The `bound\_claims.sub` matches against the subject claim of the HCP Terraform-issued JWT, which for HYOK is `organization::hyok\_config:"`. Wildcards are allowed when matching claims. For example, if you want to use the same role for all keys within your HCP Terraform organization, you can configure your subject claim to match all HYOK configurations in your organization: `organization::hyok\_config:\*`. For additional security we recommend that you choose a configuration name now, so that only the specified HYOK configuration may assume this role: `organization::hyok\_config:`. The HYOK configuration name can contain letters, numbers, hyphens, and underscores. Note the \*\*HYOK\_CONFIG\_NAME\*\* value you choose here. You use this value when you create your HYOK configuration in HCP Terraform. Run the following command to create the role in Vault: ```shell-session $ vault write auth/jwt-prod/role/unique-prod-role-prod @hyok-prod-role.json Success! Data written to: auth/jwt-prod/role/unique-prod ``` ## Configure HYOK in HCP Terraform Once you have configured your KMS with a key encryption key and the necessary OIDC trust relationship to HCP Terraform, you can create an HYOK configuration for your organization. Each HYOK configuration in your organization represents a single KMS key encryption key with potentially multiple key versions. You can configure multiple keys in different HYOK configurations, across one or more KMSs. Follow the steps outlined above for each KMS you wish to use with HYOK. Navigate to \*\*Organization Settings\*\* then \*\*HYOK Encryption\*\*. Open the HYOK configuration wizard by clicking \*\*Configure a key\*\*. ### Choose an agent pool On the first step of the wizard, select an agent pool that is hosting agents with [request forwarding enabled](/terraform/cloud-docs/agents/request-forwarding#hold-your-own-key). HCP Terraform uses this agent pool to: - Generate and encrypt data encryption keys for workspaces onboarded with HYOK. - Re-encrypt data keys when an HYOK configuration is revoked. - Connect to your KMS to check for new key versions. The agent pool you specify is not used to perform Terraform runs. HCP Terraform continues to use the agent pool specified in your workspace's execution mode when performing runs. The agents running your workspace's operations do not require request forwarding, but you should | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
-0.015781573951244354,
0.02530091628432274,
-0.05468660965561867,
-0.05651988461613655,
-0.005008976440876722,
0.01998106762766838,
0.0523645393550396,
0.020702602341771126,
0.02154838852584362,
-0.03395470231771469,
-0.0024729345459491014,
-0.031710606068372726,
0.12422765046358109,
-0.06... | -0.081237 |
KMS to check for new key versions. The agent pool you specify is not used to perform Terraform runs. HCP Terraform continues to use the agent pool specified in your workspace's execution mode when performing runs. The agents running your workspace's operations do not require request forwarding, but you should update them to version `1.23.0` or later to use them with HYOK. ### Configure OIDC settings The next step of the wizard collects the information needed to authenticate to your KMS using OIDC. Select your KMS type and fill in the required information for your KMS provider. To configure your OIDC connection in HCP Terraform, you need the following values from Azure: - \*\*Application ID\*\* for your Entra ID Application. This is also called an \*\*Application (client) ID\*\* on the EntraID Application overview page. - \*\*Tenant ID\*\* for your Entra ID Application. This is also called an \*\*Directory (tenant) ID\*\* on the EntraID Application overview page. - Your \*\*Subscription ID\*\* from the Azure subscription overview page. To configure your OIDC connection in HCP Terraform, you need the following values from AWS: - \*\*Role ARN\*\*: The ARN of the IAM role you configured earlier. To configure your OIDC connection in HCP Terraform, you need the following values from GCP: - \*\*Service account email\*\*: The email of the service account you created in the [previous step](#create-key-configuration), with permission to encrypt and decrypt using your key. - Your \*\*GCP Project Number\*\* for the project containing the Workload Identity Provider and service account. - The fully qualified [\*\*Workload Provider name\*\*](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/iam\_workload\_identity\_pool\_provider?product\_intent=terraform#name-1), in the format: `projects//locations/global/workloadIdentityPools//providers/` To configure your OIDC connection in HCP Terraform, you need the following values from Vault: - The \*\*Address (URL)\*\* of your Vault instance, with `https://` included. - The \*\*Role name\*\* for the role you created on the JWT authentication endpoint in the previous step. In the Vault configuration example above, this was `unique-prod-role-prod`. - The \*\*namespace\*\* to use when authenticating to Vault, such as `admin`. - The \*\*JWT auth path\*\* where your JWT authentication backend is mounted. By default this is `admin`, but in the [Vault configuration example](#create-key-configuration) above, it was `jwt-prod`. If you are using Vault Enterprise with a custom CA, enter the \*\*TLS CA Certificate\*\* which authenticates it. ### Configure key settings On the final page of the wizard, tell HCP Terraform which key to use for this HYOK configuration. Also, give your HYOK configuration a unique name to identify it. Your configuration name can be any combination of letters, numbers, hyphens, and underscores, and is included in the subject claim of HYOK JWTs that HCP Terraform issues. If you configured your KMS to match against your `hyok\_config` name, use the same name for your HYOK configuration. To configure your key in HCP Terraform, you need the full \*\*Key URI\*\* for the key you created in Azure, which uses the format: `https://.vault.azure.net/keys/` To configure your key in HCP Terraform, you need the following values from AWS: - The full \*\*Key ARN\*\* for the KMS key. - The \*\*Region\*\* that the key is located in. To configure your key in HCP Terraform, you need the following values from GCP: - The \*\*Key Ring Name\*\* for the key ring. - The \*\*Key Name\*\* for the specific key in that ring. - The \*\*Location\*\* that the key ring was created in, for example `global` or `us-central1`. To configure your key in HCP Terraform, you need the \*\*Name\*\* of the key you created in the transit secrets engine. In the Vault configuration example above, this was `unique-prod`. ### Test the key configuration To test your HYOK configuration, click \*\*Test Connection\*\* on the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
0.015002182684838772,
0.013607571832835674,
0.007390614133328199,
-0.005393143743276596,
-0.03882940858602524,
-0.0008438277873210609,
-0.011541982181370258,
-0.09863720834255219,
0.03330878168344498,
0.0720289796590805,
-0.029483972117304802,
-0.08155526965856552,
0.06803677976131439,
-0.... | 0.007345 |
for example `global` or `us-central1`. To configure your key in HCP Terraform, you need the \*\*Name\*\* of the key you created in the transit secrets engine. In the Vault configuration example above, this was `unique-prod`. ### Test the key configuration To test your HYOK configuration, click \*\*Test Connection\*\* on the last step of the \*\*Configure a new key\*\* wizard. Clicking \*\*Test Connection\*\* tells HCP Terraform to attempt to authenticate to your KMS and test that basic encryption and decryption works. Once a configuration is saved, you can also access the \*\*Test Connection\*\* button on the settings page for your HYOK configuration. If HCP Terraform cannot successfully connect to your KMS and use your key to encrypt and decrypt data, it will display an error message. The most likely cause of failures are: - There are no agents with \*\*Request Forwarding\*\* enabled running in the chosen \*\*Agent Pool\*\*. - Permissions have not been set correctly in your KMS. - The required resources are not fully provisioned in your KMS. In rare cases, it can take up to 15 minutes for keys to be accessible to HCP Terraform after creation, particularly for Azure and GCP. ## Use a key configuration to encrypt a workspace After you set up an HYOK configuration, you can use it to encrypt a workspace's artifacts. When you enable HYOK for a workspace, HCP Terraform uses the primary configuration to secure that workspace's artifacts. When you revoke an HYOK configuration in HCP Terraform, HCP Terraform migrates all of the workspaces that used the revoked configuration to the new primary configuration. To manually promote a configuration to primary, navigate to your organization's \*\*Settings\*\*, then to \*\*HYOK Encryption\*\*. Click \*\*Promote to primary\*\* on your desired HYOK configuration. HCP Terraform automatically promotes the first HYOK configuration with a status of \*\*Available\*\*. If you enable hold your own key encryption for a workspace, you cannot disable HYOK on that workspace. To encrypt a workspace's artifacts using HYOK, go to the workspace's \*\*Settings\*\*, and navigate to \*\*HYOK Encryption\*\*. Check \*\*Enable HYOK for this workspace\*\* to enable HYOK for that workspace. Once you enable HYOK on a workspace, HCP Terraform generates a data encryption key, connects to your KMS to encrypt it with your key encryption key, and stores the encrypted DEK. Any future runs on your workspace will now produce encrypted state and plan files. You can test this by performing a run. State versions are annotated with the name of the HYOK configuration HCP Terraform used to them. ## Revoke a key configuration HCP Terraform keeps track of which HYOK configurations secure each of your workspace's artifacts. If you want to stop using a given KEK or a specific key version, you can revoke that key configuration within HCP Terraform. For example, if a key version is old or has been leaked, revoking it in HCP Terraform instructs the platform to stop using that key for encryption and to migrate all existing data off of it. Note that HCP Terraform does not manage keys within your KMS. Revoking a key configuration in HCP Terraform does not revoke that key within your KMS. Revoking a key configuration in HCP Terraform lets you migrate data off of the key so that you can then revoke and safely delete the corresponding key from your KMS. To revoke a key configuration: 1. Navigate to your organization's \*\*Settings\*\*. 1. Then to \*\*HYOK Encryption\*\*. 1. Click the \*\*Revoke\*\* button next to the HYOK configuration you want to revoke. When you revoke a key configuration, HCP Terraform migrates all of the workspaces that used that configuration to the primary | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
0.009129680693149567,
0.04180740565061569,
-0.03498455137014389,
-0.02953210286796093,
-0.06119440123438835,
0.0005206175264902413,
-0.009099692106246948,
-0.03971288725733757,
-0.043587468564510345,
-0.0025444580242037773,
0.008011030033230782,
-0.08046593517065048,
0.09639906138181686,
-... | 0.018262 |
To revoke a key configuration: 1. Navigate to your organization's \*\*Settings\*\*. 1. Then to \*\*HYOK Encryption\*\*. 1. Click the \*\*Revoke\*\* button next to the HYOK configuration you want to revoke. When you revoke a key configuration, HCP Terraform migrates all of the workspaces that used that configuration to the primary configuration. If you have not set a primary configuration, HCP Terraform automatically promotes the first available HYOK configuration to primary when you revoke your primary configuration. When you revoke a key version, HCP Terraform automatically re-secures all of the artifacts it currently secures with the latest version of the same key. When you revoke a key or key version, HCP Terraform does not need to directly re-encrypt all the artifacts it secures. Instead, HCP Terraform uses an HCP Terraform agent to re-encrypt all of the DEKs that are encrypted with that key. This makes the re-encryption process much quicker and requires less transferring data than re-encrypting the artifacts themselves. In order to safely revoke a key being used by HCP Terraform in your KMS, you must: 1. Revoke the key in HCP Terraform. 1. Wait until all workspaces have been migrated off of the key, which you can check on the the \*\*HYOK Encryption\*\* page. 1. Revoke the key in the KMS itself. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/hold-your-own-key/configure.mdx | main | terraform | [
0.007210952695459127,
0.11570805311203003,
0.04663270339369774,
-0.0079942736774683,
-0.02351437322795391,
-0.011167346499860287,
-0.006350861396640539,
-0.07259125262498856,
-0.0167658943682909,
0.005607604049146175,
0.0034025670029222965,
-0.009435002692043781,
0.08249952644109726,
-0.07... | -0.036365 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Agents and agent pools API reference An Agent Pool represents a group of Agents, often related to one another by sharing a common network segment or purpose. A workspace or Stack may be configured to use one of the organization's agent pools to run remote operations with isolated, private, or on-premises infrastructure. Terraform Enterprise does not currently support Stacks, so any references to Stacks in the following API endpoints only apply to HCP Terraform. @include 'tfc-package-callouts/agents.mdx' ## List Agent Pools `GET /organizations/:organization\_name/agent-pools` | Parameter | Description | | -------------------- | ----------------------------- | | `:organization\_name` | The name of the organization. | This endpoint allows you to list agent pools, their agents, and their tokens for an organization. | Status | Response | Reason | | ------- | --------------------------------------------- | ---------------------- | | [200][] | [JSON API document][] (`type: "agent-pools"`) | Success | | [404][] | [JSON API error object][] | Organization not found | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | |------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `q` | \*\*Optional.\*\* A search query string. Agent pools are searchable by name. | | `sort` | \*\*Optional.\*\* Allows sorting the returned agents pools. Valid values are `"name"` and `"created-at"`. Prepending a hyphen to the sort parameter will reverse the order (e.g. `"-name"`). | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 agent pools per page. | | `filter[allowed\_workspaces][name]` | \*\*Optional.\*\* Filters agent pools to those associated with the given workspace. The workspace must have permission to use the agent pool. Refer to [Scoping Agent Pools to Specific Workspaces](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-workspaces). | | `filter[allowed\_stacks][name]` | \*\*Optional.\*\* Filters agent pools to those associated with the given Stack. The Stack must have permission to use the agent pool. Only available in HCP Terraform, refer to [Scope agent pools](/terraform/cloud-docs/agents#scope-an-agent-pool) to learn more. | | `filter[allowed\_projects][name]` | \*\*Optional.\*\* Filters agent pools to those associated with the given project. The project must have permission to use the agent pool. Refer to [Scoping Agent Pools to Specific Projects](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-projects). | | `filter[allowed\_modules][name]` | \*\*Optional.\*\* Filters agent pools to those configured to process jobs for the given registry module. Only available when the enterprise-testing feature is enabled. | ### Response fields Responses for this endpoint can contain an `attributes` object with the following fields: | Field name | Type | Description | |-------------------------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------| | `data.attributes.agent-count` | number | The number of agents in `Idle`, `Busy` or `Unknown` states. Agents that are `Exited` or `Errored` are excluded. | | `data.attributes.meta.status-counts.total` | number | The total number of resources the filter was applied to. | | `data.attributes.meta.status-counts.matching` | number | The total number of resources returned, which match the filter you applied. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/organizations/my-organization/agent-pools ``` ### Sample Response ```json { "data": [ { "id": "apool-yoGUFz5zcRMMz53i", "type": "agent-pools", "attributes": { "name": "example-pool", "created-at": "2020-08-05T18:10:26.964Z", "organization-scoped": false, "agent-count": 3 }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/authentication-tokens" } }, "workspaces": { "data": [ { "id": "ws-9EEkcEQSA3XgWyGe", "type": "workspaces" } ] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
"name": "example-pool", "created-at": "2020-08-05T18:10:26.964Z", "organization-scoped": false, "agent-count": 3 }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/authentication-tokens" } }, "workspaces": { "data": [ { "id": "ws-9EEkcEQSA3XgWyGe", "type": "workspaces" } ] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": { "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } }, "links": { "self": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i" } } ], "links": { "self": "https://app.terraform.io/api/v2/organizations/my-organization/agent-pools?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/organizations/my-organization/agent-pools?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/organizations/my-organization/agent-pools?page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 1 }, "status-counts": { "total": 1, "matching": 1 } } } ``` ## List Agents `GET /agent-pools/:agent\_pool\_id/agents` | Parameter | Description | | ---------------- | --------------------------------- | | `:agent\_pool\_id` | The ID of the Agent Pool to list. | | Status | Response | Reason | | ------- | ---------------------------------------- | ------------------------------------------------------------ | | [200][] | [JSON API document][] (`type: "agents"`) | Success | | [404][] | [JSON API error object][] | Agent Pool not found, or user unauthorized to perform action | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | ------------------------- | ---------------------------------------------------------------------------- | | `filter[last-ping-since]` | \*\*Optional.\*\* Accepts a date in ISO8601 format (ex. `2020-08-11T10:41:23Z`). | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 agents per page. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/agent-pools/apool-xkuMi7x4LsEnBUdY/agents ``` ### Sample Response ```json { "data": [ { "id": "agent-A726QeosTCpCumAs", "type": "agents", "attributes": { "name": "my-cool-agent", "status": "idle", "ip-address": "123.123.123.123", "last-ping-at": "2020-10-09T18:52:25.246Z" }, "links": { "self": "/api/v2/agents/agent-A726QeosTCpCumAs" } }, { "id": "agent-4cQzjbr1cnM6Pcxr", "type": "agents", "attributes": { "name": "my-other-cool-agent", "status": "exited", "ip-address": "123.123.123.123", "last-ping-at": "2020-08-12T15:25:09.726Z" }, "links": { "self": "/api/v2/agents/agent-4cQzjbr1cnM6Pcxr" } }, { "id": "agent-yEJjXQCucpNxtxd2", "type": "agents", "attributes": { "name": null, "status": "errored", "ip-address": "123.123.123.123", "last-ping-at": "2020-08-11T06:22:20.300Z" }, "links": { "self": "/api/v2/agents/agent-yEJjXQCucpNxtxd2" } } ], "links": { "self": "https://app.terraform.io/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents?page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 3 } } } ``` ## Show an Agent Pool `GET /agent-pools/:id` | Parameter | Description | | --------- | -------------------------------- | | `:id` | The ID of the Agent Pool to show | | Status | Response | Reason | | ------- | --------------------------------------------- | ------------------------------------------------------------ | | [200][] | [JSON API document][] (`type: "agent-pools"`) | Success | | [404][] | [JSON API error object][] | Agent Pool not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd ``` ### Sample Response ```json { "data": { "id": "apool-yoGUFz5zcRMMz53i", "type": "agent-pools", "attributes": { "name": "example-pool", "created-at": "2020-08-05T18:10:26.964Z", "organization-scoped": false }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/authentication-tokens" } }, "workspaces": { "data": [ { "id": "ws-9EEkcEQSA3XgWyGe", "type": "workspaces" } ] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.06419328600168228,
0.06384261697530746,
-0.0333663634955883,
0.03366746008396149,
-0.015717634931206703,
-0.01215977780520916,
-0.0240702535957098,
-0.054839204996824265,
0.05394132062792778,
-0.015623650513589382,
0.012870771810412407,
-0.07066341489553452,
0.018880881369113922,
0.1163... | 0.048591 |
"attributes": { "name": "example-pool", "created-at": "2020-08-05T18:10:26.964Z", "organization-scoped": false }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/authentication-tokens" } }, "workspaces": { "data": [ { "id": "ws-9EEkcEQSA3XgWyGe", "type": "workspaces" } ] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": "workspaces" } ] }, "stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } }, "links": { "self": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i" } } } ``` ## Show an Agent `GET /agents/:id` | Parameter | Description | | --------- | --------------------------- | | `:id` | The ID of the agent to show | | Status | Response | Reason | | ------- | ---------------------------------------- | ------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "agents"`) | Success | | [404][] | [JSON API error object][] | Agent not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/agents/agent-73PJNzbZB5idR7AQ ``` ### Sample Response ```json { "data": { "id": "agent-Zz9PTEcUgBtYzht8", "type": "agents", "attributes": { "name": "my-agent", "status": "busy", "ip-address": "123.123.123.123", "last-ping-at": "2020-09-08T18:47:35.361Z" }, "links": { "self": "/api/v2/agents/agent-Zz9PTEcUgBtYzht8" } } } ``` This endpoint lists details about an agent along with that agent's status. [Learn more about agents statuses](/terraform/cloud-docs/agents/agent-pools#view-agent-statuses). ## Delete an Agent `DELETE /agents/:id` | Parameter | Description | | --------- | ----------------------------- | | `:id` | The ID of the agent to delete | | Status | Response | Reason | | ------- | ------------------------- | ------------------------------------------------------------------------------------------------------------ | | [204][] | No Content | Success | | [412][] | [JSON API error object][] | Agent is not deletable. Agents must have a status of `unknown`, `errored`, or `exited` before being deleted. | | [404][] | [JSON API error object][] | Agent not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request DELETE \ https://app.terraform.io/api/v2/agents/agent-73PJNzbZB5idR7AQ ``` ## Create an Agent Pool `POST /organizations/:organization\_name/agent-pools` | Parameter | Description | | -------------------- | ----------------------------- | | `:organization\_name` | The name of the organization. | This endpoint allows you to create an Agent Pool for an organization. Only one Agent Pool may exist for an organization. | Status | Response | Reason | | ------- | --------------------------------------------- | -------------------------------------------------------------- | | [201][] | [JSON API document][] (`type: "agent-pools"`) | Agent Pool successfully created | | [404][] | [JSON API error object][] | Organization not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### 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 path | Type | Default | Description | |---------------------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `data.type` | string | | Must be `"agent-pools"`. | | `data.attributes.name` | string | | The name of the agent pool, which can only include letters, numbers, `-`, and `\_`. This will be used as an identifier and must be unique in the organization. | | `data.attributes.organization-scoped` | bool | true | The scope of the agent pool. If true, all workspaces in the organization | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.0641876831650734,
0.08457119762897491,
-0.025878818705677986,
0.047925688326358795,
0.011598064564168453,
-0.01392652839422226,
-0.023055020719766617,
-0.07081049680709839,
0.05108373612165451,
-0.006730798631906509,
0.013768722303211689,
-0.07355473935604095,
0.02057230845093727,
0.118... | 0.0385 |
The name of the agent pool, which can only include letters, numbers, `-`, and `\_`. This will be used as an identifier and must be unique in the organization. | | `data.attributes.organization-scoped` | bool | true | The scope of the agent pool. If true, all workspaces in the organization can use the agent pool. | | `data.relationships.allowed-workspaces.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.allowed-workspaces.data.id` | string | | The ID of the workspace that has permission to use the agent pool. Refer to [Scoping Agent Pools to Specific Workspaces](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-workspaces). | | `data.relationships.allowed-stacks.data.type` | string | | Must be `"stacks"`. Only available in HCP Terraform. | | `data.relationships.allowed-stacks.data.id` | string | | The ID of the stack that has permission to use the agent pool. Only available in HCP Terraform, refer to [Scope agent pools](/terraform/cloud-docs/agents#scope-an-agent-pool) to learn more. | | `data.relationships.allowed-projects.data.type` | string | | Must be `"projects"`. Refer to [Scoping Agent Pools to Specific Projects](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-projects). | | `data.relationships.allowed-projects.data.id` | string | | The ID of the project that has permission to use the agent pool. | | `data.relationships.excluded-workspaces.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.excluded-workspaces.data.id` | string | | The ID of the workspace that is excluded from the scope of the agent pool. | | `data.relationships.excluded-stacks.data.type` | string | | Must be `"stacks"`. Only available in HCP Terraform. | | `data.relationships.excluded-stacks.data.id` | string | | The ID of the Stack that is excluded from the scope of the agent pool. Only available in HCP Terraform. | | `data.relationships.allowed-modules.data.type` | string | | Must be `"registry-modules"`. Only available when the enterprise-testing feature is enabled. | | `data.relationships.allowed-modules.data.id` | string | | The ID of the registry module that the agent pool is allowed to process tests for. Only available when the enterprise-testing feature is enabled. | | `data.relationships.excluded-modules.data.type` | string | | Must be `"registry-modules"`. Only available when the enterprise-testing feature is enabled. | | `data.relationships.excluded-modules.data.id` | string | | The ID of the registry module that the agent pool is excluded from processing tests for. Only available when the enterprise-testing feature is enabled. | ### Sample Payload ```json { "data": { "type": "agent-pools", "attributes": { "name": "my-pool", "organization-scoped": false }, "relationships": { "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": "workspaces" } ] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/agent-pools ``` ### Sample Response ```json { "data": { "id": "apool-55jZekR57npjHHYQ", "type": "agent-pools", "attributes": { "name": "my-pool", "created-at": "2020-10-13T16:32:45.165Z", "organization-scoped": false, }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-55jZekR57npjHHYQ/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-55jZekR57npjHHYQ/authentication-tokens" } }, "workspaces": { "data": [] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": "workspaces" } ] }, "stacks": { "data": [] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.02246609330177307,
-0.0341426245868206,
-0.03278510645031929,
0.020357344299554825,
-0.03323924541473389,
-0.015265661291778088,
0.021138738840818405,
-0.1311585158109665,
0.01929585263133049,
0.015195597894489765,
-0.0010240791598334908,
-0.08325579762458801,
0.06124167889356613,
0.058... | 0.022095 |
"allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } }, "links": { "self": "/api/v2/agent-pools/apool-55jZekR57npjHHYQ" } } } ``` ## Update an Agent Pool `PATCH /agent-pools/:id` | Parameter | Description | | --------- | ---------------------------------- | | `:id` | The ID of the Agent Pool to update | | Status | Response | Reason | | ------- | --------------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "agent-pools"`) | Success | | [404][] | [JSON API error object][] | Agent Pool not found, or user unauthorized to perform action | | [422][] | JSON error document | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | |---------------------------------------------------|--------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `data.type` | string | | Must be `"agent-pools"`. | | `data.attributes.name` | string | (previous value) | The name of the agent pool, which can only include letters, numbers, `-`, and `\_`. This will be used as an identifier and must be unique in the organization. | | `data.attributes.organization-scoped` | bool | true | The scope of the agent pool. If true, all workspaces in the organization can use the agent pool. | | `data.relationships.allowed-workspaces.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.allowed-workspaces.data.id` | string | | The ID of the workspace that has permission to use the agent pool. Refer to [Scoping Agent Pools to Specific Workspaces](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-workspaces). | | `data.relationships.allowed-stacks.data.type` | string | | Must be `"stacks"`. Only available in HCP Terraform. | | `data.relationships.allowed-stacks.data.id` | string | | The ID of the Stack that has permission to use the agent pool. Only available in HCP Terraform, refer to [Scope agent pools](/terraform/cloud-docs/agents#scope-an-agent-pool) to learn more. | | `data.relationships.allowed-projects.data.type` | string | | Must be `"projects"`. Refer to [Scoping Agent Pools to Specific Projects](/terraform/cloud-docs/agents#scope-an-agent-pool-to-specific-projects). | | `data.relationships.allowed-projects.data.id` | string | | The ID of the project that has permission to use the agent pool. | | `data.relationships.excluded-workspaces.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.excluded-workspaces.data.id` | string | | The ID of the workspace that is excluded from the scope of the agent pool. | | `data.relationships.excluded-stacks.data.type` | string | | Must be `"stacks"`. Only available in HCP Terraform. | | `data.relationships.excluded-stacks.data.id` | string | | The ID of the Stack that is excluded from the scope of the agent pool. Only available in HCP Terraform. | | `data.relationships.allowed-modules.data.type` | string | | Must be `"registry-modules"`. Only available when the enterprise-testing feature is enabled. | | `data.relationships.allowed-modules.data.id` | string | | The ID of the registry module that the agent pool is allowed to process tests for. Only available when the enterprise-testing feature is enabled. | | `data.relationships.excluded-modules.data.type` | string | | Must be `"registry-modules"`. Only available when the enterprise-testing feature is enabled. | | `data.relationships.excluded-modules.data.id` | string | | The ID of the registry module that the agent pool is excluded from processing tests for. Only available when the enterprise-testing feature is enabled. | ### Sample Payload ```json { "data": { "type": "agent-pools", "attributes": { "name": "example-pool", "organization-scoped": false }, "relationships": { "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.048221029341220856,
0.06678059697151184,
-0.019251596182584763,
0.025383301079273224,
0.04406887665390968,
-0.04840968921780586,
-0.0011046035215258598,
-0.034731291234493256,
-0.012713168747723103,
-0.02990592271089554,
0.08347286283969879,
-0.04652762785553932,
0.011771045625209808,
0... | -0.013127 |
from processing tests for. Only available when the enterprise-testing feature is enabled. | ### Sample Payload ```json { "data": { "type": "agent-pools", "attributes": { "name": "example-pool", "organization-scoped": false }, "relationships": { "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": "workspaces" } ] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } } } } ``` ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd ``` ### Sample Response ```json { "data": { "id": "apool-yoGUFz5zcRMMz53i", "type": "agent-pools", "attributes": { "name": "example-pool", "created-at": "2020-08-05T18:10:26.964Z" }, "relationships": { "agents": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/agents" } }, "authentication-tokens": { "links": { "related": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i/authentication-tokens" } }, "workspaces": { "data": [ { "id": "ws-9EEkcEQSA3XgWyGe", "type": "workspaces" } ] }, "allowed-workspaces": { "data": [ { "id": "ws-x9taqV23mxrGcDrn", "type": "workspaces" } ] }, "excluded-workspaces": "data": [ { "id": "ws-KyBgj8dDRvQqwBCC", "type": "workspaces" } ] }, "stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "allowed-stacks": { "data": [ { "id": "st-udYJjMCsnxU87uur", "type": "stacks" } ] }, "excluded-stacks": "data": [ { "id": "st-ksVruWHkgjHVB8zM", "type": "stacks" } ] }, "allowed-projects": { "data": [ { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects" } ] }, "allowed-modules": { "data": [ { "id": "mod-Xf3VzW5zcRMMz12a", "type": "registry-modules" } ] }, "excluded-modules": { "data": [ { "id": "mod-YgBnkR89vQWer34b", "type": "registry-modules" } ] } }, "links": { "self": "/api/v2/agent-pools/apool-yoGUFz5zcRMMz53i" } } } ``` ## Delete an Agent Pool `DELETE /agent-pools/:agent\_pool\_id` | Parameter | Description | | ---------------- | ------------------------------------- | | `:agent\_pool\_id` | The ID of the agent pool ID to delete | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd ``` ### Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | Resource Name | Description | | -------------- | ------------------------------------------- | | `workspaces` | The workspaces attached to this agent pool. | | `stacks` | The Stacks attached to this agent pool. Only available in HCP Terraform. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agents.mdx | main | terraform | [
-0.05512871593236923,
0.04076641425490379,
-0.029499780386686325,
0.06322474777698517,
-0.002566293813288212,
-0.07687351107597351,
-0.0564952977001667,
-0.07823484390974045,
0.019315095618367195,
-0.023211341351270676,
0.03248005360364914,
-0.044160354882478714,
0.0006404672167263925,
0.0... | 0.059223 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: http://jsonapi.org/format/#error-objects # No-code provisioning API reference The no-code provisioning API allows you to create, configure, and deploy Terraform modules as workspaces in the no-code provisioning workflows within HCP Terraform. For more information on no-code modules, refer to [Designing No-Code Ready Modules](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design). ## Enable no-code provisioning for a module `POST /organizations/:organization\_name/no-code-modules` | Parameter | Description | | -------------------- | ---------------------------------------------------- | | `:organization\_name` | The name of the organization the module belongs to. | To deploy a module using the no-code provisioning workflow, the module must meet the following requirement: 1. The module must exist in your organization's private registry. 1. The module must meet the [design requirements](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design#requirements) for a no-code module. 1. You must enable no-code provisioning for the module. You can send a `POST` request to the `/no-code-modules` endpoint to enable no-code provisioning for a specific module. You can also call this endpoint to set options for the allowed values of a variable for a no-code module in your organization. -> \*\*Note\*\*: This endpoint can not be accessed with [organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens). | Status | Response | Reason | | ------- | ------------------------------------------------- | --------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "no-code-modules"`) | Successfully enabled a module for no-code provisioning. | | [404][] | [JSON API error object][] | Not found, or the user is unauthorized to perform this action. | | [422][] | [JSON API error object][] | Malformed request body (e.g., missing attributes, wrong types, etc.). | | [500][] | [JSON API error object][] | Internal system failure. | ### 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 path | Type | Default | Description | | --- | --- | --- | --- | | `data.type` | string | | Must be `"no-code-modules"`. | | `data.attributes.version-pin` | string | Latest version of the module | The module version to use in no-code provisioning workflows. | | `data.attributes.enabled` | boolean | `false` | Set to `true` to enable no-code provisioning workflows. | | `data.relationships.registry-module.data.id` | string | | The ID of a module in the organization's private registry. | | `data.relationships.registry-module.data.type` | string | | Must be `"registry-module"`. | | `data.relationships.variable-options.data[].type` | string | | Must be `"variable-options"`. | | `data.relationships.variable-options.data[].attributes.variable-name` | string | | The name of a variable within the module. | | `data.relationships.variable-options.data[].attributes.variable-type` | string | | The data type for the variable. Can be [any type supported by Terraform](/terraform/language/expressions/types#types). | | `data.relationships.variable-options.data[].attributes.options` | Any[] | | A list of allowed values for the variable. | ### Sample Payload ```json { "data": { "type": "no-code-modules", "attributes": { "version-pin": "1.0.1", "enabled": true }, "relationships": { "registry-module": { "data": { "id": "mod-2aaFrmRPZs2N9epr", "type": "registry-module" } }, "variable-options": { "data": [ { "type": "variable-options", "attributes": { "variable-name": "amis", "variable-type": "string", "options": [ "ami-1", "ami-2", "ami-3" ] } }, { "type": "variable-options", "attributes": { "variable-name": "region", "variable-type": "string", "options": [ "eu-north-1", "us-east-2", "us-west-1" ] } } ] } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/no-code-modules ``` ### Sample Response ```json { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-modules", "attributes": { "enabled": true, "version-pin": "1.0.1" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/no-code-modules ``` ### Sample Response ```json { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-modules", "attributes": { "enabled": true, "version-pin": "1.0.1" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "registry-module": { "data": { "id": "mod-2aaFrmRPZs2N9epr", "type": "registry-modules" }, "links": { "related": "/api/v2/registry-modules/mod-2aaFrmRPZs2N9epr" } }, "variable-options": { "data": [ { "id": "ncvaropt-fcHDfnZ1EGdRzFNC", "type": "variable-options" }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options" } ] } }, "links": { "self": "/api/v2/no-code-modules/nocode-9HE91XDNY3faePn2" } } } ``` ## Update no-code provisioning settings `PATCH /no-code-modules/:id` | Parameter | Description | | --------- | -------------------------------------------- | | `:id` | The unique identifier of the no-code module. | Send a `PATCH` request to the `/no-code-modules/:id` endpoint to update the settings for the no-code provisioning of a module. You can update the following settings: - Enable or disable no-code provisioning. - Adjust the set of options for allowed variable values. - Change the module version being provisioned. - Change the module being provisioned. The [API call that enables no-code provisioning for a module](#allow-no-code-provisioning-of-a-module-within-an-organization) returns that module's unique identifier. -> \*\*Note:\*\* This endpoint cannot be accessed with [organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens). | Status | Response | Reason | | ------- | ------------------------------------------------- | --------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "no-code-modules"`) | Successfully updated a no-code module. | | [404][] | [JSON API error object][] | Not found, or the user is unauthorized to perform this action. | | [422][] | [JSON API error object][] | Malformed request body (e.g., missing attributes, wrong types, etc.). | | [500][] | [JSON API error object][] | Internal system failure. | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | | --- | --- | --- | --- | | `data.type` | string | | Must be `"no-code-modules"`. | | `data.attributes.version-pin` | string | Existing value | The module version to use in no-code provisioning workflows. | | `data.attributes.enabled` | boolean | Existing value | Set to `true` to enable no-code provisioning workflows, or `false` to disable them. | | `data.relationships.registry-module.data.id` | string | Existing value | The ID of a module in the organization's Private Registry. | | `data.relationships.registry-module.data.type` | string | Existing value | Must be `"registry-module"`. | | `data.relationships.variable-options.data[].id` | string | | The ID of an existing variable-options set. If provided, a new variable-options set replaces the set with this ID. If not provided, this creates a new variable-option set. | | `data.relationships.variable-options.data[].type` | string | | Must be `"variable-options"`. | | `data.relationships.variable-options.data[].attributes.variable-name` | string | | The name of a variable within the module. | | `data.relationships.variable-options.data[].attributes.variable-type` | string | | The data type for the variable. Can be [any type supported by Terraform](/terraform/language/expressions/types#types). | | `data.relationships.variable-options.data[].attributes.options` | Any[] | | A list of allowed values for the variable. | ### Sample Payload ```json { "data": { "type": "no-code-modules", "attributes": { "enabled": false }, "relationships": { "registry-module": { "data": { "id": "mod-zyai9dwH4VPPaVuC", "type": "registry-module" } }, "variable-options": { "data": [ { "id": "ncvaropt-fcHDfnZ1EGdRzFNC", "type": "variable-options", "attributes": { "variable-name": "Linux AMIs", "variable-type": "array", "options": [ "Xenial Xerus", "Trusty Tahr" ] } }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options", "attributes": { "variable-name": "region", "variable-type": "array", "options": [ "eu-north-1", "us-east-2", "us-west-1" ] } } ] } } } } ``` ### Sample Request ```shell curl \ --header | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
-0.040156252682209015,
0.028018290176987648,
-0.013591067865490913,
0.0049933744594454765,
0.0032253190875053406,
-0.052226997911930084,
-0.07630176097154617,
-0.0704609602689743,
0.04743892326951027,
0.09427715837955475,
0.009012586437165737,
-0.09283937513828278,
-0.0007887007668614388,
... | 0.029209 |
"type": "variable-options", "attributes": { "variable-name": "Linux AMIs", "variable-type": "array", "options": [ "Xenial Xerus", "Trusty Tahr" ] } }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options", "attributes": { "variable-name": "region", "variable-type": "array", "options": [ "eu-north-1", "us-east-2", "us-west-1" ] } } ] } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/no-code-modules/nocode-9HE91XDNY3faePn2 ``` ### Sample Response ```json { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-modules", "attributes": { "enabled": true, "version-pin": "1.0.1" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "registry-module": { "data": { "id": "mod-2aaFrmRPZs2N9epr", "type": "registry-modules" }, "links": { "related": "/api/v2/registry-modules/mod-2aaFrmRPZs2N9epr" } }, "variable-options": { "data": [ { "id": "ncvaropt-fcHDfnZ1EGdRzFNC", "type": "variable-options" }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options" } ] } }, "links": { "self": "/api/v2/no-code-modules/nocode-9HE91XDNY3faePn2" } } } ``` ## Read a no-code module's properties `GET /no-code-modules/:id` | Parameter | Description | | --------- | -------------------------------------------- | | `:id` | The unique identifier of the no-code module. | Use this API to read the details of an existing no-code module. The [API call that enables no-code provisioning for a module](#allow-no-code-provisioning-of-a-module-within-an-organization) returns that module's unique identifier. | Status | Response | Reason | | ------- | ------------------------------------------------- | --------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "no-code-modules"`) | Successfully read the no-code module. | | [400][] | [JSON API error object][] | Invalid `include` parameter. | | [404][] | [JSON API error object][] | Not found, or the user is unauthorized to perform this action. | | [422][] | [JSON API error object][] | Malformed request body (e.g., missing attributes, wrong types, etc.). | | [500][] | [JSON API error object][] | Internal system failure. | ### Query Parameters This endpoint uses our [standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Use HTML URL encoding syntax, such as `%5B` to represent `[` and `%5D` to represent `]`, if your tooling does not automatically encode URLs. Terraform returns related resources when you add the [`include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources) to the request. | Parameter | Description | | --------- | ------------------------------------------------- | | `include` | List related resource to include in the response. | The following resource types are available: | Resource Name | Description | | ------------------ | --------------------------------------------------------- | | `variable\_options` | Module variables with a configured set of allowed values. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/no-code-modules/nocode-9HE91XDNY3faePn2?include=variable\_options ``` ### Sample Response ```json { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-modules", "attributes": { "enabled": true, "version-pin": "1.0.1" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "registry-module": { "data": { "id": "mod-2aaFrmRPZs2N9epr", "type": "registry-modules" }, "links": { "related": "/api/v2/registry-modules/mod-2aaFrmRPZs2N9epr" } }, "variable-options": { "data": [ { "id": "ncvaropt-fcHDfnZ1EGdRzFNC", "type": "variable-options" }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options" } ] } }, "links": { "self": "/api/v2/no-code-modules/nocode-9HE91XDNY3faePn2" } }, "included": [ { "id": "ncvaropt-fcHDfnZ1EGdRzFNC", "type": "variable-options", "attributes": { "variable-name": "Linux AMIs", "variable-type": "array", "options": [ "Xenial Xerus", "Trusty Tahr" ] }, "relationships": { "no-code-allowed-module": { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-allowed-modules" } } } }, { "id": "ncvaropt-dZMfdh9KBcwFjyv2", "type": "variable-options", "attributes": { "variable-name": "region", "variable-type": "array", "options": [ "eu-north-1", "us-east-2", "us-west-1" ] }, "relationships": { "no-code-allowed-module": { "data": { "id": "nocode-9HE91XDNY3faePn2", "type": "no-code-allowed-modules" } } } } ] } ``` ## Create a no-code module workspace This endpoint creates a workspace from a no-code module. `POST /no-code-modules/:id/workspaces` | Parameter | Description | | -------------------- | ------------------------------------------ | | `:id` | The ID of the no-code module to provision. | Each HCP Terraform organization has a list | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
0.031221099197864532,
0.09979099035263062,
-0.03386741131544113,
-0.024952510371804237,
-0.004481672775000334,
-0.027809247374534607,
0.01561108697205782,
-0.002708651125431061,
0.003291209228336811,
0.06389762461185455,
-0.007830356247723103,
-0.13906624913215637,
0.0057445610873401165,
0... | 0.039026 |
} ] } ``` ## Create a no-code module workspace This endpoint creates a workspace from a no-code module. `POST /no-code-modules/:id/workspaces` | Parameter | Description | | -------------------- | ------------------------------------------ | | `:id` | The ID of the no-code module to provision. | Each HCP Terraform organization has a list of which modules you can use to create workspaces using no-code provisioning. You can use this API to create a workspace by selecting a no-code module to enable a no-code provisioning workflow. -> \*\*Note\*\*: This endpoint can not be accessed with [organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens). | Status | Response | Reason | | ------- | -------------------------------------------- | -------------------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "workspaces"`) | Successfully created a workspace from a no-code module for no-code provisioning. | | [404][] | [JSON API error object][] | Not found, or the user is unauthorized to perform this action. | | [422][] | [JSON API error object][] | Malformed request body (e.g., missing attributes, wrong types, etc.). | | [500][] | [JSON API error object][] | Internal system failure. | ### 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 path | Type | Default | Description | | --- | --- | --- | --- | | `data.type` | string | none | Must be `"workspaces"`. | | `data.attributes.agent-pool-id` | string | none | Required when `execution-mode` is set to `agent`. The ID of the agent pool belonging to the workspace's organization. This value must not be specified if `execution-mode` is set to `remote`. | | | `data.attributes.auto\_apply` | boolean | `false` | If `true`, Terraform automatically applies changes when a Terraform `plan` is successful. | | `data.attributes.description` | string | `""` | A description for the workspace. | | `data.attributes.execution-mode` | string | none | Which [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) to use. Valid values are `remote`, and `agent`. When not provided, defaults to `remote`. | | | `data.attributes.name` | string | none | The name of the workspace. You can only include letters, numbers, `-`, and `\_`. Terraform uses this value to identify the workspace and must be unique in the organization. | | `data.attributes.source-name` | string | none | A friendly name for the application or client creating this workspace. If set, this will be displayed on the workspace as "Created via ``". | | | `data.attributes.source-url` | string | (nothing) | A URL for the application or client creating this workspace. This can be the URL of a related resource in another app, or a link to documentation or other info about the client. | | | `data.attributes.terraform-version` | string | latest release | Specifies the version of Terraform to use for this workspace. You can specify an exact version or a [version constraint](/terraform/language/expressions/version-constraints) such as `~> 1.0.0`. If you specify a constraint, the workspace always uses the newest release that meets that constraint. If omitted when creating a workspace, this defaults to the latest released version. | | `data.relationships.project.data.id` | string | | The ID of the project to create the workspace in. You must have permission to create workspaces in the project, either by organization-level permissions or team admin access to a specific project. | | `data.relationships.project.data.type` | string | | Must be `"project"`. | | `data.relationships.vars.data[].type` | string | | Must be `"vars"`. | | `data.relationships.vars.data[].attributes.key` | string | | The name of the variable. | | `data.relationships.vars.data[].attributes.value` | string | `""` | The value of the variable. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
-0.048713572323322296,
-0.021613048389554024,
-0.052898868918418884,
0.011241206899285316,
-0.040495824068784714,
-0.005051031708717346,
-0.04276798665523529,
-0.06684858351945877,
0.0004102753009647131,
0.0421723835170269,
0.007701788563281298,
-0.0917513445019722,
0.04930087924003601,
-0... | 0.054447 |
to a specific project. | | `data.relationships.project.data.type` | string | | Must be `"project"`. | | `data.relationships.vars.data[].type` | string | | Must be `"vars"`. | | `data.relationships.vars.data[].attributes.key` | string | | The name of the variable. | | `data.relationships.vars.data[].attributes.value` | string | `""` | The value of the variable. | | `data.relationships.vars.data[].attributes.description` | string | | The description of the variable. | | `data.relationships.vars.data[].attributes.category` | string | | Whether this is a Terraform or environment variable. Valid values are `"terraform"` or `"env"`. | | `data.relationships.vars.data[].attributes.hcl` | boolean | `false` | Whether to evaluate the value of the variable as a string of HCL code. Has no effect for environment variables. | | `data.relationships.vars.data[].attributes.sensitive` | boolean | `false` | Whether the value is sensitive. If `true` then the variable is written once and not visible thereafter. | ### Sample Payload ```json { "data": { "type": "workspaces", "attributes": { "name": "no-code-workspace", "description": "A workspace to enable the no-code provisioning workflow." }, "relationships": { "project": { "data": { "id": "prj-yuEN6sJVra5t6XVy", "type": "project" } }, "vars": { "data": [ { "type": "vars", "attributes": { "key": "region", "value": "eu-central-1", "category": "terraform", "hcl": true, "sensitive": false, } }, { "type": "vars", "attributes": { "key": "ami", "value": "ami‑077062", "category": "terraform", "hcl": true, "sensitive": false, } } ] } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/no-code-modules/nocode-WGckovT2RQxupyt1/workspaces ``` ### Sample Response ```json { "data": { "id": "ws-qACTToFUM5BvDKhC", "type": "workspaces", "attributes": { "allow-destroy-plan": true, "auto-apply": false, "auto-destroy-at": null, "auto-destroy-status": null, "created-at": "2023-09-08T10:36:04.391Z", "environment": "default", "locked": false, "name": "no-code-workspace", "queue-all-runs": false, "speculative-enabled": true, "structured-run-output-enabled": true, "terraform-version": "1.5.6", "working-directory": null, "global-remote-state": true, "updated-at": "2023-09-08T10:36:04.427Z", "resource-count": 0, "apply-duration-average": null, "plan-duration-average": null, "policy-check-failures": null, "run-failures": null, "workspace-kpis-runs-count": null, "latest-change-at": "2023-09-08T10:36:04.391Z", "operations": true, "execution-mode": "remote", "vcs-repo": null, "vcs-repo-identifier": null, "permissions": { "can-update": true, "can-destroy": true, "can-queue-run": true, "can-read-variable": true, "can-update-variable": true, "can-read-state-versions": true, "can-read-state-outputs": true, "can-create-state-versions": true, "can-queue-apply": true, "can-lock": true, "can-unlock": true, "can-force-unlock": true, "can-read-settings": true, "can-manage-tags": true, "can-manage-run-tasks": true, "can-force-delete": true, "can-manage-assessments": true, "can-manage-ephemeral-workspaces": true, "can-read-assessment-results": true, "can-queue-destroy": true }, "actions": { "is-destroyable": true }, "description": null, "file-triggers-enabled": true, "trigger-prefixes": [], "trigger-patterns": [], "assessments-enabled": false, "last-assessment-result-at": null, "source": "tfe-module", "source-name": null, "source-url": null, "source-module-id": "private/my-organization/lambda/aws/1.0.9", "no-code-upgrade-available": false, "tag-names": [], "setting-overwrites": { "execution-mode": false, "agent-pool": false } }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, "current-run": { "data": null }, "latest-run": { "data": null }, "outputs": { "data": [] }, "remote-state-consumers": { "links": { "related": "/api/v2/workspaces/ws-qACTToFUM5BvDKhC/relationships/remote-state-consumers" } }, "current-state-version": { "data": null }, "current-configuration-version": { "data": { "id": "cv-vizi2p3mnrt3utgA", "type": "configuration-versions" }, "links": { "related": "/api/v2/configuration-versions/cv-vizi2p3mnrt3utgA" } }, "agent-pool": { "data": null }, "readme": { "data": null }, "project": { "data": { "id": "prj-yuEN6sJVra5t6XVy", "type": "projects" } }, "current-assessment-result": { "data": null }, "no-code-module-version": { "data": { "id": "nocodever-vFcQjZLs3ZHTe4TU", "type": "no-code-module-versions" } }, "vars": { "data": [] } }, "links": { "self": "/api/v2/organizations/my-organization/workspaces/no-code-workspace", "self-html": "/app/my-organization/workspaces/no-code-workspace" } } } ``` ## Initiate a no-code workspace update Upgrading a workspace's no-code provisioning settings is a multi-step process. 1. Use this API to initiate the update. HCP Terraform starts a new plan, which describes the resources to add, update, or remove from the workspace. 1. Poll the [read workspace upgrade plan status API](#read-workspace-upgrade-plan-status) to wait for HCP Terraform to complete the plan. 1. Use the [confirm and apply a workspace upgrade plan API](#confirm-and-apply-a-workspace-upgrade-plan) to complete the workspace upgrade. `POST /no-code-modules/:no\_code\_module\_id/workspaces/:id/upgrade` | Parameter | Description | | -------------------- | -------------------------------| | `:no\_code\_module\_id` | The ID of the no-code module. | | `:id` | The ID of the workspace. | ### Request Body This POST | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
0.01226906105875969,
0.040051575750112534,
-0.025535576045513153,
0.023036707192659378,
-0.0298427976667881,
0.004428006708621979,
0.022771459072828293,
-0.07444579154253006,
0.008645921014249325,
0.022624868899583817,
0.010448403656482697,
-0.14133678376674652,
0.08468394726514816,
0.0077... | -0.071915 |
Use the [confirm and apply a workspace upgrade plan API](#confirm-and-apply-a-workspace-upgrade-plan) to complete the workspace upgrade. `POST /no-code-modules/:no\_code\_module\_id/workspaces/:id/upgrade` | Parameter | Description | | -------------------- | -------------------------------| | `:no\_code\_module\_id` | The ID of the no-code module. | | `:id` | The ID of the workspace. | ### 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 path | Type | Default | Description | --- | --- | --- | --- | `data.type` | string | | Must be `"workspaces"`. | `data.relationships.vars.data[].type` | string | | Must be `"vars"`. | | `data.relationships.vars.data[].attributes.key` | string | | The name of the variable. | | `data.relationships.vars.data[].attributes.value` | string | `""` | The value of the variable. | | `data.relationships.vars.data[].attributes.description` | string | | The description of the variable. | | `data.relationships.vars.data[].attributes.category` | string | | Whether this is a Terraform or environment variable. Valid values are `"terraform"` or `"env"`. | | `data.relationships.vars.data[].attributes.hcl` | boolean | `false` | Whether to evaluate the value of the variable as a string of HCL code. Has no effect for environment variables. | | `data.relationships.vars.data[].attributes.sensitive` | boolean | `false` | Whether the value is sensitive. If `true` then the variable is written once and not visible thereafter. | ### Sample Payload ```json { "data": { "type": "workspaces", "relationships": { "vars": { "data": [ { "type": "vars", "attributes": { "key": "region", "value": "eu-central-1", "category": "terraform", "hcl": true, "sensitive": false } }, { "type": "vars", "attributes": { "key": "ami", "value": "ami‑077062", "category": "terraform", "hcl": true, "sensitive": false } } ] } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/no-code-modules/nocode-WGckovT2RQxupyt1/workspaces/ws-qACTToFUM5BvDKhC/upgrade ``` ### Sample Response ```json { "data": { "id": "run-Cyij8ctBHM1g5xdX", "type": "workspace-upgrade", "attributes": { "status": "planned", "plan-url": "https://app.terraform.io/app/my-organization/no-code-workspace/runs/run-Cyij8ctBHM1g5xdX" }, "relationships": { "workspace": { "data": { "id": "ws-VvKtcfueHNkR6GqP", "type": "workspaces" } } } } } ``` ## Read workspace upgrade plan status This endpoint returns the plan details and status for updating a workspace to new no-code provisioning settings. `GET /no-code-modules/:no\_code\_module\_id/workspaces/:workspace\_id/upgrade/:id` | Parameter | Description | | -------------------- | -------------------------------| | `:no\_code\_module\_id` | The ID of the no-code module. | | `:workspace\_id` | The ID of workspace. | | `:id` | The ID of update. | Returns the details of a no-code workspace update run, including the run's current state, such as `pending`, `fetching`, `planning`, `planned`, or `cost\_estimated`. Refer to [Run States and Stages](/terraform/enterprise/run/states) for more information on the states a run can return. | Status | Response | Reason | | ------- | ------------------------------------------------------- | --------------------------------------------------------------------| | [200][] | [JSON API document][] (`type: "workspace-upgrade"`) | Success | | [404][] | [JSON API error object][] | Workspace upgrade not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/no-code-modules/nocode-WGckovT2RQxupyt1/workspaces/ws-qACTToFUM5BvDKhC/upgrade/run-Cyij8ctBHM1g5xdX ``` ### Sample Response ```json { "data": { "id": "run-Cyij8ctBHM1g5xdX", "type": "workspace-upgrade", "attributes": { "status": "planned\_and\_finished", "plan-url": "https://app.terraform.io/app/my-organization/no-code-workspace/runs/run-Cyij8ctBHM1g5xdX" }, "relationships": { "workspace": { "data": { "id": "ws-VvKtcfueHNkR6GqP", "type": "workspaces" } } } } } ``` ## Confirm and apply a workspace upgrade plan Use this endpoint to confirm an update and finalize the update for a workspace to use new no-code provisioning settings. `POST /no-code-modules/:no\_code\_module\_id/workspaces/:workspace\_id/upgrade/:id` | Parameter | Description | | -------------------- | -------------------------------| | `:no\_code\_module\_id` | The ID of the no-code module. | | `:workspace\_id` | The ID of workspace. | | `:id` | The ID of update. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
-0.09345629066228867,
-0.016847660765051842,
-0.026729073375463486,
0.0297586340457201,
-0.018226591870188713,
-0.05470846965909004,
-0.04123184084892273,
-0.031215965747833252,
0.0003922314790543169,
0.007965724915266037,
0.017414463683962822,
-0.05581926926970482,
-0.004723688587546349,
... | -0.024252 |
provisioning settings. `POST /no-code-modules/:no\_code\_module\_id/workspaces/:workspace\_id/upgrade/:id` | Parameter | Description | | -------------------- | -------------------------------| | `:no\_code\_module\_id` | The ID of the no-code module. | | `:workspace\_id` | The ID of workspace. | | `:id` | The ID of update. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ https://app.terraform.io/api/v2/no-code-modules/nocode-WGckovT2RQxupyt1/workspaces/ws-qACTToFUM5BvDKhC/upgrade/run-Cyij8ctBHM1g5xdX ``` ### Sample Response ```json { "Workspace update completed" } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/no-code-provisioning.mdx | main | terraform | [
-0.047363270074129105,
0.01419783290475607,
-0.0449540801346302,
0.010341839864850044,
0.00041750181117095053,
-0.06514513492584229,
-0.07171362638473511,
-0.058070167899131775,
0.028985915705561638,
0.1239788830280304,
0.02898346446454525,
-0.0729038342833519,
0.020331313833594322,
-0.033... | 0.020736 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Variables API reference ~> \*\*Important\*\*: The Variables API is \*\*deprecated\*\* and will be removed in a future release. All existing integrations with this API should transition to the [Workspace Variables API](/terraform/cloud-docs/api-docs/workspace-variables). This set of APIs covers create, update, list and delete operations on variables. ## Create a Variable `POST /vars` ### 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 path | Type | Default | Description | | ---------------------------------------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"vars"`. | | `data.attributes.key` | string | | The name of the variable. | | `data.attributes.value` | string | `""` | The value of the variable. | | `data.attributes.description` | string | | The description of the variable. | | `data.attributes.category` | string | | Whether this is a Terraform or environment variable. Valid values are `"terraform"` or `"env"`. | | `data.attributes.hcl` | bool | `false` | Whether to evaluate the value of the variable as a string of HCL code. Has no effect for environment variables. | | `data.attributes.sensitive` | bool | `false` | Whether the value is sensitive. If true then the variable is written once and not visible thereafter. | | `data.relationships.workspace.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.workspace.data.id` | string | | The ID of the workspace that owns the variable. Obtain workspace IDs from the [workspace settings](/terraform/cloud-docs/workspaces/settings) or the [Show Workspace](/terraform/cloud-docs/api-docs/workspaces#show-workspace) endpoint. | \*\*Deprecation warning\*\*: The custom `filter` properties are replaced by JSON API `relationships` and will be removed from future versions of the API! | Key path | Type | Default | Description | | -------------------------- | ------ | ------- | ----------------------------------------------------- | | `filter.workspace.name` | string | | The name of the workspace that owns the variable. | | `filter.organization.name` | string | | The name of the organization that owns the workspace. | ### Sample Payload ```json { "data": { "type":"vars", "attributes": { "key":"some\_key", "value":"some\_value", "description":"some description", "category":"terraform", "hcl":false, "sensitive":false }, "relationships": { "workspace": { "data": { "id":"ws-4j8p6jX1w33MiDC7", "type":"workspaces" } } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/vars ``` ### Sample Response ```json { "data": { "id":"var-EavQ1LztoRTQHSNT", "type":"vars", "attributes": { "key":"some\_key", "value":"some\_value", "description":"some description", "sensitive":false, "category":"terraform", "hcl":false }, "relationships": { "configurable": { "data": { "id":"ws-4j8p6jX1w33MiDC7", "type":"workspaces" }, "links": { "related":"/api/v2/organizations/my-organization/workspaces/my-workspace" } } }, "links": { "self":"/api/v2/vars/var-EavQ1LztoRTQHSNT" } } } ``` ## List Variables `GET /vars` ### Query Parameters [These are standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | ---------------------------- | -------------------------------------------------------------------------- | | `filter[workspace][name]` | \*\*Required\*\* The name of one workspace to list variables for. | | `filter[organization][name]` | \*\*Required\*\* The name of the organization that owns the desired workspace. | These two parameters are optional but linked; if you include one, you must include both. Without a filter, this method lists variables for all workspaces where you have permission to read variables. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ "https://app.terraform.io/api/v2/vars?filter%5Borganization%5D%5Bname%5D=my-organization&filter%5Bworkspace%5D%5Bname%5D=my-workspace" # ?filter[organization][name]=my-organization&filter[workspace][name]=demo01 ``` ### Sample Response ```json { "data": [ { "id":"var-AD4pibb9nxo1468E", "type":"vars","attributes": { "key":"name", "value":"hello", | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/variables.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
lists variables for all workspaces where you have permission to read variables. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ "https://app.terraform.io/api/v2/vars?filter%5Borganization%5D%5Bname%5D=my-organization&filter%5Bworkspace%5D%5Bname%5D=my-workspace" # ?filter[organization][name]=my-organization&filter[workspace][name]=demo01 ``` ### Sample Response ```json { "data": [ { "id":"var-AD4pibb9nxo1468E", "type":"vars","attributes": { "key":"name", "value":"hello", "description":"some description", "sensitive":false, "category":"terraform", "hcl":false }, "relationships": { "configurable": { "data": { "id":"ws-cZE9LERN3rGPRAmH", "type":"workspaces" }, "links": { "related":"/api/v2/organizations/my-organization/workspaces/my-workspace" } } }, "links": { "self":"/api/v2/vars/var-AD4pibb9nxo1468E" } } ] } ``` ## Update Variables `PATCH /vars/:variable\_id` | Parameter | Description | | -------------- | ------------------------------------- | | `:variable\_id` | The ID of the variable to be updated. | ### 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 path | Type | Default | Description | | ----------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"vars"`. | | `data.id` | string | | The ID of the variable to update. | | `data.attributes` | object | | New attributes for the variable. This object can include `key`, `value`, `description`, `category`, `hcl`, and `sensitive` properties, which are described above under [create a variable](#create-a-variable). All of these properties are optional; if omitted, a property will be left unchanged. | ### Sample Payload ```json { "data": { "id":"var-yRmifb4PJj7cLkMG", "attributes": { "key":"name", "value":"mars", "description": "new description", "category":"terraform", "hcl": false, "sensitive": false }, "type":"vars" } } ``` ### Sample Request ```bash $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/vars/var-yRmifb4PJj7cLkMG ``` ### Sample Response ```json { "data": { "id":"var-yRmifb4PJj7cLkMG", "type":"vars", "attributes": { "key":"name", "value":"mars", "description":"new description", "sensitive":false, "category":"terraform", "hcl":false }, "relationships": { "configurable": { "data": { "id":"ws-4j8p6jX1w33MiDC7", "type":"workspaces" }, "links": { "related":"/api/v2/organizations/workspace-v2-06/workspaces/workspace-v2-06" } } }, "links": { "self":"/api/v2/vars/var-yRmifb4PJj7cLkMG" } } } ``` ## Delete Variables `DELETE /vars/:variable\_id` | Parameter | Description | | -------------- | ------------------------------------- | | `:variable\_id` | The ID of the variable to be deleted. | ### Sample Request ```bash $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/vars/var-yRmifb4PJj7cLkMG ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/variables.mdx | main | terraform | [
0.017927449196577072,
0.08204977959394455,
0.0023871459998190403,
0.04897720366716385,
0.019716015085577965,
-0.04976760223507881,
0.024242637678980827,
-0.0798524022102356,
0.054437629878520966,
0.05866941437125206,
-0.0025917969178408384,
-0.08326403796672821,
-0.007506649009883404,
0.04... | -0.001515 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # OAuth client API reference An OAuth client represents the connection between an organization and a VCS provider. By default, you can globally access an OAuth client throughout the organization, or you can have scope access to one or more [projects](/terraform/cloud-docs/projects/manage). ## List OAuth Clients `GET /organizations/:organization\_name/oauth-clients` | Parameter | Description | | -------------------- | ----------------------------- | | `:organization\_name` | The name of the organization. | This endpoint allows you to list VCS connections between an organization and a VCS provider (GitHub, Bitbucket, or GitLab) for use when creating or setting up workspaces. | Status | Response | Reason | | ------- | ----------------------------------------------- | ---------------------- | | [200][] | [JSON API document][] (`type: "oauth-clients"`) | Success | | [404][] | [JSON API error object][] | Organization not found | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. If neither pagination query parameters are provided, the endpoint will not be paginated and will return all results. | Parameter | Description | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 oauth clients per page. | | `show\_affected\_workspaces` | \*\*Optional.\*\* If set to `true`, the endpoint will return names of up to 25 affected workspaces and the total number of affected workspaces for each oauth client. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/organizations/my-organization/oauth-clients?show\_affected\_workspaces=true ``` ### Sample Response ```json { "data": [ { "id": "oc-XKFwG6ggfA9n7t1K", "type": "oauth-clients", "attributes": { "created-at": "2018-04-16T20:42:53.771Z", "callback-url": "https://app.terraform.io/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a/callback", "connect-path": "/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a?organization\_id=1", "service-provider": "github", "service-provider-display-name": "GitHub", "name": null, "http-url": "https://github.com", "api-url": "https://api.github.com", "key": null, "rsa-public-key": null, "organization-scoped": false, "affected-workspaces": [ "ws-1", "ws-2" ], "affected-workspaces-count": 2 }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "oauth-tokens": { "data": [], "links": { "related": "/api/v2/oauth-clients//oauth-tokens" } }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckpK", "type": "agent-pools" }, "links": { "related": "/api/v2/agent-pools/apool-VsmjEMcYkShrckpK" } } } } ] } ``` ## Show an OAuth Client `GET /oauth-clients/:id` | Parameter | Description | | --------- | ---------------------------------- | | `:id` | The ID of the OAuth Client to show | | Status | Response | Reason | | ------- | ----------------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "oauth-clients"`) | Success | | [404][] | [JSON API error object][] | OAuth Client not found, or user unauthorized to perform action | ### Query Parameters | Parameter | Description | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | `show\_affected\_workspaces` | \*\*Optional.\*\* If set to `true`, the endpoint will return names of up to 25 affected workspaces and the total number of affected workspaces. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K?show\_affected\_workspaces=true ``` ### Sample Response ```json { "data": { "id": "oc-XKFwG6ggfA9n7t1K", "type": "oauth-clients", "attributes": { "created-at": "2018-04-16T20:42:53.771Z", "callback-url": "https://app.terraform.io/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a/callback", "connect-path": "/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a?organization\_id=1", "service-provider": "github", "service-provider-display-name": "GitHub", "name": null, "http-url": "https://github.com", "api-url": "https://api.github.com", "key": null, "rsa-public-key": null, "organization-scoped": false, "affected-workspaces": [ "ws-1", "ws-2" ], "affected-workspaces-count": 2 }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
"type": "oauth-clients", "attributes": { "created-at": "2018-04-16T20:42:53.771Z", "callback-url": "https://app.terraform.io/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a/callback", "connect-path": "/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a?organization\_id=1", "service-provider": "github", "service-provider-display-name": "GitHub", "name": null, "http-url": "https://github.com", "api-url": "https://api.github.com", "key": null, "rsa-public-key": null, "organization-scoped": false, "affected-workspaces": [ "ws-1", "ws-2" ], "affected-workspaces-count": 2 }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "oauth-tokens": { "data": [], "links": { "related": "/api/v2/oauth-clients//oauth-tokens" } }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckpK", "type": "agent-pools" }, "links": { "related": "/api/v2/agent-pools/apool-VsmjEMcYkShrckpK" } } } } } ``` ## Create an OAuth Client `POST /organizations/:organization\_name/oauth-clients` | Parameter | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:organization\_name` | The name of the organization that will be connected to the VCS provider. The organization must already exist in the system, and the user must have permission to manage VCS settings. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) | [permissions-citation]: #intentionally-unused---keep-for-maintainers This endpoint allows you to create a VCS connection between an organization and a VCS provider (GitHub or GitLab) for use when creating or setting up workspaces. By using this API endpoint, you can provide a pre-generated OAuth token string instead of going through the process of creating a GitHub or GitLab OAuth Application. To learn how to generate one of these token strings for your VCS provider, you can read the following documentation: \* [GitHub and GitHub Enterprise](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) \* [GitLab, GitLab Community Edition, and GitLab Enterprise Edition](https://docs.gitlab.com/ee/user/profile/personal\_access\_tokens.html#create-a-personal-access-token) \* [Azure DevOps Server](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops-2019&tabs=preview-page) | Status | Response | Reason | | ------- | ----------------------------------------------- | -------------------------------------------------------------- | | [201][] | [JSON API document][] (`type: "oauth-clients"`) | OAuth Client successfully created | | [404][] | [JSON API error object][] | Organization not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### 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 path | Type | Default | Description | | ------------------------------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"oauth-clients"`. | | `data.attributes.service-provider` | string | | The VCS provider being connected with. Valid options are `"github"`, `"github\_enterprise"`, `"gitlab\_hosted"`, `"gitlab\_community\_edition"`, `"gitlab\_enterprise\_edition"`, or `"ado\_server"`. | | `data.attributes.name` | string | `null` | An optional display name for the OAuth Client. If left `null`, the UI will default to the display name of the VCS provider. | | `data.attributes.key` | string | | The OAuth Client key. It can refer to a Consumer Key, Application Key, or another type of client key for the VCS provider. | | `data.attributes.http-url` | string | | The homepage of your VCS provider (e.g. `"https://github.com"` or `"https://ghe.example.com"` or `"https://gitlab.com"`). | | `data.attributes.api-url` | string | | The base URL as per your VCS provider's API documentation (e.g. `"https://api.github.com"`, `"https://ghe.example.com/api/v3"` or `"https://gitlab.com/api/v4"`). | | `data.attributes.oauth-token-string` | string | | The token string you were given by your VCS provider | | `data.attributes.private-key` | string | | \*\*Required for Azure DevOps Server. Not used for any other providers.\*\* The text of the SSH private key associated with your Azure DevOps Server account. | | `data.attributes.secret` | string | | The OAuth client secret. For Bitbucket Data Center, the secret is the text of the SSH private key associated with your Bitbucket Data Center application link. | | `data.attributes.rsa-public-key` | string | | \*\*Required for Bitbucket Data Center in conjunction with the `secret`. Not used for any other providers.\*\* The text of the SSH public key associated with your Bitbucket Data Center | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.052061837166547775,
0.0087739247828722,
-0.05370697006583214,
0.007356739137321711,
-0.005705640185624361,
-0.06709369271993637,
-0.05515936017036438,
-0.06697338074445724,
0.08214970678091049,
0.10228807479143143,
-0.002299221698194742,
-0.037163738161325455,
0.059144988656044006,
0.02... | 0.001392 |
text of the SSH private key associated with your Bitbucket Data Center application link. | | `data.attributes.rsa-public-key` | string | | \*\*Required for Bitbucket Data Center in conjunction with the `secret`. Not used for any other providers.\*\* The text of the SSH public key associated with your Bitbucket Data Center application link. | | `data.attributes.organization-scoped` | boolean | | Whether or not the OAuth client is scoped to all projects and workspaces in the organization. Defaults to `true`. | `data.relationships.projects.data[]` | array\[object] | `[]` | A list of resource identifier objects that defines which projects are associated with the OAuth client. If `data.attributes.organization-scoped` is set to `false`, the OAuth client is only available to this list of projects. Each object in this list must contain a project `id` and use the `"projects"` type. For example, `{ "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }`. | | `data.relationships.agent-pool.data` | object | `{}` | The Agent Pool associated to the VCS connection. This pool will be responsible for forwarding VCS Provider API calls and cloning VCS repositories. | ### Sample Payload ```json { "data": { "type": "oauth-clients", "attributes": { "service-provider": "github", "http-url": "https://github.com", "api-url": "https://api.github.com", "oauth-token-string": "4306823352f0009d0ed81f1b654ac17a", "organization-scoped": false }, "relationships": { "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckzzz", "type": "agent-pools" } } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/oauth-clients ``` ### Sample Response ```json { "data": { "id": "oc-XKFwG6ggfA9n7t1K", "type": "oauth-clients", "attributes": { "created-at": "2018-04-16T20:42:53.771Z", "callback-url": "https://app.terraform.io/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a/callback", "connect-path": "/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a?organization\_id=1", "service-provider": "github", "service-provider-display-name": "GitHub", "name": null, "http-url": "https://github.com", "api-url": "https://api.github.com", "key": null, "rsa-public-key": null, "organization-scoped": false }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "oauth-tokens": { "data": [], "links": { "related": "/api/v2/oauth-clients//oauth-tokens" } }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckzzz", "type": "agent-pools" } } } } } ``` ## Update an OAuth Client `PATCH /oauth-clients/:id` | Parameter | Description | | --------- | ------------------------------------- | | `:id` | The ID of the OAuth Client to update. | Use caution when changing attributes with this endpoint; editing an OAuth client that workspaces are currently using can have unexpected effects. | Status | Response | Reason | | ------- | ----------------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "oauth-clients"`) | The request was successful | | [404][] | [JSON API error object][] | OAuth Client not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | Description | | -------------------------------- | ------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"oauth-clients"`. | | `data.attributes.name` | string | (previous value) | An optional display name for the OAuth Client. If set to `null`, the UI will default to the display name of the VCS provider. | | `data.attributes.key` | string | (previous value) | The OAuth Client key. It can refer to a Consumer Key, Application Key, or another type of client key for the VCS provider. | | `data.attributes.secret` | string | (previous value) | The OAuth client secret. For Bitbucket Data Center, this secret is the text of the SSH private key associated with your Bitbucket Data Center application link. | | `data.attributes.rsa-public-key` | string | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.027904268354177475,
0.03090037778019905,
-0.10470100492238998,
0.08336854726076126,
0.026674814522266388,
-0.031643930822610855,
0.005092035047709942,
-0.05068246275186539,
0.07490882277488708,
0.026081349700689316,
-0.015094473026692867,
-0.012180806137621403,
0.06561595946550369,
0.01... | -0.023587 |
or another type of client key for the VCS provider. | | `data.attributes.secret` | string | (previous value) | The OAuth client secret. For Bitbucket Data Center, this secret is the text of the SSH private key associated with your Bitbucket Data Center application link. | | `data.attributes.rsa-public-key` | string | (previous value) | \*\*Required for Bitbucket Data Center in conjunction with the `secret`. Not used for any other providers.\*\* The text of the SSH public key associated with your Bitbucket Data Center application link. | | `data.attributes.organization-scoped` | boolean | (previous value) | Whether or not the OAuth client is available to all projects and workspaces in the organization. | | `data.attributes.oauth-token-string` | string | (previous value) | The personal access token string. Set this field to update the token when rotating credentials. Updating this value does not trigger new runs, and HCP Terraform uses the new token for all subsequent runs. | | `data.relationships.projects` | array\[object] | (previous value) | A list of resource identifier objects that defines which projects are associated with the OAuth client. If `data.attributes.organization-scoped` is set to `false`, the OAuth client is only available to this list of projects. Each object in this list must contain a project `id` and use the `"projects"` type. For example, `{ "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }`. Sending an empty array clears all project assignments. | | `data.relationships.agent-pool.data` | object | `{}` | The Agent Pool associated to the VCS connection. This pool will be responsible for forwarding VCS Provider API calls and cloning VCS repositories. | ### Sample Payload ```json { "data": { "id": "oc-XKFwG6ggfA9n7t1K", "type": "oauth-clients", "attributes": { "key": "key", "secret": "secret", "organization-scoped": false, "oauth-token-string": "74653028376f0009d0ed81f1b654ac17a" }, "relationships": { "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckzzz", "type": "agent-pools" } } } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K ``` ### Sample Response ```json { "data": { "id": "oc-XKFwG6ggfA9n7t1K", "type": "oauth-clients", "attributes": { "created-at": "2018-04-16T20:42:53.771Z", "callback-url": "https://app.terraform.io/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a/callback", "connect-path": "/auth/35936d44-842c-4ddd-b4d4-7c741383dc3a?organization\_id=1", "service-provider": "github", "service-provider-display-name": "GitHub", "name": null, "http-url": "https://github.com", "api-url": "https://api.github.com", "key": null, "rsa-public-key": null, "organization-scoped": false }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "projects": { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" } ] }, "oauth-tokens": { "data": [], "links": { "related": "/api/v2/oauth-clients//oauth-tokens" } }, "agent-pool": { "data": { "id": "apool-VsmjEMcYkShrckzzz", "type": "agent-pools" } } } } } ``` ## Destroy an OAuth Client `DELETE /oauth-clients/:id` | Parameter | Description | | --------- | ------------------------------------- | | `:id` | The ID of the OAuth Client to destroy | This endpoint allows you to remove an existing connection between an organization and a VCS provider (GitHub, Bitbucket, or GitLab). \*\*Note:\*\* Removing the OAuth Client will unlink workspaces that use this connection from their repositories, and these workspaces will need to be manually linked to another repository. | Status | Response | Reason | | ------- | ------------------------- | ------------------------------------------------------------------------------ | | [204][] | Empty response | The OAuth Client was successfully destroyed | | [404][] | [JSON API error object][] | Organization or OAuth Client not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K ``` ## Attach to a project `POST /oauth-clients/:id/relationships/projects` | Parameter | Description | | --------- | -------------------------------------------------------------------------------------------------- | | `:id` | The ID of the OAuth client to attach to a project. Use the [List OAuth Clients](#list-oauth-clients) | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.06112886220216751,
0.010854077525436878,
-0.04666002094745636,
0.029606452211737633,
-0.0033629636745899916,
0.012686403468251228,
0.013732885010540485,
-0.033207036554813385,
0.08842713385820389,
0.0768396183848381,
0.0059256721287965775,
-0.029384508728981018,
0.08197594434022903,
-0.... | -0.048411 |
--header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K ``` ## Attach to a project `POST /oauth-clients/:id/relationships/projects` | Parameter | Description | | --------- | -------------------------------------------------------------------------------------------------- | | `:id` | The ID of the OAuth client to attach to a project. Use the [List OAuth Clients](#list-oauth-clients) endpoint to reference your OAuth client IDs. | | Status | Response | Reason | | ------- | ------------------------- | -------------------------------------------------------------------------- | | [204][] | Nothing | The request was successful | | [404][] | [JSON API error object][] | OAuth Client not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (one or more projects not found, wrong types, etc.) | ### 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 path | Type | Default | Description | | -------- | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data[]` | array\[object] | `[]` | A list of resource identifier objects that defines which projects to attach the OAuth client to. These objects must contain `id` and `type` properties, and the `type` property must be `projects` (e.g. `{ "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }`). | ### Sample Payload ```json { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }, { "id": "prj-2HRvNs49EWPjDqT1", "type": "projects" } ] } ``` ### Sample Request ```shell curl \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K/relationships/projects ``` ## Detach an OAuth Client from projects `DELETE /oauth-clients/:id/relationships/projects` | Parameter | Description | | --------- | -------------------------------------------------------------------------------------------------- | | `:id` | The ID of the oauth client you want to detach from the specified projects. Use the "List OAuth Clients" endpoint to find IDs. | | Status | Response | Reason | | ------- | ------------------------- | -------------------------------------------------------------------------- | | [204][] | Nothing | The request was successful | | [404][] | [JSON API error object][] | OAuth Client not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (one or more projects not found, wrong types, etc.) | ### Request Body This DELETE endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | | -------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data[]` | array\[object] | `[]` | A list of resource identifier objects that defines which projects are associated with the OAuth client. If `data.attributes.organization-scoped` is set to `false`, the OAuth client is only available to this list of projects. Each object in this list must contain a project `id` and use the `"projects"` type. For example, `{ "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }`. | ### Sample Payload ```json { "data": [ { "id": "prj-AwfuCJTkdai4xj9w", "type": "projects" }, { "id": "prj-2HRvNs49EWPjDqT1", "type": "projects" } ] } ``` ### Sample Request ```shell curl \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/vnd.api+json" \ --request DELETE \ --data @payload.json \ https://app.terraform.io/api/v2/oauth-clients/oc-XKFwG6ggfA9n7t1K/relationships/projects ``` ### Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | Resource Name | Description | | -------------- | ---------------------------------------- | | `oauth\_tokens` | The OAuth tokens managed by this client | | `projects` | The projects scoped to this client | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.04431520029902458,
0.10592593997716904,
-0.006221357733011246,
0.030251571908593178,
0.03910251706838608,
-0.05817817896604538,
-0.0038308058865368366,
-0.017032451927661896,
0.0937197208404541,
0.04639450088143349,
-0.01895042136311531,
-0.09440816938877106,
0.056037530303001404,
0.039... | 0.014345 |
Description | | -------------- | ---------------------------------------- | | `oauth\_tokens` | The OAuth tokens managed by this client | | `projects` | The projects scoped to this client | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-clients.mdx | main | terraform | [
-0.04066930338740349,
0.06639990210533142,
0.00373701355420053,
0.01679166778922081,
0.04838168993592262,
-0.044360168278217316,
0.06129700317978859,
0.01816401071846485,
0.047609541565179825,
-0.07834962010383606,
-0.03908705338835716,
-0.007472395896911621,
0.08354950696229935,
0.0001720... | 0.039277 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # OAuth token API reference The `oauth-token` object represents a VCS configuration which includes the OAuth connection and the associated OAuth token. This object is used when creating a workspace to identify which VCS connection to use. ## List OAuth Tokens List all the OAuth Tokens for a given OAuth Client `GET /oauth-clients/:oauth\_client\_id/oauth-tokens` | Parameter | Description | | ------------------ | -------------------------- | | `:oauth\_client\_id` | The ID of the OAuth Client | | Status | Response | Reason | | ------- | ---------------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "oauth-tokens"`) | Success | | [404][] | [JSON API error object][] | OAuth Client not found, or user unauthorized to perform action | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. If neither pagination query parameters are provided, the endpoint will not be paginated and will return all results. | Parameter | Description | | -------------- | ---------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 oauth tokens per page. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ https://app.terraform.io/api/v2/oauth-clients/oc-GhHqb5rkeK19mLB8/oauth-tokens ``` ### Sample Response ```json { "data": [ { "id": "ot-hmAyP66qk2AMVdbJ", "type": "oauth-tokens", "attributes": { "created-at":"2017-11-02T06:37:49.284Z", "service-provider-user":"skierkowski", "has-ssh-key": false }, "relationships": { "oauth-client": { "data": { "id": "oc-GhHqb5rkeK19mLB8", "type": "oauth-clients" }, "links": { "related": "/api/v2/oauth-clients/oc-GhHqb5rkeK19mLB8" } } }, "links": { "self": "/api/v2/oauth-tokens/ot-hmAyP66qk2AMVdbJ" } } ] } ``` ## Show an OAuth Token `GET /oauth-tokens/:id` | Parameter | Description | | --------- | --------------------------------- | | `:id` | The ID of the OAuth token to show | | Status | Response | Reason | | ------- | ---------------------------------------------- | ------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "oauth-tokens"`) | Success | | [404][] | [JSON API error object][] | OAuth Token not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/oauth-tokens/ot-29t7xkUKiNC2XasL ``` ### Sample Response ```json { "data": { "id": "ot-29t7xkUKiNC2XasL", "type": "oauth-tokens", "attributes": { "created-at": "2018-08-29T14:07:22.144Z", "service-provider-user": "EM26Jj0ikRsIFFh3fE5C", "has-ssh-key": false }, "relationships": { "oauth-client": { "data": { "id": "oc-WMipGbuW8q7xCRmJ", "type": "oauth-clients" }, "links": { "related": "/api/v2/oauth-clients/oc-WMipGbuW8q7xCRmJ" } } }, "links": { "self": "/api/v2/oauth-tokens/ot-29t7xkUKiNC2XasL" } } } ``` ## Update an OAuth Token `PATCH /oauth-tokens/:id` | Parameter | Description | | --------- | ----------------------------------- | | `:id` | The ID of the OAuth token to update | | Status | Response | Reason | | ------- | ---------------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "oauth-tokens"`) | OAuth Token successfully updated | | [404][] | [JSON API error object][] | OAuth Token not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | | ------------------------- | ------ | ------- | ------------------------- | | `data.type` | string | | Must be `"oauth-tokens"`. | | `data.attributes.ssh-key` | string | | \*\*Optional.\*\* The SSH key | ### Sample Payload | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-tokens.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
Properties without a default value are required. | Key path | Type | Default | Description | | ------------------------- | ------ | ------- | ------------------------- | | `data.type` | string | | Must be `"oauth-tokens"`. | | `data.attributes.ssh-key` | string | | \*\*Optional.\*\* The SSH key | ### Sample Payload ```json { "data": { "id": "ot-29t7xkUKiNC2XasL", "type": "oauth-tokens", "attributes": { "ssh-key": "..." } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/oauth-tokens/ot-29t7xkUKiNC2XasL ``` ### Sample Response ```json { "data": { "id": "ot-29t7xkUKiNC2XasL", "type": "oauth-tokens", "attributes": { "created-at": "2018-08-29T14:07:22.144Z", "service-provider-user": "EM26Jj0ikRsIFFh3fE5C", "has-ssh-key": false }, "relationships": { "oauth-client": { "data": { "id": "oc-WMipGbuW8q7xCRmJ", "type": "oauth-clients" }, "links": { "related": "/api/v2/oauth-clients/oc-WMipGbuW8q7xCRmJ" } } }, "links": { "self": "/api/v2/oauth-tokens/ot-29t7xkUKiNC2XasL" } } } ``` ## Destroy an OAuth Token `DELETE /oauth-tokens/:id` | Parameter | Description | | --------- | ------------------------------------ | | `:id` | The ID of the OAuth Token to destroy | | Status | Response | Reason | | ------- | ------------------------- | ------------------------------------------------------------- | | [204][] | Empty response | The OAuth Token was successfully destroyed | | [404][] | [JSON API error object][] | OAuth Token not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/oauth-tokens/ot-29t7xkUKiNC2XasL ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/oauth-tokens.mdx | main | terraform | [
0.04572492092847824,
0.07950480282306671,
-0.019756773486733437,
0.026746045798063278,
-0.007528373971581459,
-0.022910933941602707,
-0.018105963245034218,
0.05497279390692711,
0.04771051183342934,
-0.024687429890036583,
-0.0014329623663797975,
-0.1062299832701683,
0.02166132815182209,
0.0... | -0.046501 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Agent token API reference @include 'tfc-package-callouts/agents.mdx' ## List Agent Tokens `GET /agent-pools/:agent\_pool\_id/authentication-tokens` | Parameter | Description | | ---------------- | ------------------------- | | `:agent\_pool\_id` | The ID of the Agent Pool. | The objects returned by this endpoint only contain metadata, and do not include the secret text of any authentication tokens. A token is only shown upon creation, and cannot be recovered later. | Status | Response | Reason | | ------- | ------------------------------------------------------- | ------------------------------------------------------------ | | [200][] | [JSON API document][] (`type: "authentication-tokens"`) | Success | | [404][] | [JSON API error object][] | Agent Pool not found, or user unauthorized to perform action | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | ---------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 tokens per page. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd/authentication-tokens ``` ### Sample Response ```json { "data": [ { "id": "at-bonpPzYqv2bGD7vr", "type": "authentication-tokens", "attributes": { "created-at": "2020-08-07T19:38:20.868Z", "last-used-at": "2020-08-07T19:40:55.139Z", "description": "asdfsdf", "token": null }, "relationships": { "created-by": { "data": { "id": "user-Nxv6svuhVrTW7eb1", "type": "users" } } } } ], "links": { "self": "https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd/authentication-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd/authentication-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/agent-pools/apool-MCf6kkxu5FyHbqhd/authentication-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 1 } } } ``` ## Show an Agent Token `GET /authentication-tokens/:id` | Parameter | Description | | --------- | --------------------------------- | | `:id` | The ID of the Agent Token to show | | Status | Response | Reason | | ------- | ------------------------------------------------------- | ------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "authentication-tokens"`) | Success | | [404][] | [JSON API error object][] | Agent Token not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/authentication-tokens/at-bonpPzYqv2bGD7vr ``` ### Sample Response ```json { "data": { "id": "at-bonpPzYqv2bGD7vr", "type": "authentication-tokens", "attributes": { "created-at": "2020-08-07T19:38:20.868Z", "last-used-at": "2020-08-07T19:40:55.139Z", "description": "test token", "token": null }, "relationships": { "created-by": { "data": { "id": "user-Nxv6svuhVrTW7eb1", "type": "users" } } } } } ``` ## Create an Agent Token `POST /agent-pools/:agent\_pool\_id/authentication-tokens` | Parameter | Description | | ---------------- | ------------------------ | | `:agent\_pool\_id` | The ID of the Agent Pool | This endpoint returns the secret text of the created authentication token. A token is only shown upon creation, and cannot be recovered later. | Status | Response | Reason | | ------- | ------------------------------------------------------- | -------------------------------------------------------------- | | [201][] | [JSON API document][] (`type: "authentication-tokens"`) | The request was successful | | [404][] | [JSON API error object][] | Agent Pool not found or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | | [500][] | [JSON API error object][] | Failure during Agent Token creation | ### 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 path | Type | Default | Description | | ----------------------------- | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agent-tokens.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
[500][] | [JSON API error object][] | Failure during Agent Token creation | ### 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 path | Type | Default | Description | | ----------------------------- | ------ | ------- | ------------------------------------ | | `data.type` | string | | Must be `"authentication-tokens"`. | | `data.attributes.description` | string | | The description for the Agent Token. | ### Sample Payload ```json { "data": { "type": "authentication-tokens", "attributes": { "description":"api" } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/agent-pools/apool-xkuMi7x4LsEnBUdY/authentication-tokens ``` ### Sample Response ```json { "data": { "id": "at-2rG2oYU9JEvfaqji", "type": "authentication-tokens", "attributes": { "created-at": "2020-08-10T22:29:21.907Z", "last-used-at": null, "description": "api", "token": "eHub7TsW7fz7LQ.atlasv1.cHGFcvf2VxVfUH4PZ7UNdaGB6SjyKWs5phdZ371zkI2KniZs2qKgrAcazhlsiy02awk" }, "relationships": { "created-by": { "data": { "id": "user-Nxv6svuhVrTW7eb1", "type": "users" } } } } } ``` ## Destroy an Agent Token `DELETE /api/v2/authentication-tokens/:id` | Parameter | Description | | --------- | ------------------------------------- | | `:id` | The ID of the Agent Token to destroy. | | Status | Response | Reason | | ------- | ------------------------- | ------------------------------------------------------------- | | [204][] | Empty response | The Agent Token was successfully destroyed | | [404][] | [JSON API error object][] | Agent Token not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/authentication-tokens/at-6yEmxNAhaoQLH1Da ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/agent-tokens.mdx | main | terraform | [
-0.018497075885534286,
0.0612403005361557,
-0.028910713270306587,
0.007691494654864073,
-0.05176844075322151,
-0.03177759051322937,
-0.028275374323129654,
0.023451728746294975,
0.04495570808649063,
0.0025746070314198732,
-0.021762406453490257,
-0.09314054995775223,
0.01339267659932375,
0.0... | 0.046778 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Account API reference Account represents the current user interacting with Terraform. It returns the same type of object as the [Users](/terraform/cloud-docs/api-docs/users) API, but also includes an email address, which is hidden when viewing info about other users. For internal reasons, HCP Terraform associates team and organization tokens with a synthetic user account called \_service user\_. HCP Terraform returns the associated service user for account requests authenticated by a team or organization token. Use the `authenticated-resource` relationship to access the underlying team or organization associated with a token. For user tokens, you can use the user, itself. ## Get your account details `GET /account/details` | Status | Response | Reason | | ------- | --------------------------------------- | -------------------------- | | [200][] | [JSON API document][] (`type: "users"`) | The request was successful | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/account/details ``` ### Sample Response ```json { "data": { "id": "user-V3R563qtJNcExAkN", "type": "users", "attributes": { "username": "admin", "is-service-account": false, "auth-method": "tfc", "avatar-url": "https://www.gravatar.com/avatar/9babb00091b97b9ce9538c45807fd35f?s=100&d=mm", "v2-only": false, "is-site-admin": true, "is-sso-login": false, "email": "admin@hashicorp.com", "unconfirmed-email": null, "permissions": { "can-create-organizations": true, "can-change-email": true, "can-change-username": true } }, "relationships": { "authentication-tokens": { "links": { "related": "/api/v2/users/user-V3R563qtJNcExAkN/authentication-tokens" } }, "authenticated-resource": { "data": { "id": "user-V3R563qtJNcExAkN", "type": "users" }, "links": { "related": "/api/v2/users/user-V3R563qtJNcExAkN" } } }, "links": { "self": "/api/v2/users/user-V3R563qtJNcExAkN" } } } ``` ## Update your account info Your username and email address can be updated with this endpoint. `PATCH /account/update` | Status | Response | Reason | | ------- | --------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "users"`) | Your info was successfully updated | | [401][] | [JSON API error object][] | Unauthorized | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | Description | | -------------------------- | ------ | ------- | --------------------------------------------------------------- | | `data.type` | string | | Must be `"users"` | | `data.attributes.username` | string | | New username | | `data.attributes.email` | string | | New email address (must be confirmed afterwards to take effect) | ### Sample Payload ```json { "data": { "type": "users", "attributes": { "email": "admin@example.com", "username": "admin" } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/account/update ``` ### Sample Response ```json { "data": { "id": "user-V3R563qtJNcExAkN", "type": "users", "attributes": { "username": "admin", "is-service-account": false, "auth-method": "hcp\_username\_password", "avatar-url": "https://www.gravatar.com/avatar/9babb00091b97b9ce9538c45807fd35f?s=100&d=mm", "v2-only": false, "is-site-admin": true, "is-sso-login": false, "email": "admin@hashicorp.com", "unconfirmed-email": null, "permissions": { "can-create-organizations": true, "can-change-email": true, "can-change-username": true } }, "relationships": { "authentication-tokens": { "links": { "related": "/api/v2/users/user-V3R563qtJNcExAkN/authentication-tokens" } } }, "links": { "self": "/api/v2/users/user-V3R563qtJNcExAkN" } } } ``` ## Change your password `PATCH /account/password` | Status | Response | Reason | | ------- | --------------------------------------- | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "users"`) | Your password was successfully changed | | [401][] | [JSON API error object][] | Unauthorized | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/account.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
| [JSON API error object][] | Unauthorized | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | Description | | --------------------------------------- | ------ | ------- | --------------------------- | | `data.type` | string | | Must be `"users"` | | `data.attributes.current\_password` | string | | Current password | | `data.attributes.password` | string | | New password (must be at least 10 characters in length) | | `data.attributes.password\_confirmation` | string | | New password (confirmation) | ### Sample Payload ```json { "data": { "type": "users", "attributes": { "current\_password": "current password e.g. 2:C)e'G4{D\n06:[d1~y", "password": "new password e.g. 34rk492+jgLL0@xhfyisj", "password\_confirmation": "new password e.g. 34rk492+jLL0@xhfyisj" } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/account/password ``` ### Sample Response ```json { "data": { "id": "user-V3R563qtJNcExAkN", "type": "users", "attributes": { "username": "admin", "is-service-account": false, "auth-method": "hcp\_github", "avatar-url": "https://www.gravatar.com/avatar/9babb00091b97b9ce9538c45807fd35f?s=100&d=mm", "v2-only": false, "is-site-admin": true, "is-sso-login": false, "email": "admin@hashicorp.com", "unconfirmed-email": null, "permissions": { "can-create-organizations": true, "can-change-email": true, "can-change-username": true } }, "relationships": { "authentication-tokens": { "links": { "related": "/api/v2/users/user-V3R563qtJNcExAkN/authentication-tokens" } } }, "links": { "self": "/api/v2/users/user-V3R563qtJNcExAkN" } } } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/account.mdx | main | terraform | [
-0.06883896887302399,
0.024041442200541496,
-0.035400208085775375,
0.005632881540805101,
-0.07450248301029205,
-0.06865373998880386,
-0.0009012350346893072,
0.018947217613458633,
-0.023500898852944374,
0.029979120939970016,
0.001448499271646142,
-0.06651592254638672,
0.04484717175364494,
0... | -0.000403 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # GitHub App installations API reference You can create a GitHub App installation using the HCP Terraform UI. Learn how to [create a GitHub App installation](/terraform/enterprise/vcs/github-app). ## Requirements To use this resource in Terraform Enterprise installations, you must configure the GitHub App in the site admin area. You must have already authorized the Terraform Cloud GitHub App. Refer to [GitHub app OAuth token](/terraform/enterprise/users-teams-organizations/users#github-app-oauth-token) for instructions. ## List Installations This endpoint lists GitHub App installations available to the current user. `GET /github-app/installations` ### Query Parameters Queries only return GitHub App Installations that the current user has access to within GitHub. | Parameter | Description | |-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | `filter[name]` | \*\*Optional.\*\* If present, returns a list of available GitHub App installations that match the GitHub organization or login. | | `filter[installation\_id]` | \*\*Optional.\*\* If present, returns a list of available GitHub App installations that match the installation ID within GitHub. (\*\*Not HCP Terraform\*\*) | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/github-app/installations ``` ### Sample Response ```json { "data": [ { "id": "ghain-BYrbNeGQ8nAzKouu", "type": "github-app-installations", "attributes": { "name": "octouser", "installation-id": 54810170, "icon-url": "https://avatars.githubusercontent.com/u/29916665?v=4", "installation-type": "User", "installation-url": "https://github.com/settings/installations/54810170" } } ] } ``` ## Show Installation `GET /github-app/installation/:gh\_app\_installation\_id` | Parameter | Description | |---------------------------|--------------------------------| | `:gh\_app\_installation\_id` | The Github App Installation ID | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/github-app/installation/ghain-R4xmKTaxnhLFioUq ``` ### Sample Response ```json { "data": { "id": "ghain-R4xmKTaxnhLFioUq", "type": "github-app-installations", "attributes": { "name": "octouser", "installation-id": 54810170, "icon-url": "https://avatars.githubusercontent.com/u/29916665?v=4", "installation-type": "User", "installation-url": "https://github.com/settings/installations/54810170" } } } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/github-app-installations.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
# VCS events API reference -> \*\*Note\*\*: The VCS Events API is still in beta as support is being added for additional VCS providers. Currently only GitLab.com connections established after December 2020 are supported. VCS (version control system) events describe changes within your organization for VCS-related actions. Events are only stored for 10 days. If information about the [OAuth Client](/terraform/cloud-docs/api-docs/oauth-clients) or [OAuth Token](/terraform/cloud-docs/api-docs/oauth-tokens) are available at the time of the event, it will be logged with the event. ## List VCS events This endpoint lists VCS events for an organization `GET /organizations/:organization\_name/vcs-events` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to list VCS events from. The organization must already exist in the system and the user must have permissions to manage VCS settings. | -> \*\*Note:\*\* Viewing VCS events is restricted to the owners team, teams with the "Manage VCS Settings", and the [organization API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). ([More about permissions](/terraform/cloud-docs/users-teams-organizations/permissions).) ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 workspaces per page. | | `filter[from]` | \*\*Optional.\*\* Must be RFC3339 formatted and in UTC. If omitted, the endpoint will default to 10 days ago. | | `filter[to]` | \*\*Optional.\*\* Must be RFC3339 formatted and in UTC. If omitted, the endpoint will default to now. | | `filter[oauth\_client\_external\_ids]` | \*\*Optional.\*\* Format as a comma-separated string. If omitted, the endpoint will return all events. | | `filter[levels]` | \*\*Optional.\*\* `info` and `error` are the only accepted values. If omitted, the endpoint will return both info and error events. | | `include` | \*\*Optional.\*\* Allows including related resource data. This endpoint only supports `oauth\_client` as a value. Only the `name`, `service-provider`, and `id` will be returned on the OAuth Client object in the `included` block. | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/organizations/my-organization/vcs-events?filter%5Bfrom%5D=2021-02-02T14%3A09%3A00Z&filter%5Bto%5D=2021-02-12T14%3A09%3A59Z&filter%5Boauth\_client\_external\_ids%5D=oc-hhTM7WNUUgbXJpkW&filter%5Blevels%5D=info&include=oauth\_client ``` ### Sample Response ```json { "data": [ { "id": "ve-DJpbEwZc98ZedHZG", "type": "vcs-events", "attributes": { "created-at": "2021-02-09 20:07:49.686182 +0000 UTC", "level": "info", "message": "Loaded 11 repositories", "organization-id": "org-SBVreZxVessAmCZG", "suggested\_action": "Refresh the OAuth Token / Client Secret and reset the VCS provider connection: " }, "relationships": { "oauth-client": { "data": { "id": "oc-LePsVhHXhCM6jWf3", "type": "oauth-clients" }, "links": { "related": "/api/v2/oauth-clients/oc-LePsVhHXhCM6jWf3" } }, "oauth-token": { "data": { "id": "ot-Ma2cs8tzjv3LYZHw", "type": "oauth-tokens" }, "links": { "related": "/api/v2/oauth-tokens/ot-Ma2cs8tzjv3LYZHw" } } } } ], "included": [ { "id": "oc-LePsVhHXhCM6jWf3", "type": "oauth-clients", "attributes": { "name": "working", "service-provider": "gitlab\_hosted" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "oauth-tokens": { "data": [ { "id": "ot-Ma2cs8tzjv3LYZHw", "type": "oauth-tokens" } ] } } } ], "links": { "self": "https://app.terraform.io/api/v2/organizations/my-organization/vcs-events?filter%5Bfrom%5D=2021-02-02T14%3A09%3A00Z\u0026filter%5Blevels%5D=info\u0026filter%5Boauth\_client\_external\_ids%5D=oc-LePsVhHXhCM6jWf3\u0026filter%5Bto%5D=2021-02-12T14%3A09%3A59Z\u0026include=oauth\_client\u0026organization\_name=my-organization\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/organizations/my-organization/vcs-events?filter%5Bfrom%5D=2021-02-02T14%3A09%3A00Z\u0026filter%5Blevels%5D=info\u0026filter%5Boauth\_client\_external\_ids%5D=oc-LePsVhHXhCM6jWf3\u0026filter%5Bto%5D=2021-02-12T14%3A09%3A59Z\u0026include=oauth\_client\u0026organization\_name=my-organization\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/organizations/my-organization/vcs-events?filter%5Bfrom%5D=2021-02-02T14%3A09%3A00Z\u0026filter%5Blevels%5D=info\u0026filter%5Boauth\_client\_external\_ids%5D=oc-LePsVhHXhCM6jWf3\u0026filter%5Bto%5D=2021-02-12T14%3A09%3A59Z\u0026include=oauth\_client\u0026organization\_name=my-organization\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 8 } } } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/vcs-events.mdx | main | terraform | [
-0.035735953599214554,
0.02360043115913868,
0.01822294294834137,
0.017164485529065132,
0.03342166170477867,
-0.05483488366007805,
-0.008408159017562866,
-0.03966129943728447,
0.14580465853214264,
0.07071278989315033,
-0.05795877054333687,
-0.030502621084451675,
-0.006822471972554922,
-0.02... | 0.037746 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Group member role API reference The group member role API returns the assigned roles for an HCP group on a given resource, such as an organization, project, or a workspace. This API is only available for HCP Europe organizations. If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HCP Europe organization. To learn more about HCP Europe, refer to the [HCP Europe documentation](/hcp/docs/hcp/europe). For other HCP Terraform organizations, refer to the [Team members](/terraform/cloud-docs/api-docs/team-members) API. ## List all role assignments `GET /member-roles/:resource\_type/:resource\_id` | Parameter | Description | | -------------------- | ------------------------------------------------ | | `:resource\_type` | The type of the resource. This can be organizations, projects, workspaces. | | `:resource\_id` | The id of the respective resource. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `q` | \*\*Optional.\*\* Allows querying a list of role assignments by group name. This search is case-insensitive. | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 role assignments per page. | | `sort` | \*\*Optional.\*\* Allows sorting by group names. The only valid value is `"name"`. Prepending a hyphen to the sort parameter will reverse the order (e.g. `"-name"`). | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/member-roles/organizations/5574ca0a-4d0b-4456-b1a6-54e8ae4c1b2a?page[number]=1&page[size]=10&sort= ``` ### Sample Response The response shows the ID and name of the HCP groups, as well as the HCP and HCP Terraform permissions that group has access to. The `resource-type` attribute determines at which resource level, such as organization, project, or workspace, that the role is coming from. ```json { "data": [ { "id": "726a300c45-groups-bbe82f8dcb41025f18c951", "type": "member-roles", "attributes": { "roles": [], "member-id": "iam.group:hFkn8zpNB6cRp8jnqPkH", "member-name": "group\_D", "member-type": "groups" } }, { "id": "bee3018293f35b435662b8882e3fc024", "type": "member-roles", "attributes": { "roles": [ { "resource-type": "organizations", "role-id": "roles/terraform.legacy-organization-access-custom" }, { "resource-type": "organizations", "role-id": "roles/admin" } ], "member-id": "iam.group:HTwTGdftfghn9HHwKJ9w", "member-name": "group\_C", "member-type": "groups" } }, { "id": "36ed391b9b65ad434576787d46c01af8b8", "type": "member-roles", "attributes": { "roles": [], "member-id": "iam.group:cTJfbKCJTThcq8pPQJTj", "member-name": "group\_B", "member-type": "groups" } } ], "links": { "self": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "page-size": 20, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 19 } } } ``` ## Show roles for a group `GET /member-roles/:resource\_type/:resource\_id` This endpoint fetches the HCP roles and relevant permissions for a single group on the specified resource. | Parameter | Description | | -------------------- | ------------------------------------------------ | | `:resource\_type` | The resource level to view the roles for. This can be organizations, projects, workspaces. | | `:resource\_id` | The id of the resource that is of the type resource\_type. | | `filter[member\_type]` | \*\*Required.\*\* Specifies the type of the member. As of now, the only acceptable value is groups. | | `filter[group\_id]` | \*\*Required.\*\* The id of the group that you want to see the permissions for. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/group-member-roles.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
| ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 10 teams per page. | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/member-roles/organizations/5574ca0a-4d0b-4456-b1a6-54e8ae4c1b2a?filter[member\_type]=groups&filter[member\_id]=iam.group%6ANzJbGbHIigBctKmRrTkz ``` ### Sample Response The response shows the hcp and terraform roles for a single member (e.g. group) on the specified resource. ```json { "data": [ { "id": "865a1f57998956c67ae86e745ea61654", "type": "member-roles", "attributes": { "roles": [ { "resource-type": "organizations", "role-id": "roles/admin" }, { "resource-type": "projects", "role-id": "roles/terraform.legacy-project-access-custom" } ], "member-id": "iam.group:NzJbGbYyLgBctKmDmTkz", "member-name": "group\_A", "member-type": "groups" } } ], "links": { "self": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember\_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember\_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember\_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember\_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember\_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember\_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "page-size": 20, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 1 } } } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/group-member-roles.mdx | main | terraform | [
-0.020988523960113525,
0.08490979671478271,
0.04145219177007675,
0.009616111405193806,
-0.08794776350259781,
0.028641995042562485,
-0.07210508733987808,
-0.07182466238737106,
0.05727924406528473,
0.07317671179771423,
-0.05782374367117882,
-0.057522159069776535,
0.05541406571865082,
-0.0654... | -0.032122 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [307]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Comments API reference Comments allow users to leave feedback or record decisions about a run on a workspace. ## List Comments for a Run `GET /runs/:id/comments` | Parameter | Description | | --------- | ------------------ | | `id` | The ID of the run. | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/runs/run-KTuq99JSzgmDSvYj/comments ``` ### Sample Response ```json { "data": [ { "id": "wsc-JdFX3u8o114F4CWf", "type": "comments", "attributes": { "body": "A comment body" }, "relationships": { "run-event": { "data": { "id": "re-fo1YXZ8W5bp5GBKM", "type": "run-events" }, "links": { "related": "/api/v2/run-events/re-fo1YXZ8W5bp5GBKM" } } }, "links": { "self": "/api/v2/comments/wsc-JdFX3u8o114F4CWf" } }, { "id": "wsc-QdhSPFTNoCTpfafp", "type": "comments", "attributes": { "body": "Another comment body" }, "relationships": { "run-event": { "data": { "id": "re-fo1YXZ8W5bp5GBKM", "type": "run-events" }, "links": { "related": "/api/v2/run-events/re-fo1YXZ8W5bp5GBKM" } } }, "links": { "self": "/api/v2/comments/wsc-QdhSPFTNoCTpfafp" } } ] } ``` ## Show a Comment `GET /comments/:id` | Parameter | Description | | --------- | ---------------------- | | `id` | The ID of the comment. | ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/comments/wsc-gTFq83JSzjmAvYj ``` ### Sample Response ```json { "data": { "id": "wsc-gTFq83JSzjmAvYj", "type": "comments", "attributes": { "body": "Another comment" }, "relationships": { "run-event": { "data": { "id": "re-8RB5ZaFrDanG2hGY", "type": "run-events" }, "links": { "related": "/api/v2/run-events/re-8RB5ZaFrDanG2hGY" } } }, "links": { "self": "/api/v2/comments/wsc-gTFq83JSzjmAvYj" } } } ``` ## Create Comment `POST /runs/:id/comments` | Parameter | Description | | --------- | ------------------ | | `id` | The ID of the run. | ### Request Body This POST endpoint requires a JSON object with the following properties as the request payload. | Key Path | Type | Default | Description | ------------------------ | ------ | ------- | ---------------- | `data.type` | string | | Must be `"comments"`. | `data.attributes.body` | string | | The body of the comment. ### Sample Payload ```json { "data": { "attributes": { "body": "A comment about the run", }, "type": "comments" } } ``` ### Sample Request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/runs/run-KTuq99JSzgmDSvYj/comments ``` ### Sample Response ```json { "data": { "id": "wsc-oRiShushpgLU4JD2", "type": "comments", "attributes": { "body": "A comment about the run" }, "relationships": { "run-event": { "data": { "id": "re-E3xsBX11F1fbm2zV", "type": "run-events" }, "links": { "related": "/api/v2/run-events/re-E3xsBX11F1fbm2zV" } } }, "links": { "self": "/api/v2/comments/wsc-oRiShushpgLU4JD2" } } } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/comments.mdx | main | terraform | [
-0.026010459288954735,
-0.02275005355477333,
-0.026095468550920486,
-0.018418513238430023,
-0.02009897492825985,
-0.08436909317970276,
-0.05374377593398094,
-0.0791759043931961,
-0.0060250526294112206,
-0.03486490249633789,
0.03005075827240944,
0.05508139356970787,
0.0022271922789514065,
-... | 0.068675 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Notification configurations API reference HCP Terraform can send notifications for run state transitions and workspace events. You can specify a destination URL, request type, and what events will trigger the notification. Each workspace can have up to 20 notification configurations, and they apply to all runs for that workspace. Interacting with notification configurations requires admin access to the relevant workspace. ([More about permissions](/terraform/cloud-docs/users-teams-organizations/permissions).) -> \*\*Note:\*\* [Speculative plans](/terraform/cloud-docs/workspaces/run/modes-and-options#plan-only-speculative-plan) and workspaces configured with `Local` [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) do not support notifications. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Notification triggers Notifications are sent in response to triggers related to workspace events, and can be defined at workspace and team levels. You can specify workspace events in the `triggers` array attribute. ### Workspace notification triggers The following triggers are available for workspace notifications. | Display Name | Value | Description | | ------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------- | | Created | `"run:created"` | A run is created and enters the [Pending stage](/terraform/cloud-docs/workspaces/run/states#the-pending-stage) | | Planning | `"run:planning"` | A run acquires the lock and starts to execute. | | Needs Attention | `"run:needs\_attention"` | A plan has changes and Terraform requires user input to continue. This input may include approving the plan or a [policy override](/terraform/cloud-docs/workspaces/run/states#the-policy-check-stage). | | Applying | `"run:applying"` | A run enters the [Apply stage](/terraform/cloud-docs/workspaces/run/states#the-apply-stage), where Terraform makes the infrastructure changes described in the plan. | | Completed | `"run:completed"` | A run completes successfully. | | Errored | `"run:errored"` | A run terminates early due to error or cancellation. | | Drifted | `"assessment:drifted"` | HCP Terraform detected configuration drift. This option is only available if you enabled drift detection for the workspace. | | Checks Failed | `"assessment:check\_failure"` | One or more continuous validation checks did not pass. This option is only available if you enabled drift detection for the workspace. | | Health Assessment Failed | `"assessment:failed"` | A health assessment failed. This option is only available if you enable health assessments for the workspace. | | Auto Destroy Reminder | `"workspace:auto\_destroy\_reminder"` | An automated workspace destroy run is imminent. | | Auto Destroy Results | `"workspace:auto\_destroy\_run\_results"` | HCP Terraform attempted an automated workspace destroy run. | ### Team notification triggers The following triggers are available for [team notifications](#team-notification-configuration). | Display Name | Value | Description | | ------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------- | | Change Request | `"team:change\_request"` | HCP Terraform sent a change request to a workspace that the specified team has explicit access to. | ## Notification payload The notification is an HTTP POST request with a detailed payload. The content depends on the type of notification. For Slack and Microsoft Teams notifications, the payload conforms to the respective webhook API and results in a notification message with informational attachments. Refer to [Slack Notification Payloads](/terraform/cloud-docs/workspaces/settings/notifications#slack) and [Microsoft Teams Notification Payloads](/terraform/cloud-docs/workspaces/settings/notifications#microsoft-teams) for examples. For generic notifications, the payload varies based on whether the notification contains information about run events or workspace events. ### Run notification payload Run events include detailed information about a specific run, including the time it began and the associated workspace and organization. Generic notifications for run events contain the following information: | Name | Type | Description | | -------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payload\_version` | number | Always "1". | | `notification\_configuration\_id` | string | The ID of the configuration associated with this notification. | | `run\_url` | string | URL used to access the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
the following information: | Name | Type | Description | | -------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payload\_version` | number | Always "1". | | `notification\_configuration\_id` | string | The ID of the configuration associated with this notification. | | `run\_url` | string | URL used to access the run UI page. | | `run\_id` | string | ID of the run which triggered this notification. | | `run\_message` | string | The reason the run was queued. | | `run\_created\_at` | string | Timestamp of the run's creation. | | `run\_created\_by` | string | Username of the user who created the run. | | `workspace\_id` | string | ID of the run's workspace. | | `workspace\_name` | string | Human-readable name of the run's workspace. | | `organization\_name` | string | Human-readable name of the run's organization. | | `notifications` | array | List of events which caused this notification to be sent, with each event represented by an object. At present, this is always one event, but in the future HCP Terraform may roll up several notifications for a run into a single request. | | `notifications[].message` | string | Human-readable reason for the notification. | | `notifications[].trigger` | string | Value of the trigger which caused the notification to be sent. | | `notifications[].run\_status` | string | Status of the run at the time of notification. | | `notifications[].run\_updated\_at` | string | Timestamp of the run's update. | | `notifications[].run\_updated\_by` | string | Username of the user who caused the run to update. | #### Sample payload ```json { "payload\_version": 1, "notification\_configuration\_id": "nc-AeUQ2zfKZzW9TiGZ", "run\_url": "https://app.terraform.io/app/acme-org/my-workspace/runs/run-FwnENkvDnrpyFC7M", "run\_id": "run-FwnENkvDnrpyFC7M", "run\_message": "Add five new queue workers", "run\_created\_at": "2019-01-25T18:34:00.000Z", "run\_created\_by": "sample-user", "workspace\_id": "ws-XdeUVMWShTesDMME", "workspace\_name": "my-workspace", "organization\_name": "acme-org", "notifications": [ { "message": "Run Canceled", "trigger": "run:errored", "run\_status": "canceled", "run\_updated\_at": "2019-01-25T18:37:04.000Z", "run\_updated\_by": "sample-user" } ] } ``` ### Change request notification payload Change request events contain the following fields in their payloads. | Name | Type | Description | | -------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payload\_version` | number | Always "1". | | `notification\_configuration\_id` | string | The ID of the configuration associated with this notification. | | `change\_request\_url` | string | URL used to access the change request UI page. | | `change\_request\_subject` | string | title of the change request which triggered this notification. | | `change\_request\_message` | string | The contents of the change request. | | `change\_request\_created\_at` | string | Timestamp of the change request's creation. | | `change\_request\_created\_by` | string | Username of the user who created the change\_request. | | `workspace\_id` | string | ID of the run's workspace. | | `workspace\_name` | string | Human-readable name of the run's workspace. | | `organization\_name` | string | Human-readable name of the run's organization. | ##### `Send a test` payload This is a sample payload you can send to test if notifications are working. The payload does not have a `run` or `workspace` context, resulting in null values. You can trigger a test notification from the workspace notification settings page. You can read more about verifying a [notification configuration](/terraform/enterprise/workspaces/settings/notifications#enabling-and-verifying-a-configuration). ```json { "payload\_version": 1, "notification\_configuration\_id": "nc-jWvVsmp5VxsaCeXm", "run\_url": null, "run\_id": null, "run\_message": null, "run\_created\_at": null, "run\_created\_by": null, "workspace\_id": null, "workspace\_name": null, "organization\_name": null, "notifications": [ { "message": "Verification of test", "trigger": "verification", "run\_status": null, "run\_updated\_at": null, "run\_updated\_by": null, } ] } ``` ### Workspace notification payload Workspace events include detailed information about workspace-level validation events like [health assessments](/terraform/cloud-docs/workspaces/health) if you enable them for the workspace. Much of the information provides details about the associated [assessment result](/terraform/cloud-docs/api-docs/assessment-results), which HCP Terraform uses to track instances of continuous validation. HCP | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.0062637473456561565,
0.05819385498762131,
-0.010701271705329418,
0.014665198512375355,
-0.06705909967422485,
0.030755065381526947,
0.041231099516153336,
0.0019502727081999183,
0.026196254417300224,
-0.059626683592796326,
0.012803749181330204,
-0.0465838797390461,
-0.010636583901941776,
... | 0.046641 |
null, } ] } ``` ### Workspace notification payload Workspace events include detailed information about workspace-level validation events like [health assessments](/terraform/cloud-docs/workspaces/health) if you enable them for the workspace. Much of the information provides details about the associated [assessment result](/terraform/cloud-docs/api-docs/assessment-results), which HCP Terraform uses to track instances of continuous validation. HCP Terraform returns different types of attributes returned in the payload details, depending on the type of `trigger\_scope`. There are two main values for `trigger\_scope`: `assessment` and `workspace`, examples of which you can see below. #### Health assessments Health assessment notifications for workspace events contain the following information: @include 'tfc-package-callouts/health-assessments.mdx' | Name | Type | Description | | -------------------------------------------- | ------ | ------------------------------------------------------------------------------------ | | `payload\_version` | number | Always "2". | | `notification\_configuration\_id` | string | The ID of the configuration associated with this notification. | | `notification\_configuration\_url` | string | URL to get the notification configuration from the HCP Terraform API. | | `trigger\_scope` | string | Always "assessment" for workspace assessment notifications. | | `trigger` | string | Value of the trigger that caused the notification to be sent. | | `message` | string | Human-readable reason for the notification. | | `details` | object | Object containing details specific to the notification. | | `details.new\_assessment\_result` | object | The most recent assessment result. This result triggered the notification. | | `details.new\_assessment\_result.id` | string | ID of the assessment result. | | `details.new\_assessment\_result.url` | string | URL to get the assessment result from the HCP Terraform API. | | `details.new\_assessment\_result.succeeded` | bool | Whether assessment succeeded. | | `details.new\_assessment\_result.all\_checks\_succeeded` | bool | Whether all conditions passed. | | `details.new\_assessment\_result.checks\_passed` | number | The number of resources, data sources, and outputs passing their conditions. | | `details.new\_assessment\_result.checks\_failed` | number | The number of resources, data sources, and outputs with one or more failing conditions. | | `details.new\_assessment\_result.checks\_errored` | number | The number of resources, data sources, and outputs that had a condition error. | | `details.new\_assessment\_result.checks\_unknown` | number | The number of resources, data sources, and outputs that had conditions left unevaluated. | | `details.new\_assessment\_result.drifted` | bool | Whether assessment detected drift. | | `details.new\_assessment\_result.resources\_drifted` | number| The number of resources whose configuration does not match from the workspace's state file. | | `details.new\_assessment\_result.resources\_undrifted` | number| The number of real resources whose configuration matches the workspace's state file. | | `details.new\_assessment\_result.created\_at` | string | Timestamp for when HCP Terraform created the assessment result. | | `details.prior\_assessment\_result` | object | The assessment result immediately prior to the one that triggered the notification. | | `details.prior\_assessment\_result.id` | string | ID of the assessment result. | | `details.prior\_assessment\_result.url` | string | URL to get the assessment result from the HCP Terraform API. | | `details.prior\_assessment\_result.succeeded` | bool | Whether assessment succeeded. | | `details.prior\_assessment\_result.all\_checks\_succeeded` | bool | Whether all conditions passed. | | `details.prior\_assessment\_result.checks\_passed` | number | The number of resources, data sources, and outputs passing their conditions. | | `details.prior\_assessment\_result.checks\_failed` | number | The number of resources, data sources, and outputs with one or more failing conditions. | | `details.prior\_assessment\_result.checks\_errored` | number | The number of resources, data sources, and outputs that had a condition error. | | `details.prior\_assessment\_result.checks\_unknown` | number | The number of resources, data sources, and outputs that had conditions left unevaluated. | | `details.prior\_assessment\_result.drifted` | bool | Whether assessment detected drift. | | `details.prior\_assessment\_result.resources\_drifted` | number| The number of resources whose configuration does not match the workspace's state file. | | `details.prior\_assessment\_result.resources\_undrifted` | number| The number of resources whose configuration matches the workspace's state file. | | `details.prior\_assessment\_result.created\_at` | string | Timestamp of the assessment result. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
0.0006984693463891745,
0.05252385511994362,
0.022176537662744522,
0.004748588893562555,
0.03398037701845169,
0.005954402964562178,
0.028011852875351906,
-0.04656563326716423,
0.013854630291461945,
-0.0025706083979457617,
-0.015675075352191925,
-0.1488606482744217,
0.05879102274775505,
-0.0... | 0.055351 |
Whether assessment detected drift. | | `details.prior\_assessment\_result.resources\_drifted` | number| The number of resources whose configuration does not match the workspace's state file. | | `details.prior\_assessment\_result.resources\_undrifted` | number| The number of resources whose configuration matches the workspace's state file. | | `details.prior\_assessment\_result.created\_at` | string | Timestamp of the assessment result. | | `details.workspace\_id` | string | ID of the workspace that generated the notification. | | `details.workspace\_name` | string | Human-readable name of the workspace. | | `details.organization\_name` | string | Human-readable name of the organization. | ##### Sample payload Health assessment payloads have information about resource drift and continuous validation checks. ```json { "payload\_version": "2", "notification\_configuration\_id": "nc-SZ3V3cLFxK6sqLKn", "notification\_configuration\_url": "https://app.terraform.io/api/v2/notification-configurations/nc-SZ3V3cLFxK6sqLKn", "trigger\_scope": "assessment", "trigger": "assessment:drifted", "message": "Drift Detected", "details": { "new\_assessment\_result": { "id": "asmtres-vRVQxpqq64EA9V5a", "url": "https://app.terraform.io/api/v2/assessment-results/asmtres-vRVQxpqq64EA9V5a", "succeeded": true, "drifted": true, "all\_checks\_succeeded": true, "resources\_drifted": 4, "resources\_undrifted": 55, "checks\_passed": 33, "checks\_failed": 0, "checks\_errored": 0, "checks\_unknown": 0, "created\_at": "2022-06-09T05:23:10Z" }, "prior\_assessment\_result": { "id": "asmtres-A6zEbpGArqP74fdL", "url": "https://app.terraform.io/api/v2/assessment-results/asmtres-A6zEbpGArqP74fdL", "succeeded": true, "drifted": true, "all\_checks\_succeeded": true, "resources\_drifted": 4, "resources\_undrifted": 55, "checks\_passed": 33, "checks\_failed": 0, "checks\_errored": 0, "checks\_unknown": 0, "created\_at": "2022-06-09T05:22:51Z" }, "workspace\_id": "ws-XdeUVMWShTesDMME", "workspace\_name": "my-workspace", "organization\_name": "acme-org" } } ``` #### Automatic destroy runs @include 'tfc-package-callouts/ephemeral-workspaces.mdx' Automatic destroy run notifications for workspace events contain the following information: | Name | Type | Description | | -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------| | `payload\_version` | string | Always 2. | | `notification\_configuration\_id` | string | The ID of the notification's configuration. | | `notification\_configuration\_url` | string | The URL to get the notification's configuration from the HCP Terraform API. | | `trigger\_scope` | string | Always "workspace" for ephemeral workspace notifications | | `trigger` | string | Value of the trigger that caused HCP Terraform to send the notification. | | `message` | string | Human-readable reason for the notification. | | `details` | object | Object containing details specific to the notification. | | `details.auto\_destroy\_at` | string | Timestamp when HCP Terraform will schedule the next destroy run. Only applies to reminder notifications. | | `details.run\_created\_at` | string | Timestamp of when HCP Terraform successfully created a destroy run. Only applies to results notifications. | | `details.run\_status` | string | Status of the scheduled destroy run. Only applies to results notifications. | | `details.run\_external\_id` | string | The ID of the scheduled destroy run. Only applies to results notifications. | | `details.run\_create\_error\_message` | string | Message detailing why the run was unable to be queued. Only applies to results notifications. | | `details.trigger\_type` | string | The type of notification, and the value is either "reminder" or "results". | | `details.workspace\_name` | string | Human-readable name of the workspace. | | `details.organization\_name` | string | Human-readable name of the organization. | ##### Sample payload The shape of data in auto destroy notification payloads may differ depending on the success of the run HCP Terraform created. Refer to the specific examples below. ###### Reminder Reminders that HCP Terraform will trigger a destroy run at some point in the future. ```json { "payload\_version": "2", "notification\_configuration\_id": "nc-SZ3V3cLFxK6sqLKn", "notification\_configuration\_url": "https://app.terraform.io/api/v2/notification-configurations/nc-SZ3V3cLFxK6sqLKn", "trigger\_scope": "workspace", "trigger": "workspace:auto\_destroy\_reminder", "message": "Auto Destroy Reminder", "details": { "auto\_destroy\_at": "2025-01-01T00:00:00Z", "run\_created\_at": null, "run\_status": null, "run\_external\_id": null, "run\_create\_error\_message": null, "trigger\_type": "reminder", "workspace\_name": "learned-english-dog", "organization\_name": "acme-org" } } ``` ###### Results The final result of the scheduled auto destroy run includes additional metadata about the run. ```json { "payload\_version": "2", "notification\_configuration\_id": "nc-SZ3V3cLFxK6sqLKn", "notification\_configuration\_url": "https://app.terraform.io/api/v2/notification-configurations/nc-SZ3V3cLFxK6sqLKn", "trigger\_scope": "workspace", "trigger": "workspace:auto\_destroy\_results", "message": "Auto Destroy Results", "details": { "auto\_destroy\_at": null, "run\_created\_at": "2022-06-09T05:22:51Z", "run\_status": "applied", "run\_external\_id": "run-vRVQxpqq64EA9V5a", "run\_create\_error\_message": null, "trigger\_type": "results", "workspace\_name": "learned-english-dog", "organization\_name": "acme-org" } } ``` ###### Failed run creation Run-specific values are empty when HCP Terraform was unable to create an auto destroy run. ```json { | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.061207544058561325,
0.04435277730226517,
-0.03039756789803505,
0.051448170095682144,
0.07724419981241226,
-0.06915132701396942,
0.05664127320051193,
-0.0039377361536026,
-0.009923171252012253,
-0.025740759447216988,
-0.00010170448513235897,
-0.08324503153562546,
0.06100751832127571,
0.0... | 0.153679 |
"trigger\_scope": "workspace", "trigger": "workspace:auto\_destroy\_results", "message": "Auto Destroy Results", "details": { "auto\_destroy\_at": null, "run\_created\_at": "2022-06-09T05:22:51Z", "run\_status": "applied", "run\_external\_id": "run-vRVQxpqq64EA9V5a", "run\_create\_error\_message": null, "trigger\_type": "results", "workspace\_name": "learned-english-dog", "organization\_name": "acme-org" } } ``` ###### Failed run creation Run-specific values are empty when HCP Terraform was unable to create an auto destroy run. ```json { "payload\_version": "2", "notification\_configuration\_id": "nc-SZ3V3cLFxK6sqLKn", "notification\_configuration\_url": "https://app.terraform.io/api/v2/notification-configurations/nc-SZ3V3cLFxK6sqLKn", "trigger\_scope": "workspace", "trigger": "workspace:auto\_destroy\_results", "message": "Auto Destroy Results", "details": { "auto\_destroy\_at": null, "run\_created\_at": null, "run\_status": null, "run\_external\_id": null, "run\_create\_error\_message": "Configuration version is missing", "trigger\_type": "results", "workspace\_name": "learned-english-dog", "organization\_name": "acme-org" } } ``` ## Notification authenticity If a `token` is configured, HCP Terraform provides an HMAC signature on all `"generic"` notification requests, using the `token` as the key. This is sent in the `X-TFE-Notification-Signature` header. The digest algorithm used is SHA-512. Notification target servers should verify the source of the HTTP request by computing the HMAC of the request body using the same shared secret, and dropping any requests with invalid signatures. Sample Ruby code for verifying the HMAC: ```ruby token = SecureRandom.hex hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha512"), token, @request.body) fail "Invalid HMAC" if hmac != @request.headers["X-TFE-Notification-Signature"] ``` ## Notification verification and delivery responses When saving a configuration with `enabled` set to `true`, or when using the [verify API][], HCP Terraform sends a verification request to the configured URL. The response to this request is stored and available in the `delivery-responses` array of the `notification-configuration` resource. Configurations cannot be enabled if the verification request fails. Success is defined as an HTTP response with status code of `2xx`. Configurations with `destination\_type` `email` can only be verified manually, they do not require an HTTP response. The most recent response is stored in the `delivery-responses` array. Each delivery response has several fields: | Name | Type | Description | | ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `body` | string | Response body (may be truncated). | | `code` | string | HTTP status code, e.g. `400`. | | `headers` | object | All HTTP headers received, represented as an object with keys for each header name (lowercased) and an array of string values (most arrays will be size one). | | `sent-at` | date | The UTC timestamp when the notification was sent. | | `successful` | bool | Whether HCP Terraform considers this response to be successful. | | `url` | string | The URL to which the request was sent. | [verify API]: #verify-a-notification-configuration ## Create a notification configuration `POST /workspaces/:workspace\_id/notification-configurations` | Parameter | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:workspace\_id` | The ID of the workspace to list configurations for. Obtain this from the [workspace settings](/terraform/cloud-docs/workspaces/settings) or the [Show Workspace](/terraform/cloud-docs/api-docs/workspaces#show-workspace) endpoint. | | Status | Response | Reason | | ------- | ------------------------------------------------------------- | -------------------------------------------------------------- | | [201][] | [JSON API document][] (`type: "notification-configurations"`) | Successfully created a notification configuration | | [400][] | [JSON API error object][] | Unable to complete verification request to destination URL | | [404][] | [JSON API error object][] | Workspace not found, or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request body This POST endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. If `enabled` is set to `true`, a verification request will be sent before saving the configuration. If this request receives no response or the response is not successful (HTTP 2xx), the configuration will not save. | Key path | Type | Default | Description | | ---------------------------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.027495503425598145,
0.062012430280447006,
0.026614462956786156,
0.008078513666987419,
0.010748472064733505,
0.0017532992642372847,
0.028104690834879875,
0.0005863865371793509,
0.01679607853293419,
0.04313886538147926,
-0.014838841743767262,
-0.0975823849439621,
0.06554551422595978,
-0.0... | 0.070174 |
a verification request will be sent before saving the configuration. If this request receives no response or the response is not successful (HTTP 2xx), the configuration will not save. | Key path | Type | Default | Description | | ---------------------------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"notification-configuration"`. | | `data.attributes.destination-type` | string | | Type of notification payload to send. Valid values are `"generic"`, `"email"`, `"slack"` or `"microsoft-teams"`. | | `data.attributes.enabled` | bool | `false` | Disabled configurations will not send any notifications. | | `data.attributes.name` | string | | Human-readable name for the configuration. | | `data.attributes.token` | string or null | `null` | Optional write-only secure token, which can be used at the receiving server to verify request authenticity. See [Notification Authenticity][notification-authenticity] for more details. | | `data.attributes.triggers` | array | `[]` | Array of triggers for which this configuration will send notifications. See [Notification Triggers][notification-triggers] for more details and a list of allowed values. | | `data.attributes.url` | string | | HTTP or HTTPS URL to which notification requests will be made, only for configurations with `"destination\_type:"` `"slack"`, `"microsoft-teams"` or `"generic"` | | `data.relationships.users` | array | | Array of users part of the organization, only for configurations with `"destination\_type:"` `"email"` | [notification-authenticity]: #notification-authenticity [notification-triggers]: #notification-triggers ### Sample payload for generic notification configurations ```json { "data": { "type": "notification-configuration", "attributes": { "destination-type": "generic", "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ] } } } ``` ### Sample payload for email notification configurations ```json { "data": { "type": "notification-configurations", "attributes": { "destination-type": "email", "enabled": true, "name": "Notify organization users about run", "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ] }, "relationships": { "users": { "data": [ { "id": "organization-user-id", "type": "users" } ] } } } } ``` ### Sample request ```shell 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-XdeUVMWShTesDMME/notification-configurations ``` ### Sample response ```json { "data": { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2019 21:34:37 GMT" ] }, "sent-at": "2019-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2019-01-08T21:32:14.125Z", "updated-at": "2019-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } } ``` ## List notification configurations Use the following endpoint to list all notification configurations for a workspace. `GET /workspaces/:workspace\_id/notification-configurations` | Parameter | Description | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:workspace\_id` | The ID of the workspace to list configurations from. Obtain this from the [workspace settings](/terraform/cloud-docs/workspaces/settings) or the [Show Workspace](/terraform/cloud-docs/api-docs/workspaces#show-workspace) endpoint. If neither pagination query parameters are provided, the endpoint will not be paginated and will return all results. | ### Query parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | ------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.03303118795156479,
0.017640288919210434,
-0.03202357515692711,
0.01892397738993168,
0.0029857950285077095,
-0.0777784064412117,
-0.05635714903473854,
-0.0339936837553978,
0.0007106595439836383,
0.04088607802987099,
0.037935882806777954,
-0.05407363548874855,
0.07945531606674194,
-0.0828... | -0.055694 |
Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | ------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 notification configurations per page. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/workspaces/ws-XdeUVMWShTesDMME/notification-configurations ``` ### Sample response ```json { "data": [ { "id": "nc-W6VGEi8A7Cfoaf4K", "type": "notification-configurations", "attributes": { "enabled": false, "name": "Slack: #devops", "url": "https://hooks.slack.com/services/T00000000/BC012345/0PWCpQmYyD4bTTRYZ53q4w", "destination-type": "slack", "token": null, "triggers": [ "run:errored", "run:needs\_attention" ], "delivery-responses": [], "created-at": "2019-01-08T21:34:28.367Z", "updated-at": "2019-01-08T21:34:28.367Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-W6VGEi8A7Cfoaf4K" } }, { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2019 21:34:37 GMT" ] }, "sent-at": "2019-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2019-01-08T21:32:14.125Z", "updated-at": "2019-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } ] } ``` ## Show a notification configuration `GET /notification-configurations/:notification-configuration-id` | Parameter | Description | | -------------------------------- | ------------------------------------------------- | | `:notification-configuration-id` | The id of the notification configuration to show. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ ``` ### Sample response The `type` and `id` attributes in `relationships.subscribable` may also reference a `"teams"` and team ID, respectively. ```json { "data": { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2019 21:34:37 GMT" ] }, "sent-at": "2019-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2019-01-08T21:32:14.125Z", "updated-at": "2019-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } } ``` ## Update a notification configuration `PATCH /notification-configurations/:notification-configuration-id` | Parameter | Description | | -------------------------------- | --------------------------------------------------- | | `:notification-configuration-id` | The id of the notification configuration to update. | If the `enabled` attribute is true, updating the configuration will cause HCP Terraform to send a verification request. If a response is received, it will be stored and returned in the `delivery-responses` attribute. More details in the [Notification Verification and Delivery Responses][] section above. [Notification Verification and Delivery Responses]: #notification-verification-and-delivery-responses | Status | Response | Reason | | ------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "notification-configurations"`) | Successfully updated the notification configuration | | [400][] | [JSON API error object][] | Unable to complete verification request to destination URL | | [404][] | [JSON API error object][] | Notification configuration not found, | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.013103889301419258,
0.058879803866147995,
-0.0566248781979084,
0.03129458427429199,
-0.011764554306864738,
-0.023650633171200752,
0.0093971136957407,
-0.014772097580134869,
0.037198521196842194,
0.0077825584448874,
0.007028544787317514,
-0.11580658704042435,
0.07201717793941498,
-0.0493... | 0.006587 |
------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "notification-configurations"`) | Successfully updated the notification configuration | | [400][] | [JSON API error object][] | Unable to complete verification request to destination URL | | [404][] | [JSON API error object][] | Notification configuration not found, or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request body This PATCH endpoint requires a JSON object with the following properties as a request payload. If `enabled` is set to `true`, a verification request will be sent before saving the configuration. If this request fails to send, or the response is not successful (HTTP 2xx), the configuration will not save. | Key path | Type | Default | Description | | -------------------------- | ------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | (previous value) | Must be `"notification-configuration"`. | | `data.attributes.enabled` | bool | (previous value) | Disabled configurations will not send any notifications. | | `data.attributes.name` | string | (previous value) | User-readable name for the configuration. | | `data.attributes.token` | string | (previous value) | Optional write-only secure token, which can be used at the receiving server to verify request authenticity. See [Notification Authenticity][notification-authenticity] for more details. | | `data.attributes.triggers` | array | (previous value) | Array of triggers for sending notifications. See [Notification Triggers][notification-triggers] for more details. | | `data.attributes.url` | string | (previous value) | HTTP or HTTPS URL to which notification requests will be made, only for configurations with `"destination\_type:"` `"slack"`, `"microsoft-teams"` or `"generic"` | | `data.relationships.users` | array | | Array of users part of the organization, only for configurations with `"destination\_type:"` `"email"` | [notification-authenticity]: #notification-authenticity [notification-triggers]: #notification-triggers ### Sample payload ```json { "data": { "id": "nc-W6VGEi8A7Cfoaf4K", "type": "notification-configurations", "attributes": { "enabled": false, "name": "Slack: #devops", "url": "https://hooks.slack.com/services/T00000001/BC012345/0PWCpQmYyD4bTTRYZ53q4w", "destination-type": "slack", "token": null, "triggers": [ "run:created", "run:errored", "run:needs\_attention" ], } } } ``` ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/notification-configurations/nc-W6VGEi8A7Cfoaf4K ``` ### Sample response ```json { "data": { "id": "nc-W6VGEi8A7Cfoaf4K", "type": "notification-configurations", "attributes": { "enabled": false, "name": "Slack: #devops", "url": "https://hooks.slack.com/services/T00000001/BC012345/0PWCpQmYyD4bTTRYZ53q4w", "destination-type": "slack", "token": null, "triggers": [ "run:created", "run:errored", "run:needs\_attention" ], "delivery-responses": [], "created-at": "2019-01-08T21:34:28.367Z", "updated-at": "2019-01-08T21:49:02.103Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-W6VGEi8A7Cfoaf4K" } }, } ``` ## Verify a notification configuration `POST /notification-configurations/:notification-configuration-id/actions/verify` | Parameter | Description | | -------------------------------- | --------------------------------------------------- | | `:notification-configuration-id` | The id of the notification configuration to verify. | This will cause HCP Terraform to send a verification request for the specified configuration. If a response is received, it will be stored and returned in the `delivery-responses` attribute. More details in the [Notification Verification and Delivery Responses][] section above. | Status | Response | Reason | | ------- | ------------------------------------------------------------- | ---------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "notification-configurations"`) | Successfully verified the notification configuration | | [400][] | [JSON API error object][] | Unable to complete verification request to destination URL | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ https://app.terraform.io/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ/actions/verify ``` ### Sample response ```json { "data": { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.058830633759498596,
0.03728507086634636,
-0.0004218016692902893,
-0.04377461224794388,
0.045266587287187576,
-0.07925889641046524,
0.009670671075582504,
-0.03107803873717785,
0.03823017701506615,
-0.01843605563044548,
0.04009396955370903,
-0.08132599294185638,
0.05388932302594185,
0.052... | 0.099226 |
"id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "run:applying", "run:completed", "run:created", "run:errored", "run:needs\_attention", "run:planning" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2019 21:34:37 GMT" ] }, "sent-at": "2019-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2019-01-08T21:32:14.125Z", "updated-at": "2019-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "ws-XdeUVMWShTesDMME", "type": "workspaces" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } } ``` ## Delete a notification configuration This endpoint deletes a notification configuration. `DELETE /notification-configurations/:notification-configuration-id` | Parameter | Description | | -------------------------------- | --------------------------------------------------- | | `:notification-configuration-id` | The id of the notification configuration to delete. | | Status | Response | Reason | | ------- | ------------------------- | ---------------------------------------------------------------------------- | | [204][] | None | Successfully deleted the notification configuration | | [404][] | [JSON API error object][] | Notification configuration not found, or user unauthorized to perform action | ### Sample request ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ ``` ## Team notification configuration Team notifications allow you to configure relevant alerts that notify teams you specify whenever a certain event occurs. @include 'tfc-package-callouts/notifications.mdx' ### Create a team notification configuration By default, every team has a default email notification configuration with no users assigned. If a notification configuration has no users assigned, HCP Terraform sends email notifications to all team members. Use this endpoint to create a notification configuration to notify a team. `POST /teams/:team\_id/notification-configurations` | Parameter | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:team\_id` | The ID of the team to create a configuration for. | | Status | Response | Reason | | ------- | ------------------------------------------------------------- | -------------------------------------------------------------- | | [201][] | [JSON API document][] (`type: "notification-configurations"`) | Successfully created a notification configuration | | [400][] | [JSON API error object][] | Unable to complete verification request to destination URL | | [404][] | [JSON API error object][] | Team not found, or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | #### Request body This `POST` endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. If `enabled` is set to `true`, HCP Terraform sends a verification request before saving the configuration. If this request does not receive a response or the response is not successful (HTTP 2xx), the configuration will not be saved. | Key path | Type | Default | Description | | ---------------------------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"notification-configuration"`. | | `data.attributes.destination-type` | string | | Type of notification payload to send. Valid values are `"generic"`, `"email"`, `"slack"` or `"microsoft-teams"`. | | `data.attributes.enabled` | bool | `false` | Disabled configurations will not send any notifications. | | `data.attributes.name` | string | | Human-readable name for the configuration. | | `data.attributes.token` | string or null | `null` | Optional write-only secure token, which can be used at the receiving server to verify request authenticity. See [Notification Authenticity][notification-authenticity] for more details. | | `data.attributes.triggers` | array | `[]` | Array of triggers for which this configuration will send notifications. See [Notification Triggers][notification-triggers] | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.05192040652036667,
0.0892966017127037,
-0.07126474380493164,
0.035848621279001236,
0.03440173715353012,
-0.09860825538635254,
0.0006311012548394501,
-0.01481440756469965,
0.02686522714793682,
0.03312824293971062,
-0.0235418900847435,
-0.0991319939494133,
0.006411025766283274,
-0.0506037... | 0.112106 |
| string or null | `null` | Optional write-only secure token, which can be used at the receiving server to verify request authenticity. See [Notification Authenticity][notification-authenticity] for more details. | | `data.attributes.triggers` | array | `[]` | Array of triggers for which this configuration will send notifications. See [Notification Triggers][notification-triggers] for more details and a list of allowed values. | | `data.attributes.url` | string | | HTTP or HTTPS URL to which notification requests will be made, only for configurations with `"destination\_type:"` `"slack"`, `"microsoft-teams"` or `"generic"` | | `data.attributes.email\_all\_members`| bool | | Email all team members, only for configurations with `"destination\_type:" "email"`. | | `data.relationships.users` | array | | Array of users part of the organization, only for configurations with `"destination\_type:"` `"email"` | [notification-authenticity]: #notification-authenticity [notification-triggers]: #notification-triggers #### Sample payload for generic notification configurations ```json { "data": { "type": "notification-configuration", "attributes": { "destination-type": "generic", "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "triggers": [ "change\_request:created" ] } } } ``` #### Sample payload for email notification configurations ```json { "data": { "type": "notification-configurations", "attributes": { "destination-type": "email", "enabled": true, "name": "Email teams about change requests", "triggers": [ "change\_request:created" ] }, "relationships": { "users": { "data": [ { "id": "organization-user-id", "type": "users" } ] } } } } ``` #### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/teams/team-6p5jTwJQXwqZBncC/notification-configurations ``` #### Sample response ```json { "data": { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "change\_request:created" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2024 21:34:37 GMT" ] }, "sent-at": "2024-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2024-01-08T21:32:14.125Z", "updated-at": "2024-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "team-6p5jTwJQXwqZBncC", "type": "teams" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } } ``` ### List team notification configurations Use this endpoint to list notification configurations for a team. `GET /teams/:team\_id/notification-configurations` | Parameter | Description | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:team\_id` | The ID of the teams to list configurations from. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | ------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 notification configurations per page. | #### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/teams/team-6p5jTwJQXwqZBncC/notification-configurations ``` #### Sample response ```json { "data": [ { "id": "nc-W6VGEi8A7Cfoaf4K", "type": "notification-configurations", "attributes": { "enabled": false, "name": "Slack: #devops", "url": "https://hooks.slack.com/services/T00000000/BC012345/0PWCpQmYyD4bTTRYZ53q4w", "destination-type": "slack", "token": null, "triggers": [ "change\_request:created" ], "delivery-responses": [], "created-at": "2019-01-08T21:34:28.367Z", "updated-at": "2019-01-08T21:34:28.367Z" }, "relationships": { "subscribable": { "data": { "id": "team-TdeUVMWShTesDMME", "type": "teams" } } }, "links": { "self": "/api/v2/notification-configurations/nc-W6VGEi8A7Cfoaf4K" } }, { "id": "nc-AeUQ2zfKZzW9TiGZ", "type": "notification-configurations", "attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "change\_request:created" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.013021634891629219,
0.001052808715030551,
-0.0495227575302124,
0.058396030217409134,
0.07157493382692337,
-0.05089925229549408,
0.09913212060928345,
-0.0592641644179821,
0.0318167507648468,
0.030564719811081886,
0.00418572872877121,
-0.08104220777750015,
0.1063215583562851,
0.0972160100... | 0.091099 |
"attributes": { "enabled": true, "name": "Webhook server test", "url": "https://httpstat.us/200", "destination-type": "generic", "token": null, "triggers": [ "change\_request:created" ], "delivery-responses": [ { "url": "https://httpstat.us/200", "body": "\"200 OK\"", "code": "200", "headers": { "cache-control": [ "private" ], "content-length": [ "129" ], "content-type": [ "application/json; charset=utf-8" ], "content-encoding": [ "gzip" ], "vary": [ "Accept-Encoding" ], "server": [ "Microsoft-IIS/10.0" ], "x-aspnetmvc-version": [ "5.1" ], "access-control-allow-origin": [ "\*" ], "x-aspnet-version": [ "4.0.30319" ], "x-powered-by": [ "ASP.NET" ], "set-cookie": [ "ARRAffinity=77c477e3e649643e5771873e1a13179fb00983bc73c71e196bf25967fd453df9;Path=/;HttpOnly;Domain=httpstat.us" ], "date": [ "Tue, 08 Jan 2019 21:34:37 GMT" ] }, "sent-at": "2019-01-08 21:34:37 UTC", "successful": "true" } ], "created-at": "2019-01-08T21:32:14.125Z", "updated-at": "2019-01-08T21:34:37.274Z" }, "relationships": { "subscribable": { "data": { "id": "team-XdeUVMWShTesDMME", "type": "teams" } } }, "links": { "self": "/api/v2/notification-configurations/nc-AeUQ2zfKZzW9TiGZ" } } ] } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/notification-configurations.mdx | main | terraform | [
-0.0619942732155323,
0.08760575205087662,
-0.09839191287755966,
0.05316804721951485,
0.010899129323661327,
-0.0873313844203949,
0.004688787739723921,
-0.014118198305368423,
0.02986956760287285,
0.060208093374967575,
0.010066932067275047,
-0.09957392513751984,
0.03986882045865059,
-0.031369... | 0.074886 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [307]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Plans API reference A plan represents the execution plan of a Run in a Terraform workspace. ## Attributes ### Plan States The plan state is found in `data.attributes.status`, and you can reference the following list of possible states. | State | Description | | ------------------------- | ----------------------------------------------------------------------------- | | `pending` | The initial status of a plan once it has been created. | | `managed\_queued`/`queued` | The plan has been queued, awaiting backend service capacity to run terraform. | | `running` | The plan is running. | | `errored` | The plan has errored. This is a final state. | | `canceled` | The plan has been canceled. This is a final state. | | `finished` | The plan has completed successfully. This is a final state. | | `unreachable` | The plan will not run. This is a final state. | ## Show a plan `GET /plans/:id` | Parameter | Description | | --------- | --------------------------- | | `id` | The ID of the plan to show. | There is no endpoint to list plans. You can find the ID for a plan in the `relationships.plan` property of a run object. | Status | Response | Reason | | ------- | --------------------------------------- | ------------------------------------------------------ | | [200][] | [JSON API document][] (`type: "plans"`) | The request was successful | | [404][] | [JSON API error object][] | Plan not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/plans/plan-8F5JFydVYAmtTjET ``` ### Sample Response ```json { "data": { "id": "plan-8F5JFydVYAmtTjET", "type": "plans", "attributes": { "execution-details": { "mode": "remote", }, "generated-configuration": false, "has-changes": true, "resource-additions": 0, "resource-changes": 1, "resource-destructions": 0, "resource-imports": 0, "status": "finished", "status-timestamps": { "queued-at": "2018-07-02T22:29:53+00:00", "pending-at": "2018-07-02T22:29:53+00:00", "started-at": "2018-07-02T22:29:54+00:00", "finished-at": "2018-07-02T22:29:58+00:00" }, "log-read-url": "https://archivist.terraform.io/v1/object/dmF1bHQ6djE6OFA1eEdlSFVHRSs4YUcwaW83a1dRRDA0U2E3T3FiWk1HM2NyQlNtcS9JS1hHN3dmTXJmaFhEYTlHdTF1ZlgxZ2wzVC9kVTlNcjRPOEJkK050VFI3U3dvS2ZuaUhFSGpVenJVUFYzSFVZQ1VZYno3T3UyYjdDRVRPRE5pbWJDVTIrNllQTENyTndYd1Y0ak1DL1dPVlN1VlNxKzYzbWlIcnJPa2dRRkJZZGtFeTNiaU84YlZ4QWs2QzlLY3VJb3lmWlIrajF4a1hYZTlsWnFYemRkL2pNOG9Zc0ZDakdVMCtURUE3dDNMODRsRnY4cWl1dUN5dUVuUzdnZzFwL3BNeHlwbXNXZWRrUDhXdzhGNnF4c3dqaXlZS29oL3FKakI5dm9uYU5ZKzAybnloREdnQ3J2Rk5WMlBJemZQTg" }, "relationships": { "state-versions": { "data": [] } }, "links": { "self": "/api/v2/plans/plan-8F5JFydVYAmtTjET", "json-output": "/api/v2/plans/plan-8F5JFydVYAmtTjET/json-output" } } } ``` \_Using HCP Terraform agents\_ [HCP Terraform agents](/terraform/cloud-docs/api-docs/agents) allow HCP Terraform to communicate with isolated, private, or on-premises infrastructure. When a workspace is set to use the agent execution mode, the plan response will include additional details about the agent pool and agent used. ```json { "data": { "id": "plan-8F5JFydVYAmtTjET", "type": "plans", "attributes": { "execution-details": { "agent-id": "agent-S1Y7tcKxXPJDQAvq", "agent-name": "agent\_01", "agent-pool-id": "apool-Zigq2VGreKq7nwph", "agent-pool-name": "first-pool", "mode": "agent", }, "generated-configuration": false, "has-changes": true, "resource-additions": 0, "resource-changes": 1, "resource-destructions": 0, "resource-imports": 0, "status": "finished", "status-timestamps": { "queued-at": "2018-07-02T22:29:53+00:00", "pending-at": "2018-07-02T22:29:53+00:00", "started-at": "2018-07-02T22:29:54+00:00", "finished-at": "2018-07-02T22:29:58+00:00" }, "log-read-url": "https://archivist.terraform.io/v1/object/dmF1bHQ6djE6OFA1eEdlSFVHRSs4YUcwaW83a1dRRDA0U2E3T3FiWk1HM2NyQlNtcS9JS1hHN3dmTXJmaFhEYTlHdTF1ZlgxZ2wzVC9kVTlNcjRPOEJkK050VFI3U3dvS2ZuaUhFSGpVenJVUFYzSFVZQ1VZYno3T3UyYjdDRVRPRE5pbWJDVTIrNllQTENyTndYd1Y0ak1DL1dPVlN1VlNxKzYzbWlIcnJPa2dRRkJZZGtFeTNiaU84YlZ4QWs2QzlLY3VJb3lmWlIrajF4a1hYZTlsWnFYemRkL2pNOG9Zc0ZDakdVMCtURUE3dDNMODRsRnY4cWl1dUN5dUVuUzdnZzFwL3BNeHlwbXNXZWRrUDhXdzhGNnF4c3dqaXlZS29oL3FKakI5dm9uYU5ZKzAybnloREdnQ3J2Rk5WMlBJemZQTg" }, "relationships": { "state-versions": { "data": [] } }, "links": { "self": "/api/v2/plans/plan-8F5JFydVYAmtTjET", "json-output": "/api/v2/plans/plan-8F5JFydVYAmtTjET/json-output" } } } ``` ## Retrieve the JSON execution plan `GET /plans/:id/json-output` `GET /runs/:id/plan/json-output` These endpoints generate a temporary authenticated URL to the location of the [JSON formatted execution plan](/terraform/internals/json-format#format-summary). When successful, this endpoint responds with a temporary redirect that should be followed. If using a client that can follow redirects, you can use this endpoint to save the `.json` file locally without needing to save the temporary URL. This temporary URL provided by the redirect has a life of \*\*1 minute\*\*, and should not be relied upon beyond the initial request. If you need repeat access, you should use this endpoint to generate a new URL each time. -> \*\*Note:\*\* This endpoint is available for plans using Terraform 0.12 and later. For Terraform Enterprise, this endpoint is available from v202005-1, and its | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/plans.mdx | main | terraform | [
-0.026010459288954735,
-0.02275005355477333,
-0.026095468550920486,
-0.018418513238430023,
-0.02009897492825985,
-0.08436909317970276,
-0.05374377593398094,
-0.0791759043931961,
-0.0060250526294112206,
-0.03486490249633789,
0.03005075827240944,
0.05508139356970787,
0.0022271922789514065,
-... | 0.068675 |
should not be relied upon beyond the initial request. If you need repeat access, you should use this endpoint to generate a new URL each time. -> \*\*Note:\*\* This endpoint is available for plans using Terraform 0.12 and later. For Terraform Enterprise, this endpoint is available from v202005-1, and its stability was improved in v202007-1. -> \*\*Note:\*\* This endpoint cannot be accessed with [organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens) that has admin level access to the workspace. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers | Status | Response | Reason | | ------- | ------------------------- | ------------------------------------------------------------- | | [204][] | No Content | Plan JSON supported, but plan has not yet completed. | | [307][] | Temporary Redirect | Plan JSON found and temporary download URL generated | | [422][] | [JSON API error object][] | Plan does not use a supported version of terraform (< 0.12.X) | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --location \ https://app.terraform.io/api/v2/plans/plan-8F5JFydVYAmtTjET/json-output | > json-output.json ``` ## Retrieve the sanitized plan `GET /plans/:id/sanitized-plan` `GET /runs/:id/plan/sanitized-plan` HCP Terraform workspaces that have enabled hold your own key (HYOK) encryption create sanitized plans that omit sensitive encrypted data. You can download the sanitized version of the plan file with your sensitive information redacted. Learn more about [hold your own key](/terraform/cloud-docs/hold-your-own-key). These endpoints generate a temporary authenticated URL to the sanitized execution plan. When successful, this endpoint responds with a temporary redirect. Follow the redirect to save your `.json` file locally without needing to save the temporary URL. The temporary URL that the redirect provides has a life of 1 minute. If you need repeat access, use this endpoint to generate a new URL. | Status | Response | Reason | | ------- | ------------------------- | ---------------------------------------------------------------- | | [204][] | No Content | Sanitized plan supported, but plan has not yet completed. | | [307][] | Temporary Redirect | Sanitized plan found and temporary download URL generated | | [422][] | [JSON API error object][] | Sanitized plan does not use a supported version of terraform (< 1.3.0) | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --location \ https://app.terraform.io/api/v2/plans/plan-8F5JFydVYAmtTjET/sanitized-plan | > json-output.json ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/plans.mdx | main | terraform | [
-0.04246988892555237,
0.009303000755608082,
0.029232293367385864,
0.020786505192518234,
-0.03713805973529816,
-0.050370749086141586,
-0.05467784032225609,
-0.0335351787507534,
0.06749116629362106,
0.09548787772655487,
-0.06646288931369781,
-0.029693158343434334,
0.024199465289711952,
0.033... | 0.043697 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # API documentation overview HCP Terraform provides an API for a subset of its features. If you need assistance or want to submit a feature request, visit the [HashiCorp support center](https://support.hashicorp.com/hc/en-us) and open a ticket. Terraform Enterprise provides an API for a subset of its features. If you need assistance or want to submit a feature request, visit the [HashiCorp support center](https://support.hashicorp.com/hc/en-us) and open a ticket. Before planning an API integration, consider whether the [HCP Terraform and Terraform Enterprise provider](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs) meets your needs. It can't create or approve runs in response to arbitrary events, but it's a useful tool for managing your organizations, teams, and workspaces as code. The [HashiCorp API stability policy](/terraform/cloud-docs/api-docs/stability-policy) ensures backward compatibility for stable endpoints. The [changelog](/terraform/cloud-docs/api-docs/changelog) tracks changes to the API. ## System endpoints The API includes endpoints for system-level operations, such as health checks and usage reporting. System endpoints have different authentication and rate limiting requirements than application endpoints. Refer to the following documentation for details about system endpoints: - [`/api/v1/ping`](/terraform/enterprise/api-docs/ping). Call this endpoint to verify system operation. - [`/api/v1/usage/bundle`](/terraform/enterprise/api-docs/usage-bundle). Call this endpoint to retrieve a usage data bundle. ## Authentication All requests must be authenticated with a bearer token. Use the HTTP header `Authorization` with the value `Bearer `. If the token is absent or invalid, HCP Terraform responds with [HTTP status 401][401] and a [JSON API error object][]. The 401 status code is reserved for problems with the authentication token; forbidden requests with a valid token result in a 404. You can use the following types of tokens to authenticate: - [User tokens](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) — each HCP Terraform user can have any number of API tokens, which can make requests on their behalf. - [Team tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens) — each team can have one API token at a time. This is intended for performing plans and applies via a CI/CD pipeline. - [Organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens) — each organization can have one API token at a time. This is intended for automating the management of teams, team membership, and workspaces. The organization token cannot perform plans and applies. - [Audit trails token](/terraform/cloud-docs/users-teams-organizations/api-tokens#audit-trails-tokens) - each organization can have a single token that can read that organization's audit trails. Use this token type to authenticate integrations pulling audit trail data, for example, using the [HCP Terraform for Splunk](/terraform/cloud-docs/integrations/splunk) app. ### System endpoints ### Blob storage authentication HCP Terraform relies on a HashiCorp-developed blob storage service for storing statefiles and multiple other pieces of customer data, all of which are documented on our [data security page](/terraform/cloud-docs/architectural-details/data-security). Terraform Enterprise relies on a HashiCorp-developed blob storage service for storing state files and other pieces of customer data. This service does not require you to submit a bearer token with each request. Instead, each URL includes a securely-generated secret and is only valid for 25 hours. For example, the [state versions endpoint](/terraform/enterprise/api-docs/state-versions) returns a field named `hosted-state-download` that contains a URL in the following format: `https://archivist.terraform.io/v1/object/` This is a widely accepted pattern for secure access. Treat URLs retrieved from the blob storage service as secrets. Do not log them or share them with untrusted parties. ## Feature entitlements HCP Terraform is available at multiple pricing tiers, including free, which offer different feature sets. Each organization has a set of \_entitlements\_ that corresponds to its pricing tier. These entitlements determine which HCP Terraform features the organization can use. If an organization doesn't have the necessary entitlement to | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
Feature entitlements HCP Terraform is available at multiple pricing tiers, including free, which offer different feature sets. Each organization has a set of \_entitlements\_ that corresponds to its pricing tier. These entitlements determine which HCP Terraform features the organization can use. If an organization doesn't have the necessary entitlement to use a given feature, the application returns a `404` error for API requests to any endpoints devoted to that feature. The [show entitlement set](/terraform/cloud-docs/api-docs/organizations#show-the-entitlement-set) endpoint can return information about an organization's current entitlements, which is useful if your client needs to change its interface when a given feature isn't available. The following entitlements are available: - `agents` — Allows isolated, private or on-premises infrastructure to communicate with an organization in HCP Terraform. Affects the [agent pools][], [agents][], and [agent tokens][] endpoints. - `audit-logging` — Allows an organization to access [audit trails][]. - `configuration-designer` — Allows an organization to use the [Configuration Designer][]. - `cost-estimation` — Allows an organization to access [cost estimation][]. - `global-run-tasks` — Allows an organization to apply [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) to every workspace. Affects the [run tasks][] endpoints. This feature is currently in beta. - `groups` - Allows an organization to manage access to its workspaces with [groups](https://docs.hashicorp.com/hcp/docs/hcp/iam/groups) for a HCP Europe organization. To learn more about HCP Europe, refer to the [HCP Europe documentation](/hcp/docs/hcp/europe). - `module-tests-generation` - Allows an organization to generate tests for private registry modules. This feature is currently in beta. - `module-deprecations` - Allows an organization to mark a module version from the Private Registry as deprecated. - `module-revocations` - Allows an organization to mark a deprecated module version from the Private Registry as revoked. - `operations` — Allows an organization to perform runs within HCP Terraform. Affects the [runs][], [plans][], and [applies][] endpoints. - `policy-enforcement` — Allows an organization to use [Sentinel](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel). Affects the [policies][], [policy sets][], and [policy checks][] endpoints. - `private-module-registry` — Allows an organization to publish and use modules with the [private module registry][]. Affects the [registry modules][] endpoints. - `private-policy-agents` - Allows an organization to ensure that HTTP enabled [Sentinel](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) and OPA [policies][] can communicate with isolated, private, or on-premises infrastructure. - `private-run-tasks` - Allows an organization to ensure that [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) can communicate with isolated, private, or on-premises infrastructure. - `private-vcs` - Allows a self-hosted HCP Terraform agent to [connect to a private VCS provider](/terraform/cloud-docs/vcs/private) without having to expose that provider to the public internet. - `run-tasks` — Allows an organization to use [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks). Affects the [run tasks][] endpoints. - `self-serve-billing` — Allows an organization to pay via credit card using the in-app billing UI. - `sentinel` - \*\*DEPRECATED\*\* Use `policy-enforcement` instead. - `state-storage` — Allows an organization to store state versions in its workspaces, which enables local Terraform runs with HCP Terraform. Affects the [state versions][] endpoints. - `sso` — Allows an organization to manage and authenticate users with single sign on. - `teams` — Allows an organization to manage access to its workspaces with [teams](/terraform/cloud-docs/users-teams-organizations/teams). Without this entitlement, an organization only has an owners team. Affects the [teams][], [team members][], [team access][], and [team tokens][] endpoints. - `user-limit` — An integer value representing the maximum number of users allowed for the organization. If blank, there is no limit. - `vcs-integrations` — Allows an organization to [connect with a VCS provider][vcs integrations] and link VCS repositories to workspaces. Affects the [OAuth Clients][o-clients], and [OAuth Tokens][o-tokens] endpoints, and determines whether the `data.attributes.vcs-repo` property can be set for [workspaces][]. [agents]: /terraform/cloud-docs/api-docs/agents [agent pools]: /terraform/cloud-docs/api-docs/agents [agent tokens]: /terraform/cloud-docs/api-docs/agent-tokens [applies]: /terraform/cloud-docs/api-docs/applies [audit trails]: /terraform/cloud-docs/api-docs/audit-trails [Configuration Designer]: /terraform/cloud-docs/registry/design [cost estimation]: /terraform/cloud-docs/cost-estimation [o-clients]: /terraform/cloud-docs/api-docs/oauth-clients [o-tokens]: /terraform/cloud-docs/api-docs/oauth-tokens [member roles]: /terraform/cloud-docs/api-docs/member-roles [plans]: /terraform/cloud-docs/api-docs/plans [policies]: | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx | main | terraform | [
-0.009021323174238205,
0.0458824448287487,
0.02180521748960018,
-0.05634573847055435,
0.045754268765449524,
0.03423651307821274,
-0.035676345229148865,
-0.020971808582544327,
-0.019068490713834763,
0.023734580725431442,
-0.03174301236867905,
-0.1482287347316742,
0.05363176017999649,
0.0152... | 0.088571 |
to workspaces. Affects the [OAuth Clients][o-clients], and [OAuth Tokens][o-tokens] endpoints, and determines whether the `data.attributes.vcs-repo` property can be set for [workspaces][]. [agents]: /terraform/cloud-docs/api-docs/agents [agent pools]: /terraform/cloud-docs/api-docs/agents [agent tokens]: /terraform/cloud-docs/api-docs/agent-tokens [applies]: /terraform/cloud-docs/api-docs/applies [audit trails]: /terraform/cloud-docs/api-docs/audit-trails [Configuration Designer]: /terraform/cloud-docs/registry/design [cost estimation]: /terraform/cloud-docs/cost-estimation [o-clients]: /terraform/cloud-docs/api-docs/oauth-clients [o-tokens]: /terraform/cloud-docs/api-docs/oauth-tokens [member roles]: /terraform/cloud-docs/api-docs/member-roles [plans]: /terraform/cloud-docs/api-docs/plans [policies]: /terraform/cloud-docs/api-docs/policies [policy checks]: /terraform/cloud-docs/api-docs/policy-checks [policy sets]: /terraform/cloud-docs/api-docs/policy-sets [private module registry]: /terraform/cloud-docs/registry [registry modules]: /terraform/cloud-docs/api-docs/private-registry/modules [registry providers]: /terraform/cloud-docs/api-docs/private-registry/providers [runs]: /terraform/cloud-docs/api-docs/run [run tasks]: /terraform/cloud-docs/api-docs/run-tasks/run-tasks [Sentinel]: /terraform/cloud-docs/policy-enforcement/sentinel [single sign on]: /terraform/cloud-docs/users-teams-organizations/single-sign-on [state versions]: /terraform/cloud-docs/api-docs/state-versions [teams]: /terraform/cloud-docs/api-docs/teams [team access]: /terraform/cloud-docs/api-docs/team-access [team members]: /terraform/cloud-docs/api-docs/team-members [team tokens]: /terraform/cloud-docs/api-docs/team-tokens [vcs integrations]: /terraform/cloud-docs/vcs [workspaces]: /terraform/cloud-docs/api-docs/workspaces ## Response codes This API returns standard HTTP response codes. We return 404 Not Found codes for resources that a user doesn't have access to, as well as for resources that don't exist. This is to avoid telling a potential attacker that a given resource exists. ## Versioning The API documented in these pages is the second version of HCP Terraform's API, and resides under the `/v2` prefix. Future APIs will increment this version, leaving the `/v1` API intact, though in the future we might deprecate certain features. In that case, we'll provide ample notice to migrate to the new API. ## Paths All V2 API endpoints use `/api/v2` as a prefix unless otherwise specified. For example, if the API endpoint documentation defines the path `/runs` then the full path is `/api/v2/runs`. ## JSON API formatting The HCP Terraform endpoints use the [JSON API specification](https://jsonapi.org/), which specifies key aspects of the API. Most notably: - [HTTP error codes](https://jsonapi.org/examples/#error-objects-error-codes) - [Error objects](https://jsonapi.org/examples/#error-objects-basics) - [Document structure][document] - [HTTP request/response headers](https://jsonapi.org/format/#content-negotiation) [document]: https://jsonapi.org/format/#document-structure ### JSON API documents Since our API endpoints use the JSON API spec, most of them return [JSON API documents][document]. Endpoints that use the POST method also require a JSON API document as the request payload. A request object usually looks something like this: ```json { "data": { "type":"vars", "attributes": { "key":"some\_key", "value":"some\_value", "category":"terraform", "hcl":false, "sensitive":false }, "relationships": { "workspace": { "data": { "id":"ws-4j8p6jX1w33MiDC7", "type":"workspaces" } } } } } ``` These objects always include a top-level `data` property, which: - Must have a `type` property to indicate what type of API object you're interacting with. - Often has an `attributes` property to specify attributes of the object you're creating or modifying. - Sometimes has a `relationships` property to specify other objects that are linked to what you're working with. In the documentation for each API method, we use dot notation to explain the structure of nested objects in the request. For example, the properties of the request object above are listed as follows: | Key path | Type | Default | Description | | ---------------------------------------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"vars"`. | | `data.attributes.key` | string | | The name of the variable. | | `data.attributes.value` | string | | The value of the variable. | | `data.attributes.category` | string | | Whether this is a Terraform or environment variable. Valid values are `"terraform"` or `"env"`. | | `data.attributes.hcl` | bool | `false` | Whether to evaluate the value of the variable as a string of HCL code. Has no effect for environment variables. | | `data.attributes.sensitive` | bool | `false` | Whether the value is sensitive. If true then the variable is written once and not visible thereafter. | | `data.relationships.workspace.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.workspace.data.id` | string | | The ID of the workspace that owns the variable. | We also always include a sample payload object, to show the document structure more visually. ### | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx | main | terraform | [
-0.04983610287308693,
0.034761421382427216,
0.02051382325589657,
0.05623829364776611,
0.04191097989678383,
-0.05666959285736084,
0.002905472181737423,
-0.04400504752993584,
0.1103229820728302,
0.04383530467748642,
-0.027585096657276154,
-0.04291921108961105,
0.043903667479753494,
0.0022507... | 0.042737 |
is written once and not visible thereafter. | | `data.relationships.workspace.data.type` | string | | Must be `"workspaces"`. | | `data.relationships.workspace.data.id` | string | | The ID of the workspace that owns the variable. | We also always include a sample payload object, to show the document structure more visually. ### Query parameters Although most of our API endpoints use the POST method and receive their parameters as a JSON object in the request payload, some of them use the GET method. These GET endpoints sometimes require URL query parameters, in the standard `...path?key1=value1&key2=value2` format. Since these parameters were originally designed as part of a JSON object, they sometimes have characters that must be [percent-encoded](https://en.wikipedia.org/wiki/Percent-encoding) in a query parameter. For example, `[` becomes `%5B` and `]` becomes `%5D`. For more about URI structure and query strings, see [the specification (RFC 3986)](https://tools.ietf.org/html/rfc3986) or [the Wikipedia page on URIs](https://en.wikipedia.org/wiki/Uniform\_Resource\_Identifier). ### Pagination Most of the endpoints that return lists of objects support pagination. A client may pass the following query parameters to control pagination on supported endpoints: | Parameter | Description | | -------------- | --------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 items per page. The maximum page size is 100. | Additional data is returned in the `links` and `meta` top level attributes of the response. ```json { "data": [...], "links": { "self": "https://app.terraform.io/api/v2/organizations/hashicorp/workspaces?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/organizations/hashicorp/workspaces?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": "https://app.terraform.io/api/v2/organizations/hashicorp/workspaces?page%5Bnumber%5D=2&page%5Bsize%5D=20", "last": "https://app.terraform.io/api/v2/organizations/hashicorp/workspaces?page%5Bnumber%5D=2&page%5Bsize%5D=20" }, "meta": { "pagination": { "current-page": 1, "prev-page": null, "next-page": 2, "total-pages": 2, "total-count": 21 } } } ``` ### Inclusion of related resources Some of the API's GET endpoints can return additional information about nested resources by adding an `include` query parameter, whose value is a comma-separated list of resource types. The related resource options are listed in each endpoint's documentation where available. The related resources will appear in an `included` section of the response. Example: ```shell $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/teams/team-n8UQ6wfhyym25sMe?include=users ``` ```json { "data": { "id": "team-n8UQ6wfhyym25sMe", "type": "teams", "attributes": { "name": "owners", "users-count": 1 ... }, "relationships": { "users": { "data": [ { "id": "user-62goNpx1ThQf689e", "type": "users" } ] } ... } ... }, "included": [ { "id": "user-62goNpx1ThQf689e", "type": "users", "attributes": { "username": "hashibot" ... } ... } ] } ``` ## Rate limits You can make up to 30 requests per second to most API endpoints as an authenticated or unauthenticated request. If you reach the rate limit then your access will be throttled and an error response will be returned. Requests are per user, not per token. As a result, you cannot use multiple tokens to make more than 30 requests per second. Unauthenticated requests are associated with the requesting IP address. | Status | Response | Reason | | ------- | ------------------------- | ---------------------------- | | [429][] | [JSON API error object][] | Rate limit has been reached. | ```json { "errors": [ { "detail": "You have exceeded the API's rate limit.", "status": 429, "title": "Too many requests" } ] } ``` ### Lower rate limits for some endpoints To prevent abuse, some endpoints have lower rate limits. The lower limits are unnoticeable under normal use. If you trigger a rate-limited response, you can see that limit in the `x-ratelimit-limit` header. The following endpoints have lower rate limits: | Method and endpoint | Purpose | Limit | | --- | --- | --- | | `POST /session/two-factor-send-sms` `POST /api/v2/account/actions/two-factor-enable` `POST /api/v2/account/actions/two-factor-resend-verification-code` | Send SMS message | 5 requests per minute per user| | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx | main | terraform | [
-0.06405866891145706,
0.017447032034397125,
-0.0451529286801815,
0.08437325805425644,
-0.09826550632715225,
-0.013543103821575642,
-0.05299736559391022,
0.014904893934726715,
0.08932658284902573,
-0.07857391238212585,
-0.016073796898126602,
0.009242205880582333,
0.0790359377861023,
-0.0012... | 0.062336 |
you can see that limit in the `x-ratelimit-limit` header. The following endpoints have lower rate limits: | Method and endpoint | Purpose | Limit | | --- | --- | --- | | `POST /session/two-factor-send-sms` `POST /api/v2/account/actions/two-factor-enable` `POST /api/v2/account/actions/two-factor-resend-verification-code` | Send SMS message | 5 requests per minute per user| | `POST /api/v2/account/actions/two-factor-enable` `POST /api/v2/account/actions/two-factor-resend-verification-code` | Send SMS message | 10 requests per hour per user| | `POST /api/v2/account/actions/two-factor-enable` `POST /api/v2/account/actions/two-factor-resend-verification-code` | Send SMS message | 100 requests per day per IP address | | `POST /session/two-factor` `POST /session/two-factor-recovery` | Submit 2FA code | 5 requests per minute per user| | `POST` and `PATCH /api/v2/account/create` `POST` and `PATCH /api/v2/account/update` `POST` and `PATCH /api/v2/account/password` `POST` and `PATCH /api/v2/account/reconfirm` `POST /session` | Send emails | 100 per minute | | `POST` and `GET /sso/link-new-account` `POST` and `GET /sso/link-account` `POST` and `GET /sso/link-existing-account` `POST /sso/saml/{SAML\_CONFIGURATION\_EXTERNAL\_ID}/acs` | Send emails | 20 per minute | | `POST /api/v2/notification-configurations/{EXTERNAL\_ID}/actions/verify` `DELETE /api/v2/oauth-tokens` | Send emails | 10 per minute | | `POST /account/reconfirm` | Send emails | 40 per hour | | `POST /auth` | Send emails | 40 per hour per email address | ## Client libraries and tools HashiCorp maintains the following clients for interacting with the HCP Terraform and Terraform Enterprise APIs: - [`go-tfe`](https://github.com/hashicorp/go-tfe) is a Go client - [`pytfe`](https://github.com/hashicorp/python-tfe) is a Python client Additionally, the community of HCP Terraform users and vendors have built client libraries in other languages. These client libraries and tools are not tested nor officially maintained by HashiCorp, but are listed below in order to help users find them easily. If you have built a client library and would like to add it to this community list, please [contribute](https://github.com/hashicorp/terraform-website#contributions-welcome) to [this page](https://github.com/hashicorp/web-unified-docs/blob/main/content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx#client-libraries-and-tools#client-libraries-and-tools). - [`tfh`](https://github.com/hashicorp-community/tf-helper) - A UNIX shell console application. - [`tf\_api\_gateway`](https://github.com/PlethoraOfHate/tf\_api\_gateway) - A Python API library and console application. - [`terrasnek`](https://github.com/dahlke/terrasnek) - A Python API library. - [`terraform-enterprise-client`](https://github.com/skierkowski/terraform-enterprise-client) - A Ruby API library and console application. - [`pyterprise`](https://github.com/JFryy/terraform-enterprise-api-python-client) - A simple python API client library. - [`Tfe.NetClient`](https://github.com/everis-technology/Tfe.NetClient) - A `.NET` client library. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx | main | terraform | [
0.0014454922638833523,
-0.046429719775915146,
-0.0236235149204731,
0.017305297777056694,
0.011726760305464268,
-0.05325064808130264,
-0.06571561098098755,
0.04771851748228073,
-0.005856489762663841,
0.02743859961628914,
0.10864268243312836,
-0.056143440306186676,
0.05603249743580818,
0.006... | 0.031294 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Policy checks API reference @include 'tfc-package-callouts/policies.mdx' Policy checks are the default workflow for Sentinel evaluating plans on workspaces. Policy checks use the latest version of the Sentinel runtime and have access to cost estimation data. This set of APIs provides endpoints to get, list, and override policy checks. @include 'deprecation/policy-checks.mdx' ## List Policy Checks This endpoint lists the policy checks in a run. -> \*\*Note\*\*: The `sentinel` hash in the `result` attribute structure represents low-level Sentinel details generated by the policy engine. The keys or structure may change over time. Use the data in this hash at your own risk. `GET /runs/:run\_id/policy-checks` | Parameter | Description | | --------- | -------------------------------------------- | | `run\_id` | The ID of the run to list policy checks for. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. If neither pagination query parameters are provided, the endpoint will not be paginated and will return all results. | Parameter | Description | | -------------- | ----------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 policy checks per page. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ https://app.terraform.io/api/v2/runs/run-CZcmD7eagjhyXavN/policy-checks ``` ### Sample Response ```json { "data": [ { "id": "polchk-9VYRc9bpfJEsnwum", "type": "policy-checks", "attributes": { "result": { "result": false, "passed": 0, "total-failed": 1, "hard-failed": 0, "soft-failed": 1, "advisory-failed": 0, "duration-ms": 0, "sentinel": {...} }, "scope": "organization", "status": "soft\_failed", "status-timestamps": { "queued-at": "2017-11-29T20:02:17+00:00", "soft-failed-at": "2017-11-29T20:02:20+00:00" }, "actions": { "is-overridable": true }, "permissions": { "can-override": false } }, "relationships": { "run": { "data": { "id": "run-veDoQbv6xh6TbnJD", "type": "runs" } } }, "links": { "output": "/api/v2/policy-checks/polchk-9VYRc9bpfJEsnwum/output" } } ] } ``` ## Show Policy Check This endpoint gets information about a specific policy check ID. Policy check IDs can appear in audit logs. -> \*\*Note\*\*: The `sentinel` hash in the `result` attribute structure represents low-level Sentinel details generated by the policy engine. The keys or structure may change over time. Use the data in this hash at your own risk. `GET /policy-checks/:id` | Parameter | Description | | --------- | ----------------------------------- | | `id` | The ID of the policy check to show. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ https://app.terraform.io/api/v2/policy-checks/polchk-9VYRc9bpfJEsnwum ``` ### Sample Response ```json { "data": { "id": "polchk-9VYRc9bpfJEsnwum", "type": "policy-checks", "attributes": { "result": { "result": false, "passed": 0, "total-failed": 1, "hard-failed": 0, "soft-failed": 1, "advisory-failed": 0, "duration-ms": 0, "sentinel": {...} }, "scope": "organization", "status": "soft\_failed", "status-timestamps": { "queued-at": "2017-11-29T20:02:17+00:00", "soft-failed-at": "2017-11-29T20:02:20+00:00" }, "actions": { "is-overridable": true }, "permissions": { "can-override": false } }, "relationships": { "run": { "data": { "id": "run-veDoQbv6xh6TbnJD", "type": "runs" } } }, "links": { "output": "/api/v2/policy-checks/polchk-9VYRc9bpfJEsnwum/output" } } } ``` ## Override Policy This endpoint overrides a soft-mandatory or warning policy. -> \*\*Note\*\*: The `sentinel` hash in the `result` attribute structure represents low-level Sentinel details generated by the policy engine. The keys or structure may change over time. Use the data in this hash at your own risk. `POST /policy-checks/:id/actions/override` | Parameter | Description | | --------- | --------------------------------------- | | `id` | The ID of the policy check to override. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policy-checks.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
Use the data in this hash at your own risk. `POST /policy-checks/:id/actions/override` | Parameter | Description | | --------- | --------------------------------------- | | `id` | The ID of the policy check to override. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ https://app.terraform.io/api/v2/policy-checks/polchk-EasPB4Srx5NAiWAU/actions/override ``` ### Sample Response ```json { "data": { "id": "polchk-EasPB4Srx5NAiWAU", "type": "policy-checks", "attributes": { "result": { "result": false, "passed": 0, "total-failed": 1, "hard-failed": 0, "soft-failed": 1, "advisory-failed": 0, "duration-ms": 0, "sentinel": {...} }, "scope": "organization", "status": "overridden", "status-timestamps": { "queued-at": "2017-11-29T20:13:37+00:00", "soft-failed-at": "2017-11-29T20:13:40+00:00", "overridden-at": "2017-11-29T20:14:11+00:00" }, "actions": { "is-overridable": true }, "permissions": { "can-override": false } }, "links": { "output": "/api/v2/policy-checks/polchk-EasPB4Srx5NAiWAU/output" } } } ``` ### Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | Resource Name | Description | | ------------------ | -------------------------------------- | | `run` | The run this policy check belongs to. | | `run.workspace` | The associated workspace of the run. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policy-checks.mdx | main | terraform | [
-0.04424009099602699,
0.12109950929880142,
0.026579923927783966,
-0.030913887545466423,
0.028433972969651222,
-0.05498791113495827,
-0.00005014597627450712,
-0.028454914689064026,
0.03360581025481224,
0.12948785722255707,
-0.014955765567719936,
-0.06506728380918503,
0.018449360504746437,
-... | -0.005124 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects [speculative plans]: /terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans # Projects API reference This topic provides reference information about the projects API. The scope of the API includes the following endpoints: | Method | Path | Action | | --- | --- | --- | | `POST` | `/organizations/:organization\_name/projects` | Call this endpoint to [create a project](#create-a-project). | | `PATCH`| `/projects/:project\_id` | Call this endpoint to [update an existing project](#update-a-project). | | `GET` | `/organizations/:organization\_name/projects`| Call this endpoint to [list existing projects](#list-projects). | | `GET` | `/projects/:project\_id` | Call this endpoint to [show project details](#show-project). | | `DELETE` | `/projects/:project\_id` | Call this endpoint to [delete a project](#delete-a-project). | | `GET` | `/projects/:project\_id/tag-bindings` | Call this endpoint to [list project tag bindings](#list-project-tag-bindings). (For projects, this returns the same result set as the `effective-tag-bindings` endpoint.) | | `GET` | `/projects/:project\_id/effective-tag-bindings` | Call this endpoint to [list project effective tag bindings](#list-project-tag-bindings). (For projects, this returns the same result set as the `tag-bindings` endpoint.) | ## Requirements You must be on a team with one of the \*\*Owners\*\* or \*\*Manage projects\*\* permissions settings enabled to create and manage projects. Refer to [Permissions](/terraform/cloud-docs/users-teams-organizations/permissions) for additional information. You can also provide an organization API token to call project API endpoints. Refer to [Organization API Tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens) for additional information. ## Create a Project `POST /organizations/:organization\_name/projects` | Parameter | Description | |----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `:organization\_name` | The name of the organization to create the project in. The organization must already exist in the system, and the user must have permissions to create new projects. | ### 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 path | Type | Default | Description | |---|---|---|--- | | `data.type` | string | none | Must be `"projects"`. | | `data.attributes.name` | string | | The name of the project. The name can contain letters, numbers, spaces, `-`, and `\_`, but cannot start or end with spaces. It must be at least three characters long and no more than 40 characters long. | | `data.attributes.description` | string | none | Optional. The description of the project. It must be no more than 256 characters long. | | `data.attributes.auto-destroy-activity-duration`| string | none | Specifies the default for how long each workspace in the project should wait before automatically destroying its infrastructure. You can specify a duration up to four digits that is greater than `0` followed by either a `d` for days or `h` hours. For example, to queue destroy runs after fourteen days of inactivity set `auto-destroy-activity-duration: "14d"`. All future workspaces in this project inherit this default value. Refer to [Automatically destroy inactive workspaces](/terraform/cloud-docs/projects/managing#automatically-destroy-inactive-workspaces) for additional information. | | `data.relationships.tag-bindings.data` | list of objects | none | Specifies a list of tags to bind to the project. Workspaces inherit the tags bound to their project. | | `data.relationships.tag-bindings.data.type` | string | none | Must be `tag-bindings` for each object in the list. | | `data.relationships.tag-bindings.data.attributes.key` | string | none | Specifies the tag key for each object in the list. | | `data.relationships.tag-bindings.data.attributes.value` | string | none | Specifies the tag value for each object in the list. | | `data.attributes.default-execution-mode` | boolean | `remote` | Specifies which [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) to use by default. Valid values are `remote`, `local`, and `agent`. | | `data.attributes.default-agent-pool` | string | (previous value) | Required when `default-execution-mode` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
| string | none | Specifies the tag value for each object in the list. | | `data.attributes.default-execution-mode` | boolean | `remote` | Specifies which [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) to use by default. Valid values are `remote`, `local`, and `agent`. | | `data.attributes.default-agent-pool` | string | (previous value) | Required when `default-execution-mode` is set to `agent`. The ID of the agent pool belonging to the project. Do \_not\_ specify this value if you set `execution-mode` to `remote` or `local`. | | `data.attributes.setting-overwrites` | object | | The keys in this object are attributes that have project-level defaults. Each attribute key stores a boolean value which is `false` by default. To overwrite the default inherited value, set an attribute's value to `true`. For example, to unset `execution-mode` as the project-level default, you set `setting-overwrites.execution-mode = true`. | ### Sample Payload ```json { "data": { "attributes": { "name": "Test Project", "description": "An example project for documentation.", "default-execution-mode": "remote", "setting-overwrites": { "execution-mode": false } }, "type": "projects", "relationships": { "default-agent-pool": { "data": null }, "tag-bindings": { "data": [ { "type": "tag-bindings", "attributes": { "key": "environment", "value": "development" } } ] } } } } ``` ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/projects ``` ### Sample Response ```json { "data": { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects", "attributes": { "name": "Test Project", "description": "An example project for documentation.", "default-execution-mode": "remote", "permissions": { "can-update": true }, "setting-overwrites": { "execution-mode": false } }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "default-agent-pool": { "data": null }, "tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/tag-bindings" } }, "effective-tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/effective-tag-bindings" } } }, "links": { "self": "/api/v2/projects/prj-WsVcWRr7SfxRci1v" } } } ``` ## Update a Project Call the following endpoint to update a project: `PATCH /projects/:project\_id` | Parameter | Description | |---------------|---------------------------------| | `:project\_id` | The ID of the project to update | ### Request Body These PATCH endpoints require a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | |---|---|---|---| | `data.type` | string | none | Must be `"projects"`. | | `data.attributes.name` | string | existing value | A new name for the project. The name can contain letters, numbers, spaces, `-`, and `\_`, but cannot start or end with spaces. It must be at least 3 characters long and no more than 40 characters long. | | `data.attributes.description` | string | existing value | The new description for the project. It must be no more than 256 characters long. | | `data.attributes.auto-destroy-activity-duration`| string | none | Specifies how long each workspace in the project should wait before automatically destroying its infrastructure by default. You can specify a duration up to four digits that is greater than `0` followed by either a `d` for days or `h` hours. For example, to queue destroy runs after fourteen days of inactivity set `auto-destroy-activity-duration: "14d"`. When you update this value, all workspaces in the project receive the new value unless you previously configured an override. Refer to [Automatically destroy inactive workspaces](/terraform/cloud-docs/projects/managing#automatically-destroy-inactive-workspaces) for additional information. | | `data.relationships.tag-bindings.data` | list of objects | none | Specifies a list of tags to bind to the project. Workspaces inherit the tags bound to their project. | | `data.relationships.tag-bindings.data.type` | string | none | Must be `tag-bindings` for each object in the list. | | `data.relationships.tag-bindings.data.attributes.key` | string | none | Specifies the tag key for each object in the list. | | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
-0.003000193042680621,
0.04174269363284111,
0.014453587122261524,
0.046984944492578506,
-0.018880531191825867,
-0.0272704865783453,
0.0006353547796607018,
-0.09231927245855331,
0.0056314910762012005,
0.0683901384472847,
0.00708115566521883,
-0.0497932992875576,
0.03888970986008644,
-0.0092... | -0.026179 |
to bind to the project. Workspaces inherit the tags bound to their project. | | `data.relationships.tag-bindings.data.type` | string | none | Must be `tag-bindings` for each object in the list. | | `data.relationships.tag-bindings.data.attributes.key` | string | none | Specifies the tag key for each object in the list. | | `data.relationships.tag-bindings.data.attributes.value` | string | none | Specifies the tag value for each object in the list. | | `data.attributes.default-execution-mode` | boolean | `remote` | Specifies which [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) to use by default. Valid values are `remote`, `local`, and `agent`. | | `data.attributes.default-agent-pool` | string | (previous value) | Required when `default-execution-mode` is set to `agent`. The ID of the agent pool belonging to the project. Do \_not\_ specify this value if you set `execution-mode` to `remote` or `local`. | | `data.attributes.setting-overwrites` | object | | The keys in this object are attributes that have project-level defaults. Each attribute key stores a boolean value which is `false` by default. To overwrite the default inherited value, set an attribute's value to `true`. For example, to unset `execution-mode` as the project-level default, you set `setting-overwrites.execution-mode = true`. | ### Sample Payload ```json { "data": { "attributes": { "name": "Infrastructure Project", "default-execution-mode": "remote", "setting-overwrites": { "execution-mode": false } }, "type": "projects", "relationships": { "default-agent-pool": { "data": null }, "tag-bindings": { "data": [ { "type": "tag-bindings", "attributes": { "key": "environment", "value": "staging" } } ] } } } } ``` ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/projects/prj-WsVcWRr7SfxRci1v ``` ### Sample Response ```json { "data": { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects", "attributes": { "name": "Infrastructure Project", "description": null, "workspace-count": 4, "team-count": 2, "default-execution-mode": "remote", "permissions": { "can-update": true, "can-destroy": true, "can-create-workspace": true }, "setting-overwrites": { "execution-mode": false } }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "default-agent-pool": { "data": null }, "tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/tag-bindings" } }, "effective-tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/effective-tag-bindings" } } }, "links": { "self": "/api/v2/projects/prj-WsVcWRr7SfxRci1v" } } } ``` ## List projects This endpoint lists projects in the organization. `GET /organizations/:organization\_name/projects` | Parameter | Description | |----------------------|-------------------------------------------------------| | `:organization\_name` | The name of the organization to list the projects of. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | |-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 projects per page. | | `q` | \*\*Optional.\*\* A search query string. This query searches projects by name. This search is case-insensitive. If both `q` and `filter[names]` are specified, `filter[names]` will be used. | | `filter[names]` | \*\*Optional.\*\* If specified, returns the project with the matching name. This filter is case-insensitive. If multiple comma separated values are specified, projects matching any of the names are returned. | | `filter[permissions][create-workspace]` | \*\*Optional.\*\* If present, returns a list of projects that the authenticated user can create workspaces in. | | `filter[permissions][move-stack]` | \*\*Optional.\*\* If present, returns a list of projects that the authenticated user can move Stacks between. Only available in HCP Terraform. | | `filter[permissions][update]` | \*\*Optional.\*\* If present, returns a list of projects that the authenticated user can update. | | `filter[tagged][i][key]` | \*\*Optional.\*\* If specified, restricts results to projects that are tagged with the provided key. Use a value of `"0"` for `i` if you are only using a single filter. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
-0.022887330502271652,
0.004654678516089916,
-0.014021317474544048,
0.03271086513996124,
-0.042825374752283096,
-0.023811228573322296,
0.006191652733832598,
-0.07295557856559753,
0.029837755486369133,
0.06758289039134979,
-0.013583123683929443,
-0.07260561734437943,
0.07600339502096176,
0.... | -0.040726 |
| `filter[permissions][update]` | \*\*Optional.\*\* If present, returns a list of projects that the authenticated user can update. | | `filter[tagged][i][key]` | \*\*Optional.\*\* If specified, restricts results to projects that are tagged with the provided key. Use a value of `"0"` for `i` if you are only using a single filter. For multiple tag filters, use an incrementing integer value for each filter. HCP Terraform combines multiple tag filters with a logical `AND` when filtering results. | | `filter[tagged][i][value]` | \*\*Optional.\*\* If specified, restricts results to projects that are tagged with the provided value. This is useful when combined with a `key` filter for more specificity. Use a value of `"0"` for `i` if you are only using a single filter. For multiple tag filters, use an incrementing integer value for each filter. HCP Terraform combines multiple tag filters with a logical `AND` when filtering results. | | `sort` | \*\*Optional.\*\* Allows sorting the organization's projects by `"name"`. Prepending a hyphen to the sort parameter reverses the order. For example, `"-name"` sorts by name in reverse alphabetical order. If omitted, the default sort order is arbitrary but stable. | ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/organizations/my-organization/projects ``` ### Sample Response ```json { "data": [ { "id": "prj-W6k9K23oSXRHGpj3", "type": "projects", "attributes": { "name": "Default Project", "description": null, "workspace-count": 2, "team-count": 1, "default-execution-mode": "remote", "setting-overwrites": { "execution-mode": false }, "permissions": { "can-update": true, "can-destroy": true, "can-create-workspace": true } }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "default-agent-pool": { "data": null }, "tag-bindings": { "links": { "related": "/api/v2/projects/prj-W6k9K23oSXRHGpj3/tag-bindings" } }, "effective-tag-bindings": { "links": { "related": "/api/v2/projects/prj-W6k9K23oSXRHGpj3/effective-tag-bindings" } } }, "links": { "self": "/api/v2/projects/prj-W6k9K23oSXRHGpj3" } }, { "id": "prj-YoriCxAawTMDLswn", "type": "projects", "attributes": { "name": "Infrastructure Project", "description": null, "workspace-count": 4, "team-count": 2, "permissions": { "can-update": true, "can-destroy": true, "can-create-workspace": true } }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "tag-bindings": { "links": { "related": "/api/v2/projects/prj-YoriCxAawTMDLswn/tag-bindings" } }, "effective-tag-bindings": { "links": { "related": "/api/v2/projects/prj-YoriCxAawTMDLswn/effective-tag-bindings" } } }, "links": { "self": "/api/v2/projects/prj-YoriCxAawTMDLswn" } } ], "links": { "self": "https://app.terraform.io/api/v2/organizations/my-organization/projects?page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "https://app.terraform.io/api/v2/organizations/my-organization/projects?page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "https://app.terraform.io/api/v2/organizations/my-organization/projects?page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "status-counts": { "total": 2, "matching": 2 }, "pagination": { "current-page": 1, "page-size": 20, "prev-page": null, "next-page": null, "total-pages": 1, "total-count": 2 } } } ``` ## Show project `GET /projects/:project\_id` | Parameter | Description | |---------------|----------------| | `:project\_id` | The project ID | ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/projects/prj-WsVcWRr7SfxRci1v ``` ### Sample Response ```json { "data": { "id": "prj-WsVcWRr7SfxRci1v", "type": "projects", "attributes": { "name": "Infrastructure Project", "description": null, "workspace-count": 4, "team-count": 2, "default-execution-mode": "remote", "setting-overwrites": { "execution-mode": false }, "permissions": { "can-update": true, "can-destroy": true, "can-create-workspace": true }, "auto-destroy-activity-duration": "2d" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" }, "links": { "related": "/api/v2/organizations/my-organization" } }, "default-agent-pool": { "data": null }, "tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/tag-bindings" } }, "effective-tag-bindings": { "links": { "related": "/api/v2/projects/prj-WsVcWRr7SfxRci1v/effective-tag-bindings" } } }, "links": { "self": "/api/v2/projects/prj-WsVcWRr7SfxRci1v" } } } ``` ## Delete a project A project cannot be deleted if it contains Stacks or workspaces. `DELETE /projects/:project\_id` | Parameter | Description | |---------------|---------------------------------| | `:project\_id` | The ID of the project to delete | | Status | Response | Reason(s) | |---------|---------------------------|-------------------------------------------------------------------| | [204][] | No Content | Successfully deleted the project | | [403][] | [JSON API error object][] | Not authorized to perform a force delete on the project | | [404][] | [JSON API error | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
0.01084899716079235,
0.08903592824935913,
0.02000068873167038,
-0.0425596758723259,
0.029749367386102676,
-0.019260887056589127,
0.06445053964853287,
-0.11103588342666626,
-0.04345186799764633,
0.046319782733917236,
-0.020253736525774002,
-0.12784120440483093,
0.0930647924542427,
-0.004053... | -0.02412 |
of the project to delete | | Status | Response | Reason(s) | |---------|---------------------------|-------------------------------------------------------------------| | [204][] | No Content | Successfully deleted the project | | [403][] | [JSON API error object][] | Not authorized to perform a force delete on the project | | [404][] | [JSON API error object][] | Project not found, or user unauthorized to perform project delete | ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/projects/prj-WsVcWRr7SfxRci1v ``` ## List project tag bindings Call the following endpoints to list the tags bound to a project. - `GET /projects/:project\_id/tag-bindings`: Lists the set of tags associated with the project. Tags set on the project are inherited by its workspaces. | Parameter | Description | |---------------|----------------------- | | `:project\_id` | The ID of the project. | ### Sample request The following request returns all tags bound to a project with the ID `prj-WsVcWRr7SfxRci1v`. ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/projects/prj-WsVcWRr7SfxRci1v/tag-bindings ``` ### Sample response ```json { "data": [ { "type": "tag-bindings", "attributes": { "key": "added", "value": "new", "created-at": "2024-11-20T00:04:47.948Z" } }, { "type": "tag-bindings", "attributes": { "key": "aww", "value": "aww", "created-at": "2024-11-20T00:04:47.948Z" } } ] } ``` ## Add or update tag bindings on a project Use this endpoint to add key-value tag bindings to an existing resource or to update existing tag binding values on the resource. You cannot use this endpoint to remove tag bindings from the resource. This endpoint is useful for ensuring that a modification is additive. Tag bindings have the following constraints and behaviors: - A project can have up to 10 tags. - All workspaces within the project inherit its tag bindings. - Keys can have up to 128 characters. - Keys support all alphanumeric characters and the symbols `\_`, `.`, `=`, `+`, `-`, `@`, `:`. - Values can have up to 256 characters. - Values support all alphanumeric characters and the symbols `\_`, `.`, `=`, `+`, `-`, `@`, `:`. - You cannot use `hc:` and `hcp:` as key prefixes. `PATCH /projects/:project\_id/tag-bindings` | Parameter | Description | | -------------------| --------------------------------------------------------------------| | `:project\_id` | The ID of the project to update | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. It is important to note that for each data item, `type`, as well as `attributes.key` is required. | Key path | Type | Default | Description | | ------------------------- | ------ | ------- | ---------------------------------- | | `data[].type` | string | | Must be `"tag-bindings"`. | | `data[].attributes.key` | string | | The key of the tag to add or update. | | `data[].attributes.value` | string | | The name of the tag to add or update. | ### Sample Payload ```json { "data": [ { "type": "tag-bindings", "attributes": { "key": "costcenter", "value": "123" } }, { "type": "tag-bindings", "attributes": { "key": "bar", "value": "baz" } } ] } ``` ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/projects/prj-82d2281aa259ba09/tag-bindings ``` ### Sample Response Example status code 200 response after updating tag bindings: ```json { "data": [ { "id": "tb-e4a5847b2cf06559", "type": "tag-bindings", "attributes": { "key": "costcenter", "value": "123" } }, { "id": "tb-97ce954636f93a6c", "type": "tag-bindings", "attributes": { "key": "bar", "value": "baz" } } ] } ``` ## Move workspaces into a project This endpoint allows you to move one or more workspaces into a project. You must have permission to move workspaces on the destination project as well as any source project(s). | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
-0.0567186065018177,
0.06009320914745331,
-0.0619012713432312,
-0.03893490508198738,
0.04718087986111641,
-0.05379859358072281,
-0.006109327077865601,
-0.03831290826201439,
0.08714281767606735,
0.05418255552649498,
0.0479787178337574,
-0.06238185614347458,
0.020783111453056335,
0.045233957... | 0.098373 |
"tb-97ce954636f93a6c", "type": "tag-bindings", "attributes": { "key": "bar", "value": "baz" } } ] } ``` ## Move workspaces into a project This endpoint allows you to move one or more workspaces into a project. You must have permission to move workspaces on the destination project as well as any source project(s). If you are not authorized to move any of the workspaces in the request, or if any workspaces in the request are not found, then no workspaces will be moved. `POST /projects/:project\_id/relationships/workspaces` | Parameter | Description | |---------------|-----------------------------------| | `:project\_id` | The ID of the destination project | This POST endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | Description | |---------------|--------|---------|------------------------------------------------------------| | `data[].type` | string | | Must be `"workspaces"` | | `data[].id` | string | | The ids of workspaces to move into the destination project | | Status | Response | Reason(s) | |---------|---------------------------|----------------------------------------------------------------------------------------------------------| | [204][] | No Content | Successfully moved workspace(s) | | [403][] | [JSON API error object][] | Workspace(s) not found, or user is not authorized to move all workspaces out of their current project(s) | | [404][] | [JSON API error object][] | Project not found, or user unauthorized to move workspaces into project | ### Sample Payload ```json { "data": [ { "type": "workspaces", "id": "ws-AQEct2XFuH4HBsmS" } ] } ``` ### Sample Request ```shell-session $ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/projects/prj-zXm4y2BjeGPgHtkp/relationships/workspaces ``` ### Sample Error Response ```json { "errors": [ { "status": "403", "title": "forbidden", "detail": "Workspace(s) not found, or you are not authorized to move them: ws-AQEct2XFuH4HBmS" } ] } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/projects.mdx | main | terraform | [
-0.05857633054256439,
-0.05477200821042061,
-0.0639432817697525,
0.039080578833818436,
-0.016682498157024384,
0.0028880101162940264,
-0.007256736513227224,
-0.016403719782829285,
0.03241217881441116,
0.030137207359075546,
-0.019398914650082588,
-0.05391484126448631,
0.0360758975148201,
0.0... | -0.019053 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Policies API reference Policies are rules that HCP Terraform enforces on runs in workspaces. You can use policies to validate that the Terraform plan complies with security rules and best practices. HCP Terraform policy enforcement lets you use the policy-as-code frameworks Sentinel and Open Policy Agent (OPA) to apply policy checks to HCP Terraform workspaces. Refer to [Policy Enforcement](/terraform/cloud-docs/policy-enforcement) for more details. [Policy sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) are collections of policies that you can apply globally or to specific [projects](/terraform/cloud-docs/projects/manage) and workspaces, in your organization. For each run in the selected workspaces, HCP Terraform checks the Terraform plan against the policy set and displays the results in the UI. @include 'tfc-package-callouts/policies.mdx' This page documents the API endpoints to create, read, update, and delete policies in an organization. To manage policy sets, use the [Policy Sets API](/terraform/cloud-docs/api-docs/policy-sets). To manage the policy results, use the [Runs API](/terraform/cloud-docs/api-docs/run). ## Create a Policy `POST /organizations/:organization\_name/policies` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The organization to create the policy in. The organization must already exist in the system, and the token authenticating the API request must have permission to manage policies. (([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) | \[permissions-citation]: #intentionally-unused---keep-for-maintainers) This creates a new policy object for the organization, but does not upload the actual policy code. After creation, you must use the [Upload a Policy endpoint (below)](#upload-a-policy) with the new policy's upload path. (This endpoint's response body includes the upload path in its `links.upload` property.) | Status | Response | Reason | | ------- | ------------------------------------------ | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "policies"`) | Successfully created a policy | | [404][] | [JSON API error object][] | Organization not found, or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### 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 path | Type | Default | Description | | --------------------------------------- | -------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `data.type` | string | | Must be `"policies"`. | | `data.attributes.name` | string | | The name of the policy, which can include letters, numbers, `-`, and `\_`. You cannot modify this name after creation. | | `data.attributes.description` | string | `null` | Text describing the policy's purpose. This field supports Markdown and appears in the HCP Terraform UI. | | `data.attributes.kind` | string | `sentinel` | The policy-as-code framework for the policy. Valid values are `"sentinel"` and `"opa"`. | | `data.attributes.query` | string | | The OPA query to run. Only valid for OPA policies. | | `data.attributes.enforcement-level` | string | | The enforcement level of the policy. For Sentinel, valid values are `"hard-mandatory"`, `"soft-mandatory"`, and `"advisory"`. For OPA, Valid values are `"mandatory"`and `"advisory"`. Refer to [Managing Policies](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) for details. | | `data.attributes.enforce` | array\[object] | | \*\*DEPRECATED\*\* Use `enforcement-level` instead. An array of enforcement configurations that map policy file paths to their enforcement modes. Policies support a single file, so this array should consist of a single element. For Sentinel, if the path in the enforcement map does not match the Sentinel policy (`.sentinel`), then HCP Terraform uses the default `hard-mandatory` enforcement level. For OPA, the default enforcement level is `advisory`. | | `data.attributes.enforce[].path` | string | | \*\*DEPRECATED\*\* For Sentinel, | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policies.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
array should consist of a single element. For Sentinel, if the path in the enforcement map does not match the Sentinel policy (`.sentinel`), then HCP Terraform uses the default `hard-mandatory` enforcement level. For OPA, the default enforcement level is `advisory`. | | `data.attributes.enforce[].path` | string | | \*\*DEPRECATED\*\* For Sentinel, must be `.sentinel`, where `` has the same value as `data.attributes.name`. For OPA, must be `.rego`. | | `data.attributes.enforce[].mode` | string | | \*\*DEPRECATED\*\* Use `enforcement-level` instead. The enforcement level of the policy. For Sentinel, valid values are `"hard-mandatory"`, `"soft-mandatory"`, and `"advisory"`. For OPA, Valid values are `"mandatory"`and `"advisory"`. Refer to [Managing Policies](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) for details. | | `data.relationships.policy-sets.data[]` | array\[object] | `[]` | A list of resource identifier objects to define which policy sets include the new policy. These objects must contain `id` and `type` properties, and the `type` property must be `policy-sets`. For example,`{ "id": "polset-3yVQZvHzf5j3WRJ1","type": "policy-sets" }`. | ### Sample Payload (Sentinel) ```json { "data": { "attributes": { "enforcement-level": "hard-mandatory", "name": "my-example-policy", "description": "An example policy.", "kind": "sentinel" }, "relationships": { "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "type": "policies" } } ``` ### Sample Payload (OPA) -> \*\*Note\*\*: We have deprecated the `enforce` property in requests and responses but continue to provide it for backward compatibility. The below sample uses the deprecated `enforce` property. ```json { "data": { "attributes": { "enforce": [ { "path": "my-example-policy.rego", "mode": "advisory" } ], "name": "my-example-policy", "description": "An example policy.", "kind": "opa", "query": "terraform.main" }, "relationships": { "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "type": "policies" } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/policies ``` ### Sample Response (Sentinel) ```json { "data": { "id":"pol-u3S5p2Uwk21keu1s", "type":"policies", "attributes": { "name":"my-example-policy", "description":"An example policy.", "enforcement-level":"advisory", "enforce": [ { "path":"my-example-policy.sentinel", "mode":"advisory" } ], "policy-set-count": 1, "updated-at": null }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "links": { "self":"/api/v2/policies/pol-u3S5p2Uwk21keu1s", "upload":"/api/v2/policies/pol-u3S5p2Uwk21keu1s/upload" } } } ``` ### Sample Response (OPA) ```json { "data": { "id":"pol-u3S5p2Uwk21keu1s", "type":"policies", "attributes": { "name":"my-example-policy", "description":"An example policy.", "kind": "opa", "query": "terraform.main", "enforcement-level": "advisory", "enforce": [ { "path":"my-example-policy.rego", "mode":"advisory" } ], "policy-set-count": 1, "updated-at": null }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "links": { "self":"/api/v2/policies/pol-u3S5p2Uwk21keu1s", "upload":"/api/v2/policies/pol-u3S5p2Uwk21keu1s/upload" } } } ``` ## Show a Policy `GET /policies/:policy\_id` | Parameter | Description | | ------------ | --------------------------------------------------------------------------- | | `:policy\_id` | The ID of the policy to show. Refer to [List Policies](/terraform/cloud-docs/api-docs/policies#list-policies) for reference information about finding IDs. | | Status | Response | Reason | | ------- | ------------------------------------------ | ------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "policies"`) | The request was successful | | [404][] | [JSON API error object][] | Policy not found or user unauthorized to perform action | ### Sample Request ```shell curl --request GET \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/policies/pol-oXUppaX2ximkqp8w ``` ### Sample Response ```json { "data": { "id": "pol-oXUppaX2ximkqp8w", "type": "policies", "attributes": { "name": "my-example-policy", "description":"An example policy.", "kind": "sentinel", "enforcement-level": "soft-mandatory", "enforce": [ { "path": "my-example-policy.sentinel", "mode": "soft-mandatory" } ], "policy-set-count": 1, "updated-at": "2018-09-11T18:21:21.784Z" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "links": { "self": "/api/v2/policies/pol-oXUppaX2ximkqp8w", "upload": "/api/v2/policies/pol-oXUppaX2ximkqp8w/upload", "download": "/api/v2/policies/pol-oXUppaX2ximkqp8w/download" } } } ``` ## Upload a Policy | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policies.mdx | main | terraform | [
0.028143364936113358,
0.06619729846715927,
0.03949856013059616,
-0.01548552792519331,
0.009159074164927006,
-0.0318707637488842,
0.03258470445871353,
-0.04859704151749611,
-0.061751145869493484,
0.05501649156212807,
0.0046353149227797985,
-0.06665683537721634,
0.056499335914850235,
-0.0017... | 0.01462 |
"mode": "soft-mandatory" } ], "policy-set-count": 1, "updated-at": "2018-09-11T18:21:21.784Z" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, "policy-sets": { "data": [ { "id": "polset-3yVQZvHzf5j3WRJ1", "type": "policy-sets" } ] } }, "links": { "self": "/api/v2/policies/pol-oXUppaX2ximkqp8w", "upload": "/api/v2/policies/pol-oXUppaX2ximkqp8w/upload", "download": "/api/v2/policies/pol-oXUppaX2ximkqp8w/download" } } } ``` ## Upload a Policy `PUT /policies/:policy\_id/upload` | Parameter | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | | `:policy\_id` | The ID of the policy to upload code to. Refer to [List Policies](/terraform/cloud-docs/api-docs/policies#list-policies) for reference information about finding the policy ID. The ID also appears in the response when you create a policy. | This endpoint uploads code to an existing Sentinel or OPA policy. -> \*\*Note\*\*: This endpoint does not use JSON-API's conventions for HTTP headers and body serialization. -> \*\*Note\*\*: This endpoint limits the size of uploaded policies to 10MB. If a larger payload is uploaded, an HTTP 413 error will be returned, and the policy will not be saved. Consider refactoring policies into multiple smaller, more concise documents if you reach this limit. ### Request Body This PUT endpoint requires the text of a valid Sentinel or OPA policy with a `Content-Type` of `application/octet-stream`. - Refer to [Defining Sentinel Policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) for details about writing Sentinel code. - Refer to [Defining OPA Policies](/terraform/cloud-docs/policy-enforcement/opa) for details about writing OPA code. ### Sample Payload ```plain main = rule { true } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/octet-stream" \ --request PUT \ --data-binary @payload.file \ https://app.terraform.io/api/v2/policies/pol-u3S5p2Uwk21keu1s/upload ``` ## Update a Policy `PATCH /policies/:policy\_id` | Parameter | Description | | ------------ | ----------------------------------------------------------------------------- | | `:policy\_id` | The ID of the policy to update. Refer to [List Policies](/terraform/cloud-docs/api-docs/policies#list-policies) for reference information about finding IDs. | This endpoint can update the enforcement mode of an existing policy. To update the policy code itself, use the upload endpoint. | Status | Response | Reason | | ------- | ------------------------------------------ | -------------------------------------------------------------- | | [200][] | [JSON API document][] (`type: "policies"`) | Successfully updated the policy | | [404][] | [JSON API error object][] | Policy not found, or user unauthorized to perform action | | [422][] | [JSON API error object][] | Malformed request body (missing attributes, wrong types, etc.) | ### Request Body This PATCH endpoint requires a JSON object with the following properties as a request payload. Properties without a default value are required. | Key path | Type | Default | Description | | ----------------------------------- | -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `data.type` | string | | Must be `"policies"`. | | `data.attributes.description` | string | `null` | Text describing the policy's purpose. This field supports Markdown and appears in the HCP Terraform UI. | | `data.attributes.query` | string | | The OPA query to run. This is only valid for OPA policies. | | `data.attributes.enforcement-level` | string | | The enforcement level of the policy. For Sentinel, valid values are `"hard-mandatory"`, `"soft-mandatory"`, and `"advisory"`. For OPA, Valid values are `"mandatory"`and `"advisory"`. Refer to [Managing Policies](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) for details. | | `data.attributes.enforce` | array\[object] | | \*\*DEPRECATED\*\* Use `enforcement-level` instead. An array of enforcement configurations that map policy file paths to their enforcement modes. Policies support a single file, so this array should consist of a single element. For Sentinel, if the path in the enforcement map does not match the Sentinel policy (`.sentinel`), then HCP Terraform uses the default `hard-mandatory` enforcement level. For OPA, the default enforcement level is `advisory`. | | `data.attributes.enforce[].path` | string | | \*\*DEPRECATED\*\* For Sentinel, must be `.sentinel`, where `` has the same value as `data.attributes.name`. For OPA, must be `.rego`. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policies.mdx | main | terraform | [
-0.05553293600678444,
0.09331317991018295,
-0.010371178388595581,
0.025567518547177315,
0.02866450324654579,
-0.008809183724224567,
-0.007761472836136818,
-0.020820166915655136,
0.009836798533797264,
0.0306710097938776,
0.02025325782597065,
-0.029282933101058006,
0.022289516404271126,
0.05... | 0.045157 |
does not match the Sentinel policy (`.sentinel`), then HCP Terraform uses the default `hard-mandatory` enforcement level. For OPA, the default enforcement level is `advisory`. | | `data.attributes.enforce[].path` | string | | \*\*DEPRECATED\*\* For Sentinel, must be `.sentinel`, where `` has the same value as `data.attributes.name`. For OPA, must be `.rego`. | | `data.attributes.enforce[].mode` | string | | \*\*DEPRECATED\*\* Use `enforcement-level` instead. The enforcement level of the policy. For Sentinel, valid values are `"hard-mandatory"`, `"soft-mandatory"`, and `"advisory"`. For OPA, Valid values are `"mandatory"`and `"advisory"`. Refer to [Managing Policies](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) for details. | ### Sample Payload ```json { "data": { "attributes": { "enforcement-level": "soft-mandatory" }, "type":"policies" } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://app.terraform.io/api/v2/policies/pol-u3S5p2Uwk21keu1s ``` ### Sample Response ```json { "data": { "id":"pol-u3S5p2Uwk21keu1s", "type":"policies", "attributes": { "name":"my-example-policy", "description":"An example policy.", "kind": "sentinel", "enforcement-level": "soft-mandatory", "enforce": [ { "path":"my-example-policy.sentinel", "mode":"soft-mandatory" } ], "policy-set-count": 0, "updated-at":"2017-10-10T20:58:04.621Z" }, "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, }, "links": { "self":"/api/v2/policies/pol-u3S5p2Uwk21keu1s", "upload":"/api/v2/policies/pol-u3S5p2Uwk21keu1s/upload", "download":"/api/v2/policies/pol-u3S5p2Uwk21keu1s/download" } } } ``` ## List Policies `GET /organizations/:organization\_name/policies` | Parameter | Description | | -------------------- | -------------------------------------- | | `:organization\_name` | The organization to list policies for. | | Status | Response | Reason | | ------- | ---------------------------------------------------- | -------------------------------------------------------------- | | [200][] | Array of [JSON API document][]s (`type: "policies"`) | Success | | [404][] | [JSON API error object][] | Organization not found, or user unauthorized to perform action | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters); remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | --------------------------------------------------------------------------------------------------------------------------------- | | `page[number]` | \*\*Optional.\*\* If omitted, the endpoint will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 policies per page. | | `search[name]` | \*\*Optional.\*\* Allows searching the organization's policies by name. | | `filter[kind]` | \*\*Optional.\*\* If specified, restricts results to those with the matching policy kind value. Valid values are `sentinel` and `opa` | | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ https://app.terraform.io/api/v2/organizations/my-organization/policies ``` ### Sample Response ```json { "data": [ { "attributes": { "enforcement-level": "advisory", "enforce": [ { "mode": "advisory", "path": "my-example-policy.sentinel" } ], "name": "my-example-policy", "description": "An example policy.", "policy-set-count": 0, "updated-at": "2017-10-10T20:52:13.898Z", "kind": "sentinel" }, "id": "pol-u3S5p2Uwk21keu1s", "relationships": { "organization": { "data": { "id": "my-organization", "type": "organizations" } }, }, "links": { "download": "/api/v2/policies/pol-u3S5p2Uwk21keu1s/download", "self": "/api/v2/policies/pol-u3S5p2Uwk21keu1s", "upload": "/api/v2/policies/pol-u3S5p2Uwk21keu1s/upload" }, "type": "policies" }, { "id":"pol-vM2rBfj7V2Faq8By", "type":"policies", "attributes":{ "name":"policy1", "description":null, "enforcement-level": "advisory", "enforce":[ { "path":"policy1.rego", "mode":"advisory" } ], "policy-set-count":1, "updated-at":"2022-09-13T04:57:43.516Z", "kind":"opa", "query":"data.terraform.rules.policy1.rule" }, "relationships":{ "organization":{ "data":{ "id":"hashicorp", "type":"organizations" } }, "policy-sets":{ "data":[ { "id":"polset-FYu3k5WY5eecwwdt", "type":"policy-sets" } ] } }, "links":{ "self":"/api/v2/policies/pol-vM2rBfj7V2Faq8By", "upload":"/api/v2/policies/pol-vM2rBfj7V2Faq8By/upload", "download":"/api/v2/policies/pol-vM2rBfj7V2Faq8By/download" } } ] } ``` ## Delete a Policy `DELETE /policies/:policy\_id` | Parameter | Description | | ------------ | ----------------------------------------------------------------------------- | | `:policy\_id` | The ID of the policy to delete. Refer to [List Policies](/terraform/cloud-docs/api-docs/policies#list-policies) for reference information about finding IDs. | | Status | Response | Reason | | ------- | ------------------------- | -------------------------------------------------------- | | [204][] | No Content | Successfully deleted the policy | | [404][] | [JSON API error object][] | Policy not found, or user unauthorized to perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/policies/pl-u3S5p2Uwk21keu1s ``` ## Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policies.mdx | main | terraform | [
-0.01567044109106064,
0.05052826553583145,
0.07525745779275894,
-0.014433881267905235,
0.021306486800312996,
-0.052676789462566376,
0.004352835472673178,
-0.030197549611330032,
-0.02896924503147602,
0.0688558891415596,
0.005736514925956726,
-0.07267460972070694,
0.0337551087141037,
0.03003... | -0.002573 |
perform action | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/policies/pl-u3S5p2Uwk21keu1s ``` ## Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | Resource Name | Description | | ------------- | ------------------------------------------------------ | | `policy\_sets` | Policy sets that any returned policies are members of. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/policies.mdx | main | terraform | [
-0.04062870517373085,
0.06877191364765167,
0.03226441144943237,
0.016349824145436287,
0.030299371108412743,
-0.013410689309239388,
0.007842378690838814,
-0.08177125453948975,
0.032951414585113525,
0.054525263607501984,
-0.03658659756183624,
-0.08055666089057922,
0.06994315981864929,
-0.004... | 0.010525 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects [speculative plans]: /terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans @include 'beta/explorer.mdx' # Explorer API reference Explorer allows you to query your HCP Terraform data across workspaces in an organization. You can select from a variety of available views and supply optional sort and filter parameters to present your data in the format that best suits your needs. Queries are scoped to the organization level. You must have owner permissions in the organization, or read access to workspaces and projects. ## Execute a query `GET /organizations/:organization\_name/explorer` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. The organization must already exist and you must have permissions to read the organization's workspaces and projects. | -> \*\*Note:\*\* Explorer is restricted to the owners team, teams with the "Read all workspaces" permission, teams with the "Read all projects" permission, and the [organization API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). Explorer queries will time out after 60 seconds. If the desired query is timing out, try a simpler query that uses less filters. Requests to the explorer are subject to [rate limiting](/terraform/cloud-docs/api-docs#rate-limiting). Explorer will return a 429 status code when rate limiting is active for the authenticated context. Data presented by the explorer is eventually consistent. Query results typically contain data that represents the current state of the system, but in some cases a small delay may be necessary before querying for data that has recently been updated. ### Query parameters This GET endpoint requires a query string that supports the following properties. | Parameter | Description | | -------------- | ----------------------------------------------------------------------------- | | `type` | \*\*Required.\*\* Must be one of the following available views: `workspaces`, `tf\_versions`, `providers`, or `modules`. See the [View Types](#view-types) section for more information about each. | | `sort` | Optionally sort the returned data by the specified field name. The field name must use snake case and exist within the supplied view type. The field name supplied can be prefixed with a hyphen (`-`) to perform a descending sort. | | `filter` | Optionally specify one or more filters to limit the data returned. See [Filtering](#filtering) for more information. | | `fields` | Optionally limit the data returned only to the specified fields. The field names supplied must use snake case and be submitted in comma-separated format. If omitted, all available fields will be returned for the requested view type. | | `page[number]` | Optional. If omitted, the endpoint will return the first page. | | `page[size]` | Optional. If omitted, the endpoint will use a default page size. | ### View Types Explorer queries each require a view, specified by the `type` query string parameter. There are several contextual views available for querying: | Type | Description | | ------------- | ----------------------------------------------------------------------------- | | `workspaces` | Information about the workspaces in the target organization and any current runs associated with them. Each row returned represents a single workspace. See [View Type: workspaces](#view-type-workspaces) for available fields. | | `tf\_versions` | Information about the Terraform versions in use across this organization. Each row returned represents a Terraform version in use. See [View Type: tf\_versions](#view-type-tf\_versions) for available fields. | | `providers` | Information about the Terraform providers in use across the target organization. Each row returned represents a Terraform provider in use. See [View Type: providers](#view-type-providers) for available fields. | | `modules` | Information about the Terraform modules in use across the target organization. Each | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
for available fields. | | `providers` | Information about the Terraform providers in use across the target organization. Each row returned represents a Terraform provider in use. See [View Type: providers](#view-type-providers) for available fields. | | `modules` | Information about the Terraform modules in use across the target organization. Each row returned represents a Terraform module in use. See [View Type: modules](#view-type-modules) for available fields. | The fields returned by a given query are specific to the view type used. The fields available for each view type are detailed below: #### View Type: `workspaces` | Field | Type | Description | | --------------------------------- | ---------- | ----------------------------------------------------------------------------- | | `all\_checks\_succeeded` | `boolean` | True if checks have succeeded for the workspace, false otherwise. | | `current\_rum\_count` | `number` | The number of [resources under management](/terraform/cloud-docs/overview/estimate-hcp-terraform-cost#what-is-a-managed-resource) (RUM). | | `checks\_errored` | `number` | The number of checks that errored without completing. | | `checks\_failed` | `number` | The number of checks that completed and failed. | | `checks\_passed` | `number` | The number of checks that completed and passed. | | `checks\_unknown` | `number` | The number of checks that could not be assessed. | | `current\_run\_applied\_at` | `datetime` | Represents the time that this workspace's current run was applied. | | `current\_run\_external\_id` | `string` | The external ID of this workspace's current run. | | `current\_run\_status` | `string` | The status of this workspace's current run. | | `drifted` | `boolean` | True if drift has been detected for the workspace, false otherwise. | | `external\_id` | `string` | The external ID of this workspace. | | `module\_count` | `number` | The number of distinct modules used by this workspace. | | `modules` | `string` | A comma separated list of modules used by this workspace. | | `organization\_name` | `string` | The name of the organization this workspace belongs to. | | `project\_external\_id` | `string` | The external ID of the project this workspace belongs to. | | `project\_name` | `string` | The name of the project this workspace belongs to. | `provider\_count` | `number` | The number of distinct providers used in this workspace. | | `providers` | `string` | A comma separated list of providers used in this workspace. | | `resources\_drifted` | `number` | The count of resources that drift was detected for. | | `resources\_undrifted` | `number` | The count of resources that drift was not detected for. | | `state\_version\_terraform\_version` | `string` | The Terraform version used to create the current run's state file. | | `tags` | `string` | A comma separated list of tags (keys and key:value pairs) applied to this workspace. | | `vcs\_repo\_identifier` | `string` | The name of the repository configured for this workspace, if available. | | `workspace\_created\_at` | `datetime` | The time this workspace was created. | | `workspace\_name` | `string` | The name of this workspace. | | `workspace\_terraform\_version` | `string` | The Terraform version currently configured for this workspace. | | `workspace\_updated\_at` | `datetime` | The time this workspace was last updated. | #### View Type: `tf\_versions` | Field | Type | Description | | ------------------ | -------- | ------------------------------------------------------------------ | | `version` | `string` | The semantic version string for this Terraform version. | | `workspace\_count` | `number` | The number of workspaces using this terraform version. | | `workspaces` | `string` | A comma-separated list of workspaces using this terraform version. | #### View Type: `providers` | Field | Type | Description | | ------------------| -------- | --------------------------------------------------------- | | `name` | `string` | The name of this provider. | | `source` | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.0014631893718615174,
0.008168189786374569,
-0.03212546184659004,
0.07193364948034286,
0.03012586571276188,
0.0051345182582736015,
0.008018869906663895,
-0.08626221120357513,
0.010259152390062809,
0.004678433761000633,
-0.011707590892910957,
-0.09033256024122238,
0.012623773887753487,
0.... | 0.019704 |
this terraform version. | | `workspaces` | `string` | A comma-separated list of workspaces using this terraform version. | #### View Type: `providers` | Field | Type | Description | | ------------------| -------- | --------------------------------------------------------- | | `name` | `string` | The name of this provider. | | `source` | `string` | The source of this provider. | | `version` | `string` | The semantic version string for this provider. | | `workspace\_count` | `number` | The number of workspaces using this provider. | | `workspaces` | `string` | A comma-separated list of workspaces using this provider. | #### View Type: `modules` | Field | Type | Description | | ------------------| -------- | ------------------------------------------------------- | | `name` | `string` | The name of this module. | | `source` | `string` | The source of this module. | | `version` | `string` | The semantic version string for this module. | | `workspace\_count` | `number` | The number of workspaces using this module version. | | `workspaces` | `string` | A comma-separated list of workspaces using this module version. | ### Filtering The explorer can present filtered data from any view type using a variety of operators. Filter strings begin with the reserved string `filter`, and are passed as URL query string parameters using key-value pairs. The parameter key contains the filter's target field and operator, and the parameter value contains the filter value to be used during the query. Multiple filters can be used in a query by providing multiple filter query string parameters separated with `&`. When multiple filters are used, a logical AND is used to evaluate the results. Each filter string must use the following format: ``` filter[][][][FIELD\_VALUE\_INDEX]= ``` \*\*Filter string sub-parameters\*\* - \*\*FILTER\_INDEX\*\*: The index of the filter. Each filter requires a unique index. The first filter should use a `0` and each additional filter should use an index that is the previous filter's index incremented by 1. - \*\*FIELD\_NAME\*\*: The name of the field to apply the filter to. The field must be a valid field for the view type being queried. See [View Types](#view-types) for a list of fields available for each type. - \*\*FIELD\_OPERATOR\*\*: The operator to use when filtering. Must be supported by the field type being filtered. See [Filter Operators](#filter-operators) for the available operators and their supported field types. - \*\*FIELD\_VALUE\_INDEX\*\*: Must be `0`. This sub-parameter is reserved for future use. - \*\*FILTER\_VALUE\*\*: The filter value used by the filter during the query. Once the desired filter strings have been added to a request URI, they should be percent-encoded along with the rest of the query string parameters. #### Sample Filter Strings \*\*View Type: `workspace`\*\* \_Show workspaces that contain `test` in their name:\_ ``` filter[0][workspace\_name][contains][0]=test ``` \_After encoding:\_ ``` filter%5B0%5D%5Bworkspace\_name%5D%5Bcontains%5D%5B0%5D=test ``` \*\*View Type: `modules`\*\* \_Show modules that contain `aws` in their name and version string equal to `1.1`\_ ``` filter[0][name][contains][0]=aws&filter[0][version][is][0]=1.1 ``` \_After encoding:\_ ``` filter%5B0%5D%5Bname%5D%5Bcontains%5D%5B0%5D=aws&filter%5B0%5D%5Bversion%5D%5Bis%5D%5B0%5D=1.1 ``` #### Filter Operators | Operator | Supported Field Types | Description | | ------------------ | ----------------------------- | ----------- | | `is` | `boolean`, `number`, `string` | Filters data to rows where the field value is equivalent to the filter value. | | `is\_not` | `number`, `string` | Filters data to rows where the field value is different from the filter value. | | `contains` | `string` | Filters data to rows where the field value contains the filter value as a sub-string. | | `does not contain` | `string` | Filters data to rows where the field value does not contain the filter value as a sub-string. | | `is\_empty` | `boolean`, `number`, `string` | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.040137067437171936,
-0.020627789199352264,
0.02208925597369671,
0.03501036763191223,
0.01274043321609497,
-0.010131544433534145,
0.02737954445183277,
-0.08229633420705795,
0.005591466091573238,
0.04638420790433884,
0.0017957153031602502,
-0.09320079535245895,
0.007859435863792896,
0.004... | 0.029207 |
`string` | Filters data to rows where the field value contains the filter value as a sub-string. | | `does not contain` | `string` | Filters data to rows where the field value does not contain the filter value as a sub-string. | | `is\_empty` | `boolean`, `number`, `string` | Filters data to rows where the field does not contain a value. | | `is\_not\_empty` | `boolean`, `number`, `string` | Filters data to rows where the field contains any value. | | `gt` | `number` | Filters data to rows where the field value is greater than the filter value. | | `lt` | `number` | Filters data to rows where the field value is less than the filter value. | | `gteq` | `number` | Filters data to rows where the field value is greater than or equal to the filter value. | | `lteq` | `number` | Filters data to rows where the field value is less than or equal to the filter value. | | `is\_before` | `datetime` | Filters data to rows where the field value is earlier than the filter value. ISO 8601 formatted timestamps are required for filter values. If no time zone offset is provided, the filter value will be interpreted as UTC. | | `is\_after` | `datetime` | Filters data to rows where the field value is earlier than the filter value. ISO 8601 formatted timestamps are required for filter values. If no time zone offset is provided, the filter value will be interpreted as UTC. | ### Pagination This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. ### Sample requests \*\*View Type: `workspaces`\*\* \_Show data for all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=workspaces' ``` \_Show data for all workspaces with `test` in their name\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=workspaces&filter%5B0%5D%5Bworkspace\_name%5D%5Bcontains%5D%5B0%5D=test' ``` \_Show data for all workspaces with the tag key `billing` having value `tier2`\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=workspaces&filter%5B0%5D%5Btags%5D%5Bcontains%5D%5B0%5D=billing:tier2' ``` \*\*View Type: `modules`\*\* \_Show modules used across all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=modules' ``` \_Show public modules only\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=modules&filter%5B0%5D%5Bregistry\_type%5D%5Bis%5D%5B0%5D=public' ``` \*\*View Type: `provider`\*\* \_Show providers used across all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=providers' ``` \_Show most used providers across all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=providers&sort=-workspace\_count' ``` \*\*View Type: `tf\_versions`\*\* \_Show Terraform versions used across all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=tf\_versions' ``` \_Show all Terraform versions used in more than 10 workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer?type=tf\_versions&filter%5B0%5D%5Bworkspace\_count%5D%5Bgt%5D%5B0%5D=10' ``` ### Sample response \_Show data for all workspaces\_ ```json { "data": [ { "attributes": { "all-checks-succeeded": true, "current\_rum\_count": 0, "checks-errored": 0, "checks-failed": 0, "checks-passed": 0, "checks-unknown": 0, "current-run-applied-at": null, "current-run-external-id": "run-rdoEKh2Gy3K6SbCZ", "current-run-status": "planned\_and\_finished", "drifted": false, "external-id": "ws-j2sAeWRxou1b5HYf", "module-count": 0, "modules": null, "organization-name": "acme-corp", "project-external-id": "prj-V61QLE8tvs4NvVZG", "project-name": "Default Project", "provider-count": 0, "providers": null, "resources-drifted": 0, "resources-undrifted": 0, "state-version-terraform-version": "1.5.7", "tags": "", "vcs-repo-identifier": null, "workspace-created-at": "2023-10-17T21:56:45.570+00:00", "workspace-name": "payments-service", "workspace-terraform-version": "1.5.7", "workspace-updated-at": "2023-12-08T19:58:15.513+00:00" }, "id": "ws-j2sAWeRxuo1b5HYf", "type": "visibility-workspace" }, { "attributes": { "all-checks-succeeded": true, "current\_rum\_count": 0, "checks-errored": 0, "checks-failed": 0, "checks-passed": 0, "checks-unknown": 0, "current-run-applied-at": "2023-08-18T16:24:59.000+00:00", "current-run-external-id": "run-9MmJaoQTvDCh5wUa", "current-run-status": "applied", "drifted": true, "external-id": "ws-igUVNQSYVXRkhYuo", "module-count": 0, "modules": null, "organization-name": "acme-corp", "project-external-id": "prj-uU2xNqGeG86U9WgT", "project-name": "web", "provider-count": 0, "providers": null, "resources-drifted": 3, "resources-undrifted": 3, "state-version-terraform-version": "1.4.5", "tags": "billing:tier1, project\_customer", "vcs-repo-identifier": "acmecorp/api", "workspace-created-at": "2023-04-25T17:09:14.960+00:00", "workspace-name": "api-service", "workspace-terraform-version": "1.4.5", "workspace-updated-at": "2023-12-08T20:43:16.779+00:00" }, "id": "ws-igUNVQSYXVRkhYuo", "type": "visibility-workspace" } ], "links": { "self": | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
0.020255710929632187,
0.06004256010055542,
0.013838631100952625,
0.006985704880207777,
-0.054505523294210434,
0.012793036177754402,
0.05048130825161934,
0.02213176153600216,
-0.026775186881422997,
-0.021224619820713997,
0.001419155509211123,
-0.03232526779174805,
0.07049588114023209,
-0.04... | -0.036052 |
"run-9MmJaoQTvDCh5wUa", "current-run-status": "applied", "drifted": true, "external-id": "ws-igUVNQSYVXRkhYuo", "module-count": 0, "modules": null, "organization-name": "acme-corp", "project-external-id": "prj-uU2xNqGeG86U9WgT", "project-name": "web", "provider-count": 0, "providers": null, "resources-drifted": 3, "resources-undrifted": 3, "state-version-terraform-version": "1.4.5", "tags": "billing:tier1, project\_customer", "vcs-repo-identifier": "acmecorp/api", "workspace-created-at": "2023-04-25T17:09:14.960+00:00", "workspace-name": "api-service", "workspace-terraform-version": "1.4.5", "workspace-updated-at": "2023-12-08T20:43:16.779+00:00" }, "id": "ws-igUNVQSYXVRkhYuo", "type": "visibility-workspace" } ], "links": { "self": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "first": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "last": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "prev": null, "next": null }, "meta": { "pagination": { "current-page": 1, "page-size": 20, "next-page": null, "prev-page": null, "total-pages": 1, "total-count": 2 } } } ``` ## Export data as CSV `GET /organizations/:organization\_name/explorer/export/csv` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. The organization must already exist in the system, and the user must have permissions to read the workspaces and projects within it. | This endpoint can be used to download a full, unpaged export of the query results in CSV format (with the filter, sort, and field selections applied). Explorer queries will time out after 60 seconds. If the desired query is timing out, try a simpler query that uses less filters. Requests to the explorer are subject to [rate limiting](/terraform/cloud-docs/api-docs#rate-limiting). Explorer will return a 429 status code when rate limiting is active for the authenticated context. Data presented by the explorer is eventually consistent. Query results typically contain data that represents the current state of the system, but in some cases a small delay may be necessary before querying for data that has recently been updated. ### Query parameters This GET endpoint supports the same query string parameters as the Explorer [Query endpoint](#execute-a-query). ### Sample requests \*\*View Type: `workspaces`\*\* \_Show data for all workspaces\_ ```shell curl \ --header "Authorization: Bearer $TOKEN" \ https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/export/csv?type=workspaces ``` ### Sample response \_Show data for all workspaces\_ ```csv all\_checks\_succeeded,current\_rum\_count,checks\_errored,checks\_failed,checks\_passed,checks\_unknown,current\_run\_applied\_at,current\_run\_external\_id,current\_run\_status,drifted,external\_id,module\_count,modules,organization\_name,project\_external\_id,project\_name,provider\_count,providers,resources\_drifted,resources\_undrifted,state\_version\_terraform\_version,vcs\_repo\_identifier,workspace\_created\_at,workspace\_name,workspace\_terraform\_version,workspace\_updated\_at "true","0","0","0","0","0","","run-rdoEKh2Gy3K6SbCZ","planned\_and\_finished","false","ws-j2sAeWRxou1b5HYf","0","","acme-corp","prj-V61QLE8tvs4NvVZG","Default Project","0","","0","0","1.5.7","","2023-10-17T21:56:45+00:00","payments-service","1.5.7","2023-12-13T15:48:16+00:00" "true","0","0","0","0","0","2023-08-18T16:24:59+00:00","run-9MmJaoQTvDCh5wUa","applied","true","ws-igUVNQSYVXRkhYuo","0","","acme-corp","prj-uU2xNqGeG86U9WgT","web","0","","3","3","1.4.5","acmecorp/api","2023-04-25T17:09:14+00:00","api-service","1.4.5","2023-12-13T15:29:03+00:00" ``` ## List saved views Use this endpoint to display all of the explorer's [saved views](/terraform/cloud-docs/workspaces/explorer#saved-views) in an organization. `GET /api/v2/organizations/:organization\_name/explorer/views` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request GET \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views' ``` ### Sample response ```json { "data": [{ "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["child"], }, { "field": "workspace\_name", "operator": "contains", "value": ["-"], }], "type": "workspaces" }, "query-type": "workspaces" } }] } ``` ## Create saved view Use this endpoint to create a [saved view](/terraform/cloud-docs/workspaces/explorer#saved-views) in the explorer. `POST /api/v2/organizations/:organization\_name/explorer/views` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | To create a saved view, provide the following data in your payload. | Key path | Type | Default | Description | |------------|------|---------|-------------| | `data.name` | string | | The name of the saved view. | | `data.query\_type` | string | | The primary type that the view is querying. Refer to [View Types](#view-types) for details. | | `data.query` | object | | A list of filters, fields, and sorting rules for the view. Refer to [Query parameters](#query-parameters) for full details. | | `data.query.filter` | array\[objects]| | A list of filters composed of fields, operators, and values. | | `data.query.filter.field` | string | | The field name to filter by. | | `data.query.filter.operator` | string | | The operator applied to field and value. | | `data.query.filter.value` | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.0843803882598877,
-0.050608836114406586,
-0.059058696031570435,
0.001909147365950048,
0.02588273026049137,
-0.040420301258563995,
-0.020836716517806053,
-0.021404791623353958,
0.0301651731133461,
0.09166332334280014,
0.028444362804293633,
-0.13492409884929657,
0.03656719624996185,
-0.00... | 0.075443 |
for full details. | | `data.query.filter` | array\[objects]| | A list of filters composed of fields, operators, and values. | | `data.query.filter.field` | string | | The field name to filter by. | | `data.query.filter.operator` | string | | The operator applied to field and value. | | `data.query.filter.value` | array\[strings] | | A list of values to filter by. | | `data.query.fields` | array\[strings] | | A list of fields to include in the view. | | `data.query.sort` | array\[strings] | | A list of fields to sort by. Prefix with `-` for descending sort. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request POST \ --data @payload.json \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views' ``` ### Sample response ```json { "data": { "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["child"], }, { "field": "workspace\_name", "operator": "contains", "value": ["-"], }], "type": "workspaces" }, "query-type": "workspaces" } } } ``` ## Show saved view Use this endpoint to display a specific saved view from the explorer. `GET /api/v2/organizations/:organization\_name/explorer/views/:view\_id` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | | `:view\_id` | The ID of the saved view to show. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request GET \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views/$VIEW\_ID` ``` ### Sample response ```json { "data": { "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["child"], }, { "field": "workspace\_name", "operator": "contains", "value": ["-"], }], "type": "workspaces" }, "query-type": "workspaces" } } } ``` ## Update a saved view Use this endpoint to update the data a saved view queries. `PATCH /api/v2/organizations/:organization\_name/explorer/views/:view\_id` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | | `:view\_id` | The external id of the saved view to update. | You must have the following fields in the payload for your request. | Key path | Type | Default | Description | |------------|------|---------|-------------| | `data.name` | string | | The name of the saved view. | | `data.query` | object | | A list of filters, fields, and sorting rules for the view. See [Query parameters](#query-parameters) for full details. | | `data.query.filter` | array\[objects]| | A list of filters composed of fields, operators, and values. See [Filtering](#filtering) for more information. | | `data.query.filter.field` | string | | The field name to filter by. | | `data.query.filter.operator` | string | | The operator applied to field and value. | | `data.query.filter.value` | array\[strings] | | A list of values to filter by. | | `data.query.fields` | array\[strings] | | A list of fields to include in the view. Refer to [execute a query](#execute-a-query) for a list of available parameters. | | `data.query.sort` | array\[strings] | | A list of fields to sort by. Prefix with `-` for descending sort. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request PATCH \ --data @payload.json \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/viewsi/$VIEW\_ID' ``` ### Sample response ```json { "data": { "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["candy"], }, { "field": "workspace\_name", "operator": "contains", "value": ["pumpkins"], }], "type": "workspaces" }, "query-type": "workspaces" } } } ``` ## Delete | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.002466326579451561,
0.10657664388418198,
0.022651946172118187,
0.04877056926488876,
0.00538641819730401,
-0.021998712792992592,
0.029997551813721657,
-0.03887506574392319,
0.02440343052148819,
0.0807732492685318,
-0.02756931073963642,
-0.03513889014720917,
0.0025662777479737997,
0.01845... | -0.009866 |
``` ### Sample response ```json { "data": { "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["candy"], }, { "field": "workspace\_name", "operator": "contains", "value": ["pumpkins"], }], "type": "workspaces" }, "query-type": "workspaces" } } } ``` ## Delete a saved view Use this endpoint to delete a saved view. `DELETE /api/v2/organizations/:organization\_name/explorer/views/:view\_id` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | | `:view\_id` | The ID of the saved view you want to delete. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request DELETE \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views/$VIEW\_ID` ``` ### Sample response ```json { "data": { "id": "sq-P9Yn6Ad6EiVMz77s", "type": "explorer-saved-queries", "attributes": { "name": "my saved query", "created-at": "2024-10-11T16:18:51.442Z", "query": { "filter": [{ "field": "workspace\_name", "operator": "contains", "value": ["candy"], }, { "field": "workspace\_name", "operator": "contains", "value": ["pumpkins"], }], "type": "workspaces" }, "query-type": "workspaces" } } } ``` ## Query a saved view Re-execute a saved view's query to retrieve current results. HCP Terraform and Terraform Enterprise do not save query results or query history. Returning to them re-runs the query and shows current results only. `GET /api/v2/organizations/:organization\_name/explorer/views/:view\_id/results` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | | `:view\_id` | The ID of the saved view to re-query. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request GET \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views/$VIEW\_ID/results` ``` ### Sample response ```json { "data": [ { "attributes": { "all-checks-succeeded": true, "current\_rum\_count": 0, "checks-errored": 0, "checks-failed": 0, "checks-passed": 0, "checks-unknown": 0, "current-run-applied-at": null, "current-run-external-id": "run-rdoEKh2Gy3K6SbCZ", "current-run-status": "planned\_and\_finished", "drifted": false, "external-id": "ws-j2sAeWRxou1b5HYf", "module-count": 0, "modules": null, "organization-name": "acme-corp", "project-external-id": "prj-V61QLE8tvs4NvVZG", "project-name": "Default Project", "provider-count": 0, "providers": null, "resources-drifted": 0, "resources-undrifted": 0, "state-version-terraform-version": "1.5.7", "vcs-repo-identifier": null, "workspace-created-at": "2023-10-17T21:56:45.570+00:00", "workspace-name": "candy distribution system", "workspace-terraform-version": "1.5.7", "workspace-updated-at": "2023-12-08T19:58:15.513+00:00" }, "id": "ws-j2sAWeRxuo1b5HYf", "type": "visibility-workspace" }, { "attributes": { "all-checks-succeeded": true, "current\_rum\_count": 0, "checks-errored": 0, "checks-failed": 0, "checks-passed": 0, "checks-unknown": 0, "current-run-applied-at": "2023-08-18T16:24:59.000+00:00", "current-run-external-id": "run-9MmJaoQTvDCh5wUa", "current-run-status": "applied", "drifted": true, "external-id": "ws-igUVNQSYVXRkhYuo", "module-count": 0, "modules": null, "organization-name": "acme-corp", "project-external-id": "prj-uU2xNqGeG86U9WgT", "project-name": "web", "provider-count": 0, "providers": null, "resources-drifted": 3, "resources-undrifted": 3, "state-version-terraform-version": "1.4.5", "vcs-repo-identifier": "acmecorp/api", "workspace-created-at": "2023-04-25T17:09:14.960+00:00", "workspace-name": "pumpkin smasher", "workspace-terraform-version": "1.4.5", "workspace-updated-at": "2023-12-08T20:43:16.779+00:00" }, "id": "ws-igUNVQSYXVRkhYuo", "type": "visibility-workspace" } ], "links": { "self": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "first": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "last": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces", "prev": null, "next": null }, "meta": { "pagination": { "current-page": 1, "page-size": 20, "next-page": null, "prev-page": null, "total-pages": 1, "total-count": 2 } } } ``` ## Query a saved view as CSV Re-execute a saved view's query to retrieve current results, HCP Terraform returns results as a CSV. `GET /api/v2/organizations/:organization\_name/explorer/views/:view\_id/csv` | Parameter | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `:organization\_name` | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. | | `:view\_id` | The external id of the saved view to query. | ### Sample request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --request GET \ 'https://app.terraform.io/api/v2/organizations/$ORG\_NAME/explorer/views/$VIEW\_ID/csv` ``` ### Sample response ```csv all\_checks\_succeeded,checks\_errored,checks\_failed,checks\_passed,checks\_unknown,current\_run\_applied\_at,current\_run\_external\_id,current\_run\_status,drifted,external\_id,module\_count,modules,organization\_name,project\_external\_id,project\_name,provider\_count,providers,resources\_drifted,resources\_undrifted,state\_version\_terraform\_version,vcs\_repo\_identifier,workspace\_created\_at,workspace\_name,workspace\_terraform\_version,workspace\_updated\_at "true","0","0","0","0","","run-rdoEKh2Gy3K6SbCZ","planned\_and\_finished","false","ws-j2sAeWRxou1b5HYf","0","","acme-corp","prj-V61QLE8tvs4NvVZG","Default Project","0","","0","0","1.5.7","","2023-10-17T21:56:45+00:00","candy distribution service","1.5.7","2023-12-13T15:48:16+00:00" "true","0","0","0","0","2023-08-18T16:24:59+00:00","run-9MmJaoQTvDCh5wUa","applied","true","ws-igUVNQSYVXRkhYuo","0","","acme-corp","prj-uU2xNqGeG86U9WgT","web","0","","3","3","1.4.5","acmecorp/api","2023-04-25T17:09:14+00:00","api-service","1.4.5","2023-12-13T15:29:03+00:00" ``` @include 'beta/explorer-limitations.mdx' | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.02062804251909256,
0.06686706095933914,
-0.015254594385623932,
0.10353457927703857,
-0.02486388571560383,
0.012318616732954979,
0.03219466283917427,
-0.04093113914132118,
0.03764040768146515,
-0.021016258746385574,
0.018696660175919533,
-0.0783044695854187,
0.005448366515338421,
0.05237... | 0.021078 |
distribution service","1.5.7","2023-12-13T15:48:16+00:00" "true","0","0","0","0","2023-08-18T16:24:59+00:00","run-9MmJaoQTvDCh5wUa","applied","true","ws-igUVNQSYVXRkhYuo","0","","acme-corp","prj-uU2xNqGeG86U9WgT","web","0","","3","3","1.4.5","acmecorp/api","2023-04-25T17:09:14+00:00","api-service","1.4.5","2023-12-13T15:29:03+00:00" ``` @include 'beta/explorer-limitations.mdx' | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/explorer.mdx | main | terraform | [
-0.029209092259407043,
-0.0782448872923851,
-0.08145595341920853,
-0.040939997881650925,
0.026301655918359756,
-0.022037731483578682,
0.02930431254208088,
0.0011675888672471046,
0.009542113170027733,
0.030184661969542503,
0.04991122707724571,
-0.019237251952290535,
0.048585373908281326,
0.... | 0.110498 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [302]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Configuration versions API reference Before working with the runs or configuration versions APIs, read the [API-driven run workflow](/terraform/cloud-docs/workspaces/run/api) page. The page provides a full overview of the workflow and walks through a simplified implementation. Use the `configuration-version` endpoint to reference uploaded configuration files on a workspace. 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](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) documentation for more details. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Attributes The `/configuration-version` endpoint has the following 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. | State | Description | | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `pending` | The initial status of a configuration version after it has been created. Pending configuration versions cannot be used to create new runs. | | `fetching` | For configuration versions created from a commit to a connected VCS repository, HCP Terraform is currently fetching the associated files from VCS. | | `uploaded` | The configuration version is fully processed and can be used in runs. | | `archived` | All immediate runs are complete and HCP Terraform 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, HCP Terraform will re-fetch the files from VCS. | | `errored` | HCP Terraform 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. | | `backing\_data\_soft\_deleted` | Indicates that the configuration version's backing data is marked for garbage collection. If no action is taken, the backing data associated with this configuration version is permanently deleted after a set number of days. You can restore the backing data associated with the configuration version before it is permanently deleted. | | | `backing\_data\_permanently\_deleted` | The configuration version's backing data has been permanently deleted and can no longer be restored. | ## List Configuration Versions `GET /workspaces/:workspace\_id/configuration-versions` | Parameter | Description | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:workspace\_id` | The ID of the workspace to list configurations from. Obtain this from the [workspace settings](/terraform/cloud-docs/workspaces/settings) or the [Show Workspace](/terraform/cloud-docs/api-docs/workspaces#show-workspace) endpoint. | ### Query Parameters This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. | Parameter | Description | | -------------- | -------------------------------------------------------------------------------------- | | `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 ```shell 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 ```json { "data": [ { | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/configuration-versions.mdx | main | terraform | [
-0.02195754460990429,
-0.020659523084759712,
-0.0290676299482584,
-0.014626014977693558,
-0.0197884701192379,
-0.08796516060829163,
-0.05588258430361748,
-0.07633461803197861,
-0.001209685462526977,
-0.03585217893123627,
0.02804061770439148,
0.05407903343439102,
-0.0020975309889763594,
-0.... | 0.063536 |
will return the first page. | | `page[size]` | \*\*Optional.\*\* If omitted, the endpoint will return 20 configuration versions per page. | ### Sample Request ```shell 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 ```json { "data": [ { "id": "cv-ntv3HbhJqvFzamy7", "type": "configuration-versions", "attributes": { "error": null, "error-message": null, "source": "gitlab", "speculative":false, "status": "uploaded", "status-timestamps": {}, "provisional": false }, "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` | Parameter | Description | | ------------------- | ------------------------------------ | | `:configuration-id` | The id of the configuration to show. | ### Sample Request ```shell 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 ```json { "data": { "id": "cv-ntv3HbhJqvFzamy7", "type": "configuration-versions", "attributes": { "error": null, "error-message": null, "source": "gitlab", "speculative":false, "status": "uploaded", "status-timestamps": {}, "provisional": false }, "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` | Parameter | Description | | ------------------- | ------------------------------------ | | `:configuration-id` | The 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` | Parameter | Description | | ------------------- | ------------------------------------ | | `:configuration-id` | The id of the configuration to show. | ### Sample Request ```shell 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 ```json { "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` | Parameter | Description | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `:workspace\_id` | The ID of the workspace to create the new configuration version in. Obtain this from the [workspace settings](/terraform/cloud-docs/workspaces/settings) or the [Show Workspace](/terraform/cloud-docs/api-docs/workspaces#show-workspace) endpoint. | -> \*\*Note:\*\* This endpoint cannot be accessed with [organization tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens). ### 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 path | Type | Default | Description | | --------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `data.attributes.auto-queue-runs` | boolean | true | When true, runs are queued automatically when the configuration version is uploaded. | | `data.attributes.speculative` | boolean | false | When true, this configuration version may only be used to create runs which are speculative, that is, can neither be confirmed nor applied. | | `data.attributes.provisional` | boolean | false | When true, this configuration version does not immediately become the workspace current configuration version. If the associated run is applied, it then becomes the current configuration | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/configuration-versions.mdx | main | terraform | [
-0.04897003993391991,
0.11985411494970322,
0.020292978733778,
0.03914857283234596,
0.02849380113184452,
-0.04027793928980827,
-0.08946839720010757,
-0.055115535855293274,
0.051864080131053925,
0.07778512686491013,
0.01047230139374733,
-0.0704207792878151,
0.014298204332590103,
-0.041563019... | -0.063586 |
be used to create runs which are speculative, that is, can neither be confirmed nor applied. | | `data.attributes.provisional` | boolean | false | When true, this configuration version does not immediately become the workspace current configuration version. If the associated run is applied, it then becomes the current configuration version unless a newer one exists.| ### Sample Payload ```json { "data": { "type": "configuration-versions", "attributes": { "auto-queue-runs": true } } } ``` ### Sample Request ```shell 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 ```json { "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", "provisional": false }, "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](#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](/terraform/cloud-docs/api-docs/run#create-a-run) manually after the configuration version is uploaded. `PUT https://archivist.terraform.io/v1/object/` \*\*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.\*\* ```shell 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` | Parameter | Description | | --------------------------- | ---------------------------------------------- | | `configuration\_version\_id` | The ID of the configuration version to archive. | This endpoint notifies HCP Terraform 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](#configuration-version-states), have no runs in progress, and are not the current configuration version for any workspace. Otherwise, calling this endpoint will result in an error. HCP Terraform automatically archives configuration versions created through VCS when associated runs are complete and then re-fetches the files for subsequent runs. | Status | Response | Reason(s) | | ------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | [202][] | none | Successfully initiated the archive process. | | [409][] | [JSON API error object][] | Configuration version was in a non-archivable state or the configuration version was created with VCS and cannot be archived through the API. | | [404][] | [JSON API error object][] | Configuration version was not found or user not authorized. | ### Request Body This POST endpoint does not take a request body. ### Sample Request ```shell 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` | Parameter | Description | | --------------------------- | ------------------------------------------------ | | `configuration\_version\_id` | The ID of the configuration version to download. | `GET /runs/:run\_id/configuration-version/download` | Parameter | Description | | --------------------------- | ------------------------------------------------------------------- | | `run\_id` | The 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 | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/configuration-versions.mdx | main | terraform | [
-0.07544317096471786,
0.07568658888339996,
0.036826327443122864,
0.005269830580800772,
0.020602311939001083,
-0.05816005542874336,
-0.056920040398836136,
-0.05981244519352913,
0.03841916099190712,
0.05816873162984848,
0.013096942566335201,
-0.03848098963499069,
0.018628928810358047,
0.0035... | 0.006569 |
| Description | | --------------------------- | ------------------------------------------------------------------- | | `run\_id` | The 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](#configuration-version-states). | Status | Response | Reason | |---------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------| | [302][] | HTTP Redirect | Configuration version found and temporary download URL generated | | [404][] | [JSON API error object][] | Configuration version not found, or specified configuration version is not uploaded, or user unauthorized to perform action | ### Sample Request ```shell 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 ``` ## Mark a Configuration Version for Garbage Collection This endpoint is exclusive to Terraform Enterprise, and not available in HCP Terraform. [Learn more about Terraform Enterprise](https://developer.hashicorp.com/terraform/enterprise). `POST /api/v2/configuration-versions/:configuration-id/actions/soft\_delete\_backing\_data` | Parameter | Description | | --------------------------- | ---------------------------------------------- | | `:configuration-id` | The ID of the configuration version to soft delete. | This endpoint directs Terraform Enterprise to \_soft delete\_ the backing files associated with the configuration version. Soft deletion refers to marking the configuration version for garbage collection. Terraform permanently deletes configuration versions marked for soft deletion after a set number of days unless the configuration version is restored. Once a configuration version is soft deleted, any attempts to read the configuration version will fail. Refer to [Configuration Version States](#configuration-version-states) for information about all data states. This endpoint can only soft delete configuration versions that meet the following criteria: - Were created using the API or CLI, - are in an [`uploaded` state](#configuration-version-states), - and are not the current configuration version. Otherwise, the endpoint returns an error. | Status | Response | Reason(s) | | ------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | [200][] | none | Terraform successfully marked the data for garbage collection. | | [400][] | [JSON API error object][] | Terraform failed to transition the state to `backing\_data\_soft\_deleted`. | | [404][] | [JSON API error object][] | Terraform did not find the configuration version or the user is not authorized to modify the configuration version state. | ### Request Body This POST endpoint does not take a request body. ### Sample Request ```shell 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/soft\_delete\_backing\_data --data {"data": {"attributes": {"delete-older-than-n-days": 23}}} ``` ## Restore Configuration Versions Marked for Garbage Collection This endpoint is exclusive to Terraform Enterprise, and not available in HCP Terraform. [Learn more about Terraform Enterprise](https://developer.hashicorp.com/terraform/enterprise). `POST /api/v2/configuration-versions/:configuration-id/actions/restore\_backing\_data` | Parameter | Description | | --------------------------- | ---------------------------------------------- | | `:configuration-id` | The ID of the configuration version to restore back to its uploaded state if applicable. | This endpoint directs Terraform Enterprise to restore backing files associated with this configuration version. This endpoint can only restore delete configuration versions that meet the following criteria: - are not in a [`backing\_data\_permanently\_deleted` state](#configuration-version-states). Otherwise, the endpoint returns an error. Terraform restores applicable configuration versions back to their `uploaded` state. | Status | Response | Reason(s) | | ------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | [200][] | none | Terraform successfully initiated the restore process. | | [400][] | [JSON API error object][] | Terraform failed to transition the state to `uploaded`. | | [404][] | [JSON API error object][] | Terraform did | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/configuration-versions.mdx | main | terraform | [
-0.03672241047024727,
0.07728266716003418,
-0.038133732974529266,
0.02080308273434639,
0.10740640759468079,
-0.02085993066430092,
-0.05752755329012871,
0.008702653460204601,
-0.06800555437803268,
0.03639919310808182,
-0.01769035868346691,
0.06823690235614777,
0.03411291167140007,
-0.052570... | -0.070227 |
Response | Reason(s) | | ------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | [200][] | none | Terraform successfully initiated the restore process. | | [400][] | [JSON API error object][] | Terraform failed to transition the state to `uploaded`. | | [404][] | [JSON API error object][] | Terraform did not find the configuration version or the user is not authorized to modify the configuration version state. | ### Request Body This POST endpoint does not take a request body. ### Sample Request ```shell 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/restore\_backing\_data ``` ## Permanently Delete a Configuration Version This endpoint is exclusive to Terraform Enterprise, and not available in HCP Terraform. [Learn more about Terraform Enterprise](https://developer.hashicorp.com/terraform/enterprise). `POST /api/v2/configuration-versions/:configuration-id/actions/permanently\_delete\_backing\_data` | Parameter | Description | | --------------------------- | ---------------------------------------------- | | `:configuration-id` | The ID of the configuration version to permanently delete. | This endpoint directs Terraform Enterprise to permanently delete backing files associated with this configuration version. This endpoint can only permanently delete configuration versions that meet the following criteria: - Were created using the API or CLI, - are in a [`backing\_data\_soft\_deleted` state](#configuration-version-states), - and are not the current configuration version. Otherwise, the endpoint returns an error. | Status | Response | Reason(s) | | ------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | [200][] | none | Terraform successfully deleted the data permanently. | | [400][] | [JSON API error object][] | Terraform failed to transition the state to `backing\_data\_permanently\_deleted`. | | [404][] | [JSON API error object][] | Terraform did not find the configuration version or the user is not authorized to modify the configuration version state. | ### Request Body This POST endpoint does not take a request body. ### Sample Request ```shell 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/permanently\_delete\_backing\_data ``` ## Available Related Resources The GET endpoints above can optionally return related resources, if requested with [the `include` query parameter](/terraform/cloud-docs/api-docs#inclusion-of-related-resources). The following resource types are available: | Resource Name | Description | | -------------------- | ------------------------------------------------- | | `ingress\_attributes` | The commit information used in the configuration. | | `run` | The run created by the configuration. | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/configuration-versions.mdx | main | terraform | [
-0.10001353919506073,
0.03879188373684883,
0.050492316484451294,
-0.002129421103745699,
0.032182469964027405,
-0.04882536455988884,
-0.06647196412086487,
-0.050512608140707016,
0.026751726865768433,
0.06723518669605255,
0.024459829553961754,
-0.09378253668546677,
0.04317798465490341,
-0.00... | 0.031434 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Organization tokens API reference ## Generate a new organization token `POST /organizations/:organization\_name/authentication-token` | Parameter | Description | | -------------------- | ----------------------------------------------------- | | `:organization\_name` | The name of the organization to generate a token for. | Generates a new [organization API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens), replacing any existing token. Only members of the owners team, the owners [team API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens), and the [organization API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens) can access this endpoint. This endpoint returns the secret text of the new authentication token. You can only access this token when you create it and can not recover it later. [permissions-citation]: #intentionally-unused---keep-for-maintainers | Status | Response | Reason | | ------- | ------------------------------------------------------- | ------------------- | | [201][] | [JSON API document][] (`type: "authentication-tokens"`) | Success | | [404][] | [JSON API error object][] | User not authorized | ### Request Body This POST endpoint requires a JSON object with the following properties as a request payload. | Key path | Type | Default | Description | | ----------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------- | | `data.type` | string | | Must be `"authentication-token"`. | | `data.attributes.expired-at` | string | `null` | The UTC date and time that the Organization Token will expire, in ISO 8601 format. If omitted or set to `null` the token will never expire. | ### Sample Payload ```json { "data": { "type": "authentication-token", "attributes": { "expired-at": "2023-04-06T12:00:00.000Z" } } } ``` ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @payload.json \ https://app.terraform.io/api/v2/organizations/my-organization/authentication-token ``` ### Sample Response ```json { "data": { "id": "4111756", "type": "authentication-tokens", "attributes": { "created-at": "2017-11-29T19:11:28.075Z", "last-used-at": null, "description": null, "token": "ZgqYdzuvlv8Iyg.atlasv1.6nV7t1OyFls341jo1xdZTP72fN0uu9VL55ozqzekfmToGFbhoFvvygIRy2mwVAXomOE", "expired-at": "2023-04-06T12:00:00.000Z" }, "relationships": { "created-by": { "data": { "id": "user-62goNpx1ThQf689e", "type": "users" } } } } } ``` ## Delete the organization token `DELETE /organizations/:organization/authentication-token` | Parameter | Description | | -------------------- | --------------------------------------------- | | `:organization\_name` | Which organization's token should be deleted. | Only members of the owners team, the owners [team API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens), and the [organization API token](/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens) can access this endpoint. [permissions-citation]: #intentionally-unused---keep-for-maintainers | Status | Response | Reason | | ------- | ------------------------- | ------------------- | | [204][] | No Content | Success | | [404][] | [JSON API error object][] | User not authorized | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/organizations/my-organization/authentication-token ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/organization-tokens.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 [201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 [202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 [204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 [400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 [401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 [403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 [404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 [409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 [412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 [429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 [500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 [504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 [JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents [JSON API error object]: https://jsonapi.org/format/#error-objects # Subscriptions API reference -> \*\*Note:\*\* The subscriptions API is only available in HCP Terraform. An organization can subscribe to different [feature sets](/terraform/cloud-docs/api-docs/feature-sets), which represent the [pricing plans](/terraform/cloud-docs/overview) available in HCP Terraform. An organization's [entitlement set](/terraform/cloud-docs/api-docs#feature-entitlements) is calculated using its subscription and feature set. To change the subscription for an organization, use the billing settings in the HCP Terraform UI. ## Show Subscription For Organization `GET /organizations/:organization\_name/subscription` | Parameter | Description | | -------------------- | ----------------------------- | | `:organization\_name` | The name of the organization. | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/organizations/hashicorp/subscription ``` ### Sample Response ```json { "data": { "id": "sub-kyjptCZYXQ6amEVu", "type": "subscriptions", "attributes": { "end-at": null, "is-active": true, "start-at": "2021-01-20T07:03:53.492Z", "runs-ceiling": 1, "contract-start-at": null, "contract-user-limit": null, "contract-apply-limit": null, "run-task-limit": null, "run-task-workspace-limit": null, "run-task-mandatory-enforcement-limit": null, "policy-set-limit": null, "policy-limit": null, "policy-mandatory-enforcement-limit": null, "versioned-policy-set-limit": null, "agents-ceiling": 0, "is-public-free-tier": true, "is-self-serve-trial": false }, "relationships": { "organization": { "data": { "id": "hashicorp", "type": "organizations" } }, "billing-account": { "data": null }, "feature-set": { "data": { "id": "fs-EvCGYfpx9CVRzteA", "type": "feature-sets" } } }, "links": { "self": "/api/v2/subscriptions/sub-kyjptCZYXQ6amEVu" } }, "included": [ { "id": "fs-EvCGYfpx9CVRzteA", "type": "feature-sets", "attributes": { "audit-logging": false, "cost-estimation": false, "cost": 0, "description": "State storage, locking, run history, VCS integration, private module registry, and remote operations", "global-run-tasks": false, "identifier": "free", "is-current": true, "is-free-tier": true, "module-tests-generation": false, "name": "Free", "plan": null, "policy-enforcement": false, "policy-limit": null, "policy-mandatory-enforcement-limit": null, "policy-set-limit": null, "private-networking": false, "private-policy-agents": false, "private-run-tasks": false, "private-vcs": false, "run-task-limit": null, "run-task-mandatory-enforcement-limit": null, "run-task-workspace-limit": null, "run-tasks": false, "self-serve-billing": true, "sentinel": false, "sso": false, "teams": false, "user-limit": 5, "versioned-policy-set-limit": null } } ] } ``` ## Show Subscription By ID `GET /subscriptions/:id` | Parameter | Description | | --------- | ---------------------------------- | | `:id` | The ID of the Subscription to show | ### Sample Request ```shell curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request GET \ https://app.terraform.io/api/v2/organizations/hashicorp/subscription ``` ### Sample Response ```json { "data": { "id": "sub-kyjptCZYXQ6amEVu", "type": "subscriptions", "attributes": { "end-at": null, "is-active": true, "start-at": "2021-01-20T07:03:53.492Z", "runs-ceiling": 1, "contract-start-at": null, "contract-user-limit": null, "contract-apply-limit": null, "agents-ceiling": 0, "run-task-limit": null, "run-task-workspace-limit": null, "run-task-mandatory-enforcement-limit": null, "policy-set-limit": null, "policy-limit": null, "policy-mandatory-enforcement-limit": null, "versioned-policy-set-limit": null, "is-public-free-tier": true, "is-self-serve-trial": false }, "relationships": { "organization": { "data": { "id": "hashicorp", "type": "organizations" } }, "billing-account": { "data": null }, "feature-set": { "data": { "id": "fs-EvCGYfpx9CVRzteA", "type": "feature-sets" } } }, "links": { "self": "/api/v2/subscriptions/sub-kyjptCZYXQ6amEVu" } }, "included": [ { "id": "fs-EvCGYfpx9CVRzteA", "type": "feature-sets", "attributes": { "audit-logging": false, "cost-estimation": false, "cost": 0, "description": "State storage, locking, run history, VCS integration, private module registry, and remote operations", "global-run-tasks": false, "identifier": "free", "is-current": true, "is-free-tier": true, "module-tests-generation": false, "name": "Free", "plan": null, "policy-enforcement": false, "policy-limit": null, "policy-mandatory-enforcement-limit": null, "policy-set-limit": null, "private-networking": false, "private-policy-agents": false, "private-run-tasks": false, "private-vcs": false, "run-task-limit": null, "run-task-mandatory-enforcement-limit": null, "run-task-workspace-limit": null, "run-tasks": false, "self-serve-billing": true, "sentinel": false, "sso": false, "teams": false, "user-limit": 5, "versioned-policy-set-limit": null } } ] } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/api-docs/subscriptions.mdx | main | terraform | [
-0.015784088522195816,
-0.01700746826827526,
-0.018668580800294876,
-0.028096551075577736,
-0.024631375446915627,
-0.08318780362606049,
-0.0621652752161026,
-0.07521579414606094,
-0.005580500699579716,
-0.03855427727103233,
0.03281282261013985,
0.0540321059525013,
0.006812138482928276,
-0.... | 0.052879 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.