---
title: "Create a variable"
method: POST
path: "/v1/environment-variables"
tags: ["Environment Variables"]
---

# Create a variable

`POST /v1/environment-variables`

Creates a new environment variable. Keys must be uppercase with underscores only (e.g. BASE_URL). Secret variables are encrypted at rest and masked in API responses.

## Headers

- `idempotency-key` string

## Request body

- CreateEnvironmentVariableRequestDto
  - `key` string, required — 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 — Whether this variable is a secret (encrypted at rest, masked in responses)
  - `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, which is reserved.
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `405` — Method Not Allowed
- `409` — An environment variable with the same key already exists.
- `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/novu-api.md) · [All operations](https://skmtc.net/novu/apis/novu-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/novu/novu-api/revisions/c2b2fa0d5d48/schema)
