# Update environment variable

```http
PATCH /projects/{project_reference}/environments/{environment_id}/variables/{key}
```

Change the value or the key of one environment variable. Requires project.env\_vars.write.

## Parameters

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

## Request body

| Field     | Type   | Required | Description                             |
| --------- | ------ | -------- | --------------------------------------- |
| `new_key` | string |          | New environment variable key.           |
| `value`   | string |          | Replacement environment variable value. |

## Responses

| Status | Description                                                                                                 |
| ------ | ----------------------------------------------------------------------------------------------------------- |
| 200    | Environment variable updated; 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. |
