Terraform
Variable sets API reference
You can create a set of variables and reuse them aross your organization. Refer to Scope to learn more about creating and using variables sets.
Projects and organizations can both own variable sets. The owner of a variable set can determine the precedence of that set. Refer to Manage variable sets for more details on variable set permissions.
To view the variables applied from a variable set on a particular workspace, you must have Read variables permission on that workspace.
Create a Variable Set
POST organizations/:organization_name/varsets
| Parameter | Description |
|---|---|
:organization_name | The name of the organization the variable set belongs to. |
Request Body
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data.attributes.name | string | The name of the variable set. | |
data.attributes.description | string | "" | Text displayed in the UI to contextualize the variable set and its purpose. |
data.attributes.global | boolean | false | When true, HCP Terraform automatically applies the variable set to all current and future workspaces in the organization. |
data.attributes.priority | boolean | false | When true, the variables in the set override any other variable values with a more specific scope, including values set on the command line. |
data.relationships.workspaces | array | [] | Array of references to workspaces that the variable set should be assigned to. |
data.relationships.projects | array | [] | Array of references to projects that the variable set should be assigned to. |
data.relationships.stacks | array | [] | Array of references to Stacks that HCP Terraform assigns the variable set to. Only available in HCP Terraform. |
data.relationships.vars | array | [] | Array of complete variable definitions that comprise the variable set. |
data.relationships.parent | object | Organization that the variable set belongs to | The parent that owns this variable set. If the parent is a project, data.attributes.global must be false. |
data.relationships.parent.data.type | string | "organizations" | The resource type of the parent that owns this variable set. Valid values are organizations or projects. |
data.relationships.parent.data.id | string | Name of organization that the variable set belongs to. | The ID of the parent that owns the variable set. For organizations, use name instead of ID. |
HCP Terraform does not allow different global variable sets to contain conflicting variables with the same name and type. You will receive a 422 response if you try to create a global variable set that contains conflicting variables.
| Status | Response | Reason(s) |
|---|---|---|
| 200 | JSON API document | Successfully added variable set |
| 404 | JSON API error object | Organization not found, or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": {
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse",
"global": false,
"priority": false,
},
"relationships": {
"workspaces": {
"data": [
{
"id": "ws-z6YvbWEYoE168kpq",
"type": "workspaces"
}
]
},
"stacks": {
"data": [
{
"type": "stacks",
"id": "st-rrfaQkXz7CuKqt7K"
}
]
}
"vars": {
"data": [
{
"type": "vars",
"attributes": {
"key": "c2e4612d993c18e42ef30405ea7d0e9ae",
"value": "8676328808c5bf56ac5c8c0def3b7071",
"category": "terraform"
}
}
]
},
"parent": {
"data": {
"id": "prj-kFjgSzcZSr5c3imE",
"type": "projects"
}
}
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/organizations/my-organization/varsets
Sample Response
{
"data": {
"id": "varset-kjkN545LH2Sfercv",
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse",
"global": false,
"priority": false,
},
"relationships": {
"workspaces": {
"data": [
{
"id": "ws-z6YvbWEYoE168kpq",
"type": "workspaces"
}
]
},
"projects": {
"data": [
{
"id": "prj-kFjgSzcZSr5c3imE",
"type": "projects"
}
]
},
"stacks": {
"data": [
{
"id": "st-rrfaQkXz7CuKqt7K",
"type": "stacks"
}
]
}
"vars": {
"data": [
{
"id": "var-Nh0doz0hzj9hrm34qq",
"type": "vars",
"attributes": {
"key": "c2e4612d993c18e42ef30405ea7d0e9ae",
"value": "8676328808c5bf56ac5c8c0def3b7071",
"category": "terraform"
}
}
]
},
"parent": {
"data": {
"id": "prj-kFjgSzcZSr5c3imE",
"type": "projects"
}
}
}
}
}
Update a Variable Set
PUT/PATCH varsets/:varset_id
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
HCP Terraform does not allow global variable sets to contain conflicting variables with the same name and type. You will receive a 422 response if you try to create a global variable set that contains conflicting variables.
HCP Terraform does not allow you to change the parent organization or project of a variable set. Instead, you must delete the variable set and recreate it in the desired organization or project.
Request Body
| Key path | Type | Default | Description |
|---|---|---|---|
data.attributes.name | string | The name of the variable set. | |
data.attributes.description | string | Text displayed in the UI to contextualize the variable set and its purpose. | |
data.attributes.global | boolean | When true, HCP Terraform automatically applies the variable set to all current and future workspaces in the organization. | |
data.attributes.priority | boolean | false | When true, the variables in the set override any other variable values set with a more specific scope, including values set on the command line. |
data.relationships.workspaces | array | Optional Array of references to workspaces that the variable set should be assigned to. Sending an empty array clears all workspace assignments. | |
data.relationships.projects | array | Optional Array of references to projects that the variable set should be assigned to. Sending an empty array clears all project assignments. | |
data.relationships.stacks | array | Optional Array of references to Stacks that HCP Terraform assigns the variable set to. Sending an empty array clears all Stack assignments. Only available in HCP Terraform. | |
data.relationships.vars | array | Optional Array of complete variable definitions to add to the variable set. |
| Status | Response | Reason(s) |
|---|---|---|
| 200 | JSON API document | Successfully updated variable set |
| 404 | JSON API error object | Organization or variable set not found, or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": {
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse. Now global!",
"global": true,
"priority": true,
},
"relationships": {
"workspaces": {
"data": [
{
"id": "ws-FRFwkYoUoGn1e34b",
"type": "workspaces"
}
]
},
"projects": {
"data": [
{
"id": "prj-kFjgSzcZSr5c3imE",
"type": "projects"
}
]
},
"stacks": {
"data": [
{
"id": "st-rrfaQkXz7CuKqt7K",
"type": "stacks"
}
]
}
"vars": {
"data": [
{
"type": "vars",
"attributes": {
"key": "c2e4612d993c18e42ef30405ea7d0e9ae",
"value": "8676328808c5bf56ac5c8c0def3b7071",
"category": "terraform"
}
}
]
}
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv
Sample Response
{
"data": {
"id": "varset-kjkN545LH2Sfercv",
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse. Now global!",
"global": true,
"priority": true
},
"relationships": {
"organization": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
},
"workspaces": {
"data": [
{
"id": "ws-FRFwkYoUoGn1e34b",
"type": "workspaces"
}
]
},
"projects": {
"data": [
{
"id": "prj-kFjgSzcZSr5c3imE",
"type": "projects"
}
]
},
"stacks": {
"data": [
{
"id": "st-rrfaQkXz7CuKqt7K",
"type": "stacks"
}
]
}
"vars": {
"data": [
{
"id": "var-Nh0doz0hzj9hrm34qq",
"type": "vars",
"attributes": {
"key": "c2e4612d993c18e42ef30405ea7d0e9ae",
"value": "8676328808c5bf56ac5c8c0def3b7071",
"category": "terraform"
}
}
]
},
"parent": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
}
}
}
}
Delete a Variable Set
DELETE varsets/:varset_id
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv
On success, this endpoint responds with no content.
Show Variable Set
Fetch details about the specified variable set.
GET varsets/:varset_id
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request GET \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv
Sample Response
{
"data": {
"id": "varset-kjkN545LH2Sfercv",
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse",
"global": false,
"priority": false,
"updated-at": "2023-03-06T21:48:33.588Z",
"var-count": 5,
"workspace-count": 2,
"project-count": 2
},
"relationships": {
"organization": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
},
"vars": {
"data": [
{
"id": "var-mMqadSCxZtrQJAv8",
"type": "vars"
},
{
"id": "var-hFxUUKSk35QMsRVH",
"type": "vars"
},
{
"id": "var-fkd6N48tXRmoaPxH",
"type": "vars"
},
{
"id": "var-abcbBMBMWcZw3WiV",
"type": "vars"
},
{
"id": "var-vqvRKK1ZoqQCiMwN",
"type": "vars"
}
]
},
"workspaces": {
"data": [
{
"id": "ws-UohFdKAHUGsQ8Dtf",
"type": "workspaces"
},
{
"id": "ws-XhGhaaCrsx9ATson",
"type": "workspaces"
}
]
},
"projects": {
"data": [
{
"id": "prj-1JMwvPHFsdpsPhnt",
"type": "projects"
},
{
"id": "prj-SLDGqbYqELXE1obp",
"type": "projects"
}
]
},
"stacks":{
"data": [
{
"id": "st-NYdpLiBwkRXq5aAY",
"type": "stacks"
},
{
"id": "st-waGqbYqELXE1obp",
"type": "stacks"
}
]
},
"parent": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
}
}
}
}
List Variable Sets
List all variable sets for an organization.
GET organizations/:organization_name/varsets
| Parameter | Description |
|---|---|
:organization_name | The name of the organization the variable sets belong to |
List all variable sets for a project. This includes global variable sets from the project's organization.
GET projects/:project_id/varsets
| Parameter | Description |
|---|---|
:project_id | The project ID |
List all variable sets for a workspace. This includes global variable sets from the workspace's organization and variable sets attached to the project this workspace is contained within.
GET workspaces/:workspace_id/varsets
| Parameter | Description |
|---|---|
:workspace_id | The workspace ID |
Query Parameters
All list endpoints support pagination with standard URL query parameters and searching with the q parameter. 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 returns the first page. |
page[size] | Optional. If omitted, the endpoint returns 20 varsets per page. |
q | Optional. A search query string. You can search for a variable set using its name. |
Sample Response
{
"data": [
{
"id": "varset-kjkN545LH2Sfercv",
"type": "varsets",
"attributes": {
"name": "MyVarset",
"description": "Full of vars and such for mass reuse",
"global": false,
"priority": false,
"updated-at": "2023-03-06T21:48:33.588Z",
"var-count": 5,
"workspace-count": 2,
"project-count": 2
},
"relationships": {
"organization": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
},
"vars": {
"data": [
{
"id": "var-mMqadSCxZtrQJAv8",
"type": "vars"
},
{
"id": "var-hFxUUKSk35QMsRVH",
"type": "vars"
},
{
"id": "var-fkd6N48tXRmoaPxH",
"type": "vars"
},
{
"id": "var-abcbBMBMWcZw3WiV",
"type": "vars"
},
{
"id": "var-vqvRKK1ZoqQCiMwN",
"type": "vars"
}
]
},
"workspaces": {
"data": [
{
"id": "ws-UohFdKAHUGsQ8Dtf",
"type": "workspaces"
},
{
"id": "ws-XhGhaaCrsx9ATson",
"type": "workspaces"
}
]
},
"projects": {
"data": [
{
"id": "prj-1JMwvPHFsdpsPhnt",
"type": "projects"
},
{
"id": "prj-SLDGqbYqELXE1obp",
"type": "projects"
}
]
},
"stacks":{
"data": [
{
"id": "st-NYdpLiBwkRXq5aAY",
"type": "stacks"
},
{
"id": "st-waGqbYqELXE1obp",
"type": "stacks"
}
]
},
"parent": {
"data": {
"id": "hashicorp",
"type": "organizations"
}
}
}
}
],
"links": {
"self": "https://app.terraform.io/api/v2/organizations/hashicorp/varsets?page%5Bnumber%5D=1&page%5Bsize%5D=20",
"first": "https://app.terraform.io/api/v2/organizations/hashicorp/varsets?page%5Bnumber%5D=1&page%5Bsize%5D=20",
"prev": null,
"next": null,
"last": "https://app.terraform.io/api/v2/organizations/hashicorp/varsets?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": 1
}
}
}
Variable Relationships
Add Variable
POST varsets/:varset_external_id/relationships/vars
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
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, variable is not visible in the UI. |
HCP Terraform does not allow different global variable sets to contain conflicting variables with the same name and type. You will receive a 422 response if you try to add a conflicting variable to a global variable set.
| Status | Response | Reason(s) |
|---|---|---|
| 200 | JSON API document | Successfully added variable to variable set |
| 404 | JSON API error object | Variable set not found, or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": {
"type": "vars",
"attributes": {
"key": "g6e45ae7564a17e81ef62fd1c7fa86138",
"value": "61e400d5ccffb3782f215344481e6c82",
"description": "cheeeese",
"sensitive": false,
"category": "terraform",
"hcl": false
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-4q8f7H0NHG733bBH/relationships/vars
Sample Response
{
"data": {
"id":"var-EavQ1LztoRTQHSNT",
"type": "vars",
"attributes": {
"key": "g6e45ae7564a17e81ef62fd1c7fa86138",
"value": "61e400d5ccffb3782f215344481e6c82",
"description": "cheeeese",
"sensitive": false,
"category": "terraform",
"hcl": false
}
}
}
Update a Variable in a Variable Set
PATCH varsets/:varset_id/relationships/vars/:var_id
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
:var_id | The ID of the variable to delete |
HCP Terraform does not allow different global variable sets to contain conflicting variables with the same name and type. You will receive a 422 response if you try to add a conflicting variable to a global variable set.
| Status | Response | Reason(s) |
|---|---|---|
| 200 | JSON API document | Successfully updated variable for variable set |
| 404 | JSON API error object | Variable set not found, or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": {
"type": "vars",
"attributes": {
"key": "g6e45ae7564a17e81ef62fd1c7fa86138",
"value": "61e400d5ccffb3782f215344481e6c82",
"description": "new cheeeese",
"sensitive": false,
"category": "terraform",
"hcl": false
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-4q8f7H0NHG733bBH/relationships/vars/var-EavQ1LztoRTQHSNT
Sample Response
{
"data": {
"id":"var-EavQ1LztoRTQHSNT",
"type": "vars",
"attributes": {
"key": "g6e45ae7564a17e81ef62fd1c7fa86138",
"value": "61e400d5ccffb3782f215344481e6c82",
"description": "new cheeeese",
"sensitive": false,
"category": "terraform",
"hcl": false
}
}
}
Delete a Variable in a Variable Set
DELETE varsets/:varset_id/relationships/vars/:var_id
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
:var_id | The ID of the variable to delete |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
https://app.terraform.io/api/v2/varsets/varset-4q8f7H0NHG733bBH/relationships/vars/var-EavQ1LztoRTQHSNT
On success, this endpoint responds with no content.
List Variables in a Variable Set
GET varsets/:varset_id/relationships/vars
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Sample Response
{
"data": [
{
"id": "var-134r1k34nj5kjn",
"type": "vars",
"attributes": {
"key": "F115037558b045dd82da40b089e5db745",
"value": "1754288480dfd3060e2c37890422905f",
"sensitive": false,
"category": "terraform",
"hcl": false,
"created-at": "2021-10-29T18:54:29.379Z",
"description": ""
},
"relationships": {
"varset": {
"data": {
"id": "varset-992UMULdeDuebi1x",
"type": "varsets"
},
"links": { "related": "/api/v2/varsets/1" }
}
},
"links": { "self": "/api/v2/vars/var-BEPU9NjPVCiCfrXj" }
}
],
"links": {
"self": "app.terraform.io/app/varsets/varset-992UMULdeDuebi1x/vars",
"first": "app.terraform.io/app/varsets/varset-992UMULdeDuebi1x/vars?page=1",
"prev": null,
"next": null,
"last": "app.terraform.io/app/varsets/varset-992UMULdeDuebi1x/vars?page=1"
}
}
Apply Variable Set to Workspaces
Accepts a list of workspaces to add the variable set to.
POST varsets/:varset_id/relationships/workspaces
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "workspaces" | |
data[].id | string | The id of the workspace to add the variable set to |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully added variable set to the requested workspaces | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "workspaces",
"id": "ws-YwfuBJZkdai4xj9w"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/workspaces
Remove a Variable Set from Workspaces
Accepts a list of workspaces to remove the variable set from.
DELETE varsets/:varset_id/relationships/workspaces
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "workspaces" | |
data[].id | string | The id of the workspace to delete the variable set from |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully removed variable set from the requested workspaces | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "workspaces",
"id": "ws-YwfuBJZkdai4xj9w"
},
{
"type": "workspaces",
"id": "ws-YwfuBJZkdai4xj9w"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/workspaces
Apply Variable Set to Projects
Accepts a list of projects to add the variable set to. When you apply a variable set to a project, all the workspaces in that project will have the variable set applied to them.
POST varsets/:varset_id/relationships/projects
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "projects" | |
data[].id | string | The id of the project to add the variable set to |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully added variable set to the requested projects | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "projects",
"id": "prj-YwfuBJZkdai4xj9w"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/projects
Remove a Variable Set from Projects
Accepts a list of projects to remove the variable set from.
DELETE varsets/:varset_id/relationships/projects
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "projects" | |
data[].id | string | The id of the project to delete the variable set from |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully removed variable set from the requested projects | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "projects",
"id": "prj-YwfuBJZkdai4xj9w"
},
{
"type": "projects",
"id": "prj-lkjasdfiojwerlkj"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/projects
Apply Variable Set to Stacks
Accepts a list of Stacks to assign this variable set to.
POST varsets/:varset_id/relationships/stacks
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "stacks" | |
data[].id | string | The ID of the Stack to add the variable set to. |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully added variable set to the requested stacks | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "stacks",
"id": "st-YwfuCJZkdaiSxj2z"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/stacks
Remove a Variable Set from Stacks
Accepts a list of Stacks to remove the variable set from.
DELETE varsets/:varset_id/relationships/stacks
| Parameter | Description |
|---|---|
:varset_id | The variable set ID |
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data[].type | string | Must be "stacks" | |
data[].id | string | The ID of the Stack to delete the variable set from. |
| Status | Response | Reason(s) |
|---|---|---|
| 204 | Successfully removed variable set from the requested stacks | |
| 404 | JSON API error object | Variable set not found or user unauthorized to perform action |
| 422 | JSON API error object | Problem with payload or request; details provided in the error object |
Sample Payload
{
"data": [
{
"type": "stacks",
"id": "st-ZwfuBxZksai4xj9w"
},
{
"type": "stacks",
"id": "st-YwfuBJZkdai4xj9w"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
--data @payload.json \
https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/stacks
Available Related Resources
The GET endpoints above can optionally return related resources, if requested with the include query parameter. The following resource types are available:
| Resource Name | Description |
|---|---|
vars | Show each variable in a variable set and all of their attributes including id, key, value, sensitive, category, hcl, created_at, and description. |