---
title: "Update a variable"
method: PATCH
path: "/v1/environment-variables/{variableKey}"
tags: ["Environment Variables"]
---

# Update a variable

`PATCH /v1/environment-variables/{variableKey}`

Updates an existing environment variable. Providing `values` merges them into the existing per-environment values by `_environmentId`; envs not present in the request keep their stored value. Submitting the masked secret placeholder (the value returned by read endpoints for secret variables) as a real value is rejected.

## Path parameters

- `variableKey` string, required

## Request body

- UpdateEnvironmentVariableRequestDto
  - `key` string — Unique key for the variable. Must start with a letter and contain only letters, digits, and underscores.
  - `type` 'string' — The type of the variable
  - `isSecret` boolean
  - `values` EnvironmentVariableValueDto[]
    - `_environmentId` string, required
    - `value` string, required

## Response `200`

OK

- EnvironmentVariableResponseDto
  - `_id` string, required
  - `_organizationId` string, required
  - `key` string, required
  - `type` 'string', required
  - `isSecret` boolean, required
  - `values` EnvironmentVariableValueResponseDto[], required
    - `_environmentId` string, required
    - `value` string, required — Value is masked (••••••••) for secret variables
  - `createdAt` string, required
  - `updatedAt` string, required

## Other responses

- `400` — A submitted value equals the public secret mask placeholder, or no fields were provided to update.
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Environment variable not found.
- `405` — Method Not Allowed
- `409` — Conflict
- `413` — Payload Too Large
- `414` — URI Too Long
- `415` — Unsupported Media Type
- `422` — Unprocessable Entity
- `429` — The client has sent too many requests in a given amount of time.
- `500` — Internal Server Error
- `503` — The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.

---

[API](https://skmtc.net/novu/apis/deprecated-novu-api-use-openapi-json-yaml-instead.md) · [All operations](https://skmtc.net/novu/apis/deprecated-novu-api-use-openapi-json-yaml-instead/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/novu/deprecated-novu-api-use-openapi-json-yaml-instead/versions/986fe259fa85/schema)
