# Variables

This endpoint is used to create, update, search or delete variables information inside a Terrakube workspace.

{% hint style="warning" %}
To use this endpoint you should have "manageWorkspace" access at team level and a Terrakube workspace
{% endhint %}

### Entity fields:

| Path                        | Type    | Description                                                    |
| --------------------------- | ------- | -------------------------------------------------------------- |
| data.type                   | string  | Should be "variable"                                           |
| data.attributes.key         | string  | Unique variable name                                           |
| data.attributes.value       | string  | Key value                                                      |
| data.attributes.sensitive   | boolean | To hide the value when the output is sensitive                 |
| data.attributes.hcl         | boolean | Terraform HCL variable type                                    |
| data.attributes.category    | string  | Variable type could be TERRAFORM or ENV (Environment Variable) |
| data.attributes.description | string  | Free text                                                      |

### Example:

```
{
  "data": {
    "type": "variable",
    "attributes": {
      "key": "tag_name",
      "value": "HolaMundo",
      "sensitive": false,
      "hcl": false,
      "category": "TERRAFORM",
      "description": "Azure RG Tag"
    }
  }
}
```

### Supported Operations

## GET /workspace/{workspaceId}/variable/{variableId}

> Returns an instance of type variable

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"variable"}],"servers":[{"url":"/api/v1"}],"paths":{"/workspace/{workspaceId}/variable/{variableId}":{"get":{"tags":["variable"],"description":"Returns an instance of type variable","parameters":[{"name":"fields[variable]","in":"query","description":"Selects the set of variable fields that should be returned in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["category","description","hcl","key","sensitive","value","workspace"]}}},{"name":"include","in":"query","description":"Selects the set of relationships that should be expanded as a compound document in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["workspace"]}}}],"responses":{"200":{"description":"Successful response","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/variable"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}}}}}},"components":{"schemas":{"variable":{"type":"object","properties":{"type":{"type":"string","description":""},"id":{"type":"string"},"attributes":{"type":"object","properties":{"category":{"type":"string","readOnly":false,"writeOnly":false,"enum":["TERRAFORM","ENV"]},"description":{"type":"string","readOnly":false,"writeOnly":false},"hcl":{"type":"boolean","readOnly":false,"writeOnly":false},"key":{"type":"string","readOnly":false,"writeOnly":false},"sensitive":{"type":"boolean","readOnly":false,"writeOnly":false},"value":{"type":"string","description":"Read Permissions : (user read secret)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"workspace":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["workspace"]},"id":{"type":"string"}},"readOnly":false,"writeOnly":false}}}}}}}}}}}
```

{% openapi src="<https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09>" path="/workspace/{workspaceId}/variable" method="post" %}
[v1\_4.yml](https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media\&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09)
{% endopenapi %}

{% openapi src="<https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09>" path="/workspace/{workspaceId}/vcs/{vcsId}" method="delete" %}
[v1\_4.yml](https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media\&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09)
{% endopenapi %}

{% openapi src="<https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09>" path="/workspace/{workspaceId}/vcs/{vcsId}" method="patch" %}
[v1\_4.yml](https://4014930676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfAN3V983Y82_trlbcu%2Fuploads%2Fgit-blob-2824914a25a0c9dcaeb76f04beced4d42e3917dc%2Fv1_4.yml?alt=media\&token=d400fdb2-a7d2-4d5a-b731-28b1f7540c09)
{% endopenapi %}

{% hint style="info" %}
For a complete list of organization operation please visit the [OpenAPI specification](https://github.com/AzBuilder/terrakube-server/tree/main/openapi-spec)
{% endhint %}
