• Overview
    • Enforce Policy as Code
    • Infrastructure as Code
    • Inject Secrets into Terraform
    • Integrate with Existing Workflows
    • Manage Kubernetes
    • Manage Virtual Machine Images
    • Multi-Cloud Deployment
    • Network Infrastructure Automation
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
  • Registry
  • Tutorials
    • About the Docs
    • Intro to Terraform
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
    • Terraform Tools
    • CDK for Terraform
    • Glossary
  • Community
GitHubTerraform Cloud
Download

    Terraform Cloud and Enterprise

  • Overview
  • Plans and Features
  • Getting Started
    • API Docs template
    • Overview
    • Account
    • Agent Pools
    • Agent Tokens
    • Applies
    • Audit Trails
    • Comments
    • Configuration Versions
    • Cost Estimates
    • Feature Sets
    • Invoices
    • IP Ranges
    • Notification Configurations
    • OAuth Clients
    • OAuth Tokens
    • Organizations
    • Organization Memberships
    • Organization Tags
    • Organization Tokens
    • Plan Exports
    • Plans
    • Policies
    • Policy Checks
    • Policy Sets
    • Policy Set Parameters
      • Modules
      • Providers
      • Private Provider Versions and Platforms
      • GPG Keys
    • Runs
      • Run Tasks
      • Stages and Results
      • Custom Integration
    • Run Triggers
    • SSH Keys
    • State Versions
    • State Version Outputs
    • Subscriptions
    • Team Access
    • Team Membership
    • Team Tokens
    • Teams
    • User Tokens
    • Users
    • Variables
    • VCS Events
    • Workspaces
    • Workspace-Specific Variables
    • Workspace Resources
    • Variable Sets
      • Overview
      • Module Sharing
      • Organizations
      • Runs
      • Settings
      • Terraform Versions
      • Users
      • Workspaces
    • Changelog
    • Stability Policy
    • Overview
    • Creating Workspaces
    • Naming
    • Terraform Configurations
      • Overview
      • Managing Variables
      • Overview
      • VCS Connections
      • Access
      • Drift Detection
      • Notifications
      • SSH Keys for Modules
      • Run Triggers
      • Run Tasks
    • Terraform State
    • JSON Filtering
    • Remote Operations
    • Viewing and Managing Runs
    • Run States and Stages
    • Run Modes and Options
    • UI/VCS-driven Runs
    • API-driven Runs
    • CLI-driven Runs
    • The Run Environment
    • Installing Software
    • Users
    • Teams
    • Organizations
    • Permissions
    • Two-factor Authentication
    • API Tokens
      • Overview
      • Microsoft Azure AD
      • Okta
      • SAML
      • Linking a User Account
      • Testing
    • Overview
    • GitHub.com
    • GitHub.com (OAuth)
    • GitHub Enterprise
    • GitLab.com
    • GitLab EE and CE
    • Bitbucket Cloud
    • Bitbucket Server and Data Center
    • Azure DevOps Services
    • Azure DevOps Server
    • Troubleshooting
    • Overview
    • Adding Public Providers and Modules
    • Publishing Private Providers
    • Publishing Private Modules
    • Using Providers and Modules
    • Configuration Designer
  • Migrating to Terraform Cloud
    • Overview
    • Using Sentinel with Terraform 0.12
    • Manage Policies
    • Enforce and Override Policies
    • Mocking Terraform Sentinel Data
    • Working With JSON Result Data
      • Overview
      • tfconfig
      • tfconfig/v2
      • tfplan
      • tfplan/v2
      • tfstate
      • tfstate/v2
      • tfrun
    • Example Policies
    • Overview
    • AWS
    • GCP
    • Azure
      • Overview
      • Service Catalog
      • Admin Guide
      • Developer Reference
      • Example Customizations
      • V1 Setup Instructions
    • Splunk Integration
    • Kubernetes Integration
    • Run Tasks Integration
    • Overview
    • IP Ranges
    • Data Security
    • Security Model
    • Overview
    • Part 1: Overview of Our Recommended Workflow
    • Part 2: Evaluating Your Current Provisioning Practices
    • Part 3: How to Evolve Your Provisioning Practices
    • Part 3.1: From Manual Changes to Semi-Automation
    • Part 3.2: From Semi-Automation to Infrastructure as Code
    • Part 3.3: From Infrastructure as Code to Collaborative Infrastructure as Code
    • Part 3.4: Advanced Workflow Improvements

  • Terraform Cloud Agents

  • Terraform Enterprise Admin

  • Other Docs

  • Intro to Terraform
  • Configuration Language
  • Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise
  • Provider Use
  • Plugin Development
  • Registry Publishing
  • Integration Program
  • Terraform Tools
  • CDK for Terraform
  • Glossary
