# Create environment variable

```http
POST /projects/{project_reference}/environments/{environment_id}/variables
```

Create an environment variable; a key that exists already is a conflict. Requires project.env\_vars.write.

## Parameters

| Name                | In   | Required | Description                             |
| ------------------- | ---- | -------- | --------------------------------------- |
| `project_reference` | path | Yes      |                                         |
| `environment_id`    | path | Yes      | Environment ID containing the variable. |

## Request body

| Field   | Type   | Required | Description                                                                                                          |
| ------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `key`   | string | Yes      | Environment variable key. Must start with a letter or underscore and contain only letters, numbers, and underscores. |
| `value` | string | Yes      | Environment variable value.                                                                                          |

## Responses

| Status | Description                                                                                                 |
| ------ | ----------------------------------------------------------------------------------------------------------- |
| 201    | Environment variable created; the value is masked                                                           |
| 400    | Bad request                                                                                                 |
| 401    | Unauthorized                                                                                                |
| 403    | Forbidden                                                                                                   |
| 404    | Not found                                                                                                   |
| 409    | Conflict                                                                                                    |
| 500    | Server error                                                                                                |
| 503    | internal: authentication state is temporarily unavailable and the request was not processed; retry shortly. |
