# Create a workspace variable

Source: https://www.jawsdeploy.net/rest-api/workspace-variables-create | Section: Workspace Variables

Create a new variable at the workspace level.

`POST /api/workspace-variable`

Creates a workspace variable.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `workspaceId` | body | string | yes | ID of the workspace. |
| `name` | body | string | yes | Variable name. |
| `description` | body | string | no | Optional description. |
| `variableType` | body | string | no | See below. |

### Variable types

`variableType` accepts `Text`, `Secret`, `Script`, `Number`, `Boolean`, `Date`, `Map`, and `Json`. `Text` is used when the field is omitted.

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `workspaceId`, invalid `variableType`, or validation failure. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks the required role. |

Example request:

```
POST /api/workspace-variable

{ "workspaceId": "ws_abc", "name": "ConnectionString", "variableType": "Secret" }
```

Example response:

```
{ "variableId": "wv_1" }
```