Type '/' to Search

»Variable Sets API

A variable set is a resource that allows you to reuse the same variables across multiple workspaces. For example, you could define a variable set of provider credentials and automatically apply it to one or all workspaces.

You need read variables permission to view the variables for a particular workspace and to view the variable sets in the owning organization. To create or edit variable sets, your team must have Manage Workspace organization access.

»Create a Variable Set

POST organizations/:organization_name/varsets

ParameterDescription
:organization_nameThe name of the organization the workspace belongs to.

»Request Body

Properties without a default value are required.

Key pathTypeDefaultDescription
data.namestringThe name of the variable set.
data.descriptionstring""Text displayed in the UI to contextualize the variable set and its purpose.
data.globalbooleanfalseWhen true, Terraform Cloud automatically applies the variable set to all current and future workspaces in the organization.
data.relationships.workspacesarray[]Array of references to workspaces that the variable set should be assigned to. Sending an empty array clears all workspace assignments.
data.relationships.varsarray[]Array of complete variable definitions that comprise the variable set.

Terraform Cloud 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.

StatusResponseReason(s)
200JSON API documentSuccessfully added variable set
404JSON API error objectOrganization not found, or user unauthorized to perform action
422JSON API error objectProblem 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
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "vars": {
        "data": [
          {
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "type": "varsets",
    "attributes": {
      "name": "MyVarset",
      "description": "Full of vars and such for mass reuse",
      "global": false
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "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 POST \
  --data @payload.json \
  https://app.terraform.io/api/v2/organizations/my-organization/varsets
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
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "id": "varset-kjkN545LH2Sfercv"
    "type": "varsets",
    "attributes": {
      "name": "MyVarset",
      "description": "Full of vars and such for mass reuse",
      "global": false
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}

»Update a Variable Set

PUT/PATCH varsets/:varset_id

ParameterDescription
:varset_idThe variable set ID

Terraform Cloud 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.

StatusResponseReason(s)
200JSON API documentSuccessfully updated variable set
404JSON API error objectOrganization or variable set not found, or user unauthorized to perform action
422JSON API error objectProblem 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
    },
    "relationships": {
      "vars": {
        "data": [
          {
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "type": "varsets",
    "attributes": {
      "name": "MyVarset",
      "description": "Full of vars and such for mass reuse. Now global!",
      "global": true
    },
    "relationships": {
      "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 \
  https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv
curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request PATCH \
  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
    },
    "relationships": {
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "id": "varset-kjkN545LH2Sfercv"
    "type": "varsets",
    "attributes": {
      "name": "MyVarset",
      "description": "Full of vars and such for mass reuse. Now global!",
      "global": true
    },
    "relationships": {
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}

»Delete a Variable Set

DELETE varsets/:varset_id

ParameterDescription
:varset_idThe 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
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

ParameterDescription
:varset_idThe 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
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
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "id": "varset-kjkN545LH2Sfercv"
    "type": "varsets",
    "attributes": {
      "name": "MyVarset",
      "description": "Full of vars and such for mass reuse",
      "global": false
    },
    "relationships": {
      "workspaces": {
        "data": [
          {
            "id": "ws-z6YvbWEYoE168kpq",
            "type": "workspaces"
          }
        ]
      },
      "vars": {
        "data": [
          {
            "id": "var-Nh0doz0hzj9hrm34qq"
            "type": "vars",
            "attributes": {
              "key": "c2e4612d993c18e42ef30405ea7d0e9ae",
              "value": "8676328808c5bf56ac5c8c0def3b7071",
              "category": "terraform"
            }
          }
        ]
      }
    }
  }
}

»List Variable Set

List all variable sets for an organization.

GET organizations/:organization_name/varsets

ParameterDescription
:organization_nameThe name of the organization the workspace belongs to.

List all variable sets for a workspace.

GET workspaces/:workspace_id/varsets

ParameterDescription
:workspace_idThe workspace ID

»Sample Response

{
  "data": [
    {
      "id": "varset-mio9UUFyFMjU33S4",
      "type": "varsets",
      "attributes":  {
         "name": "varset-b7af6a77",
         "description": "Full of vars and such for mass reuse",
         "global": false,
         "updated-at": "2021-10-29T17:15:56.722Z",
         "var-count":  5,
         "workspace-count": 2
      },
      "relationships": {
        "organization": {
          "data": {"id": "organization_1", "type": "organizations"}
        },
        "vars": {
          "data": [
           {"id": "var-abcd12345", "type": "vars"},
           {"id": "var-abcd12346", "type": "vars"},
           {"id": "var-abcd12347", "type": "vars"},
           {"id": "var-abcd12348", "type": "vars"},
           {"id": "var-abcd12349", "type": "vars"}
          ]
        },
        "workspaces": {
          "data": [
           {"id": "ws-abcd12345", "type": "workspaces"},
           {"id": "ws-abcd12346", "type": "workspaces"}
          ]
        }
      }
    }
  ],
  "links": {
    "self": "app.terrafor.io/app/my_organization/varsets",
    "first": "app.terrafor.io/app/my_organization/varsets?page=1",
    "prev": null,
    "next": null,
    "last": "app.terrafor.io/app/my_organization/varsets?page=1"
  }
}
{
  "data": [
    {
      "id": "varset-mio9UUFyFMjU33S4",
      "type": "varsets",
      "attributes":  {
         "name": "varset-b7af6a77",
         "description": "Full of vars and such for mass reuse",
         "global": false,
         "updated-at": "2021-10-29T17:15:56.722Z",
         "var-count":  5,
         "workspace-count": 2
      },
      "relationships": {
        "organization": {
          "data": {"id": "organization_1", "type": "organizations"}
        },
        "vars": {
          "data": [
           {"id": "var-abcd12345", "type": "vars"},
           {"id": "var-abcd12346", "type": "vars"},
           {"id": "var-abcd12347", "type": "vars"},
           {"id": "var-abcd12348", "type": "vars"},
           {"id": "var-abcd12349", "type": "vars"}
          ]
        },
        "workspaces": {
          "data": [
           {"id": "ws-abcd12345", "type": "workspaces"},
           {"id": "ws-abcd12346", "type": "workspaces"}
          ]
        }
      }
    }
  ],
  "links": {
    "self": "app.terrafor.io/app/my_organization/varsets",
    "first": "app.terrafor.io/app/my_organization/varsets?page=1",
    "prev": null,
    "next": null,
    "last": "app.terrafor.io/app/my_organization/varsets?page=1"
  }
}

»Variable Relationships

»Add Variable

POST varsets/:varset_external_id/relationships/vars

ParameterDescription
:varset_idThe 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 pathTypeDefaultDescription
data.typestringMust be "vars".
data.attributes.keystringThe name of the variable.
data.attributes.valuestring""The value of the variable.
data.attributes.descriptionstringThe description of the variable.
data.attributes.categorystringWhether this is a Terraform or environment variable. Valid values are "terraform" or "env".
data.attributes.hclboolfalseWhether to evaluate the value of the variable as a string of HCL code. Has no effect for environment variables.
data.attributes.sensitiveboolfalseWhether the value is sensitive. If true, variable is not visible in the UI.

Terraform Cloud 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.

StatusResponseReason(s)
200JSON API documentSuccessfully added variable to variable set
404JSON API error objectVariable set not found, or user unauthorized to perform action
422JSON API error objectProblem 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
    }
  }
}
{
  "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
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 Respone

{
  "data": {
    "id":"var-EavQ1LztoRTQHSNT"
    "type": "vars",
    "attributes": {
      "key": "g6e45ae7564a17e81ef62fd1c7fa86138",
      "value": "61e400d5ccffb3782f215344481e6c82",
      "description": "cheeeese",
      "sensitive": false,
      "category": "terraform",
      "hcl": false
    }
  }
}
{
  "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

ParameterDescription
:varset_idThe variable set ID
:var_idThe ID of the variable to delete

Terraform Cloud 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.

StatusResponseReason(s)
200JSON API documentSuccessfully updated variable for variable set
404JSON API error objectVariable set not found, or user unauthorized to perform action
422JSON API error objectProblem 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
    }
  }
}
{
  "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
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
    }
  }
}
{
  "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

ParameterDescription
:varset_idThe variable set ID
:var_idThe ID of the variable to delete

»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-4q8f7H0NHG733bBH/relationships/vars/var-EavQ1LztoRTQHSNT
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-4q8f7H0NHG733bBH/relationships/vars/var-EavQ1LztoRTQHSNT

on success, responds with no content

»List Variables in a Variable Set

GET varsets/:varset_id/relationships/vars

ParameterDescription
:varset_idThe 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.terrafor.io/app/varsets/varset-992UMULdeDuebi1x/vars",
    "first": "app.terrafor.io/app/varsets/varset-992UMULdeDuebi1x/vars?page=1",
    "prev": null,
    "next": null,
    "last": "app.terrafor.io/app/varsets/varset-992UMULdeDuebi1x/vars?page=1"
  }
}
{
  "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.terrafor.io/app/varsets/varset-992UMULdeDuebi1x/vars",
    "first": "app.terrafor.io/app/varsets/varset-992UMULdeDuebi1x/vars?page=1",
    "prev": null,
    "next": null,
    "last": "app.terrafor.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

ParameterDescription
:varset_idThe variable set ID

Properties without a default value are required.

Key pathTypeDefaultDescription
data[].typestringMust be "workspaces"
data[].idstringThe id of the workspace to add the variable set to
StatusResponseReason(s)
204Successfully added variable set to the requested workspaces
404JSON API error objectVariable set not found or user unauthorized to perform action
422JSON API error objectProblem with payload or request; details provided in the error object

»Sample Payload

{
  "data": [
    {
      "type": "workspaces",
      "id": "ws-YwfuBJZkdai4xj9w"
    }
  ]
}
{
  "data": [
    {
      "type": "workspaces",
      "id": "ws-YwfuBJZkdai4xj9w"
    }
  ]
}

»Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/workspaces
curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  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

ParameterDescription
:varset_idThe variable set ID

Properties without a default value are required.

Key pathTypeDefaultDescription
data[].typestringMust be "workspaces"
data[].idstringThe id of the workspace to delete the variable set from
StatusResponseReason(s)
204Successfully removed variable set from the requested workspaces
404JSON API error objectVariable set not found or user unauthorized to perform action
422JSON API error objectProblem with payload or request; details provided in the error object

»Sample Payload

{
  "data": [
    {
      "type": "workspaces",
      "id": "ws-YwfuBJZkdai4xj9w"
    },
    {
      "type": "workspaces",
      "id": "ws-YwfuBJZkdai4xj9w"
    }
  ]
}
{
  "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 \
  https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/workspaces
curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request DELETE \
  https://app.terraform.io/api/v2/varsets/varset-kjkN545LH2Sfercv/relationships/workspaces
github logoEdit this page
  • Overview
  • Docs
  • Extend
  • Privacy
  • Security
  • Press Kit
  • Consent Manager