# Add a tenant variable

Source: https://www.jawsdeploy.net/rest-api/project-tenant-variable-template-create | Section: Tenant Variables

Add a variable a project asks each tenant to fill in.

`POST /api/project/tenant-variable-template`

Adds a tenant variable to a project. A `Secret` default is stored encrypted and never returned.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `projectId` | body | string | yes | ID of the project. |
| `name` | body | string | yes | Variable name. Unique in the project, and not the name of a project variable or a workspace variable used in the project. |
| `variableType` | body | string | no | `Text` (default), `Number`, `Boolean`, `Date`, `Secret`, `Script`, `Map` or `Json`. |
| `isRequired` | body | boolean | no | `true` when every tenant 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 `projectId`, 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 edit this project. |

Example request:

```
POST /api/project/tenant-variable-template HTTP/1.1
Authorization: Basic <base64(serviceAccountId:apiKey)>
Content-Type: application/json

{
  "projectId": "prj_abc123",
  "name": "DatabaseName",
  "variableType": "Text",
  "isRequired": true,
  "description": "The customer's database"
}
```

Example response:

```
{
  "templateId": "tvt_db",
  "projectId": "prj_abc123",
  "name": "DatabaseName",
  "description": "The customer's database",
  "variableType": "Text",
  "isRequired": true,
  "sortOrder": 0,
  "hasDefault": false,
  "defaultValue": null
}
```

