# Update environment

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

Update an environment. Requires project.environments.manage.

## Parameters

| Name                | In   | Required | Description                                                |
| ------------------- | ---- | -------- | ---------------------------------------------------------- |
| `project_reference` | path | Yes      | Project slug, UUID, or domain that identifies the project. |
| `environment_id`    | path | Yes      | Environment ID                                             |

## Request body

| Field       | Type    | Required | Description                                                                                                                                                                                        |
| ----------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`      | string  |          | New environment name                                                                                                                                                                               |
| `protected` | boolean |          | Whether the environment is protected                                                                                                                                                               |
| `variables` | array   |          | Atomic variable upserts in this environment. Existing keys retain their IDs; omitted keys remain unchanged and returned values are masked. A non-empty list also requires project.env\_vars.write. |

## Responses

| Status | Description                      |
| ------ | -------------------------------- |
| 200    | Environment updated successfully |
| 400    | Bad request                      |
| 401    | Unauthorized                     |
| 403    | Forbidden                        |
| 404    | Not found                        |
| 500    | Server error                     |
