# Add a workspace tenant variable

Source: https://www.jawsdeploy.net/rest-api/workspace-tenant-variable-template-create | Section: Workspace Tenant Variables

Add a tenant variable to the workspace, for projects to use.

`POST /api/workspace/tenant-variable-template`

Adds a workspace tenant variable. No project gets it until it starts using it with `POST /api/project/workspace-tenant-variables`.

A `Secret` default is stored encrypted and never returned.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `workspaceId` | body | string | yes | ID of the workspace. |
| `name` | body | string | yes | Variable name. Unique among the workspace tenant variables. A workspace variable may have the same name, but no project can use both. |
| `variableType` | body | string | no | `Text` (default), `Number`, `Boolean`, `Date`, `Secret`, `Script`, `Map` or `Json`. |
| `isRequired` | body | boolean | no | `true` when every tenant of a project that uses it must have a value (or the default is used). Defaults to `false`. |
| `defaultValue` | body | string | no | Used for tenants that don't have their own value. Must be valid for the type. |
| `description` | body | string | no | Explains what to fill in. |
| `sortOrder` | body | integer | no | Position in the list. Defaults to last. |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `workspaceId`, an unknown `variableType`, a name that is taken, or a default that is not valid for the type. |
| 401 | Missing or invalid Basic auth credentials, or the service account can't manage workspace variables in this workspace. |

Example request:

```
POST /api/workspace/tenant-variable-template HTTP/1.1
Authorization: Basic <base64(serviceAccountId:apiKey)>
Content-Type: application/json

{
  "workspaceId": "ws_abc123",
  "name": "Port",
  "variableType": "Number",
  "defaultValue": "8080"
}
```

Example response:

```
{
  "templateId": "tvt_port",
  "projectId": null,
  "workspaceId": "ws_abc123",
  "isWorkspace": true,
  "usedBy": [],
  "name": "Port",
  "description": null,
  "variableType": "Number",
  "isRequired": false,
  "sortOrder": 1,
  "hasDefault": true,
  "defaultValue": "8080"
}
```

