---
title: "Create Environment Variable"
method: POST
path: "/v1/environments/{environmentId}/variables"
tags: ["Environments"]
---

# Create Environment Variable

`POST /v1/environments/{environmentId}/variables`

Adds a new variable to the environment. Values are encrypted at rest. The `(environment, key)` pair must be unique within the org. Source-backed personal environments can override inherited variable keys only when the inherited variable has `personal_override_allowed: true`.

## Path parameters

- `environmentId` string, required

## Request body

- CreateEnvironmentVariableRequest — Request body for creating an environment variable.
  - `key` string, required — Variable name
  - `value` string, required — Variable value (encrypted at rest)
  - `personal_override_allowed` boolean — Team/Global variables only. Allows source-backed personal environments to override this inherited key.

## Response `201`

Variable created

- EnvironmentVariableResponse
  - `environment_variable` EnvironmentVariable, required — An environment variable. Values are encrypted at rest and decrypted on read.
    - `id` string, uuid, required
    - `organization_id` string, uuid, required
    - `environment_id` string, uuid, required
    - `key` string, required — Variable name (e.g. `DATABASE_URL`)
    - `value` string, required — Variable value (returned in plaintext)
    - `personal_override_allowed` boolean, required — Whether source-backed personal environments may override this inherited key
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required

## Other responses

- `400` — Bad request - Missing or invalid parameters
- `401` — Unauthorized - Invalid or missing API key
- `403` — Admin access required to change personal override policy
- `409` — Conflict - Resource already exists or operation conflicts with current state
- `500` — Internal server error

---

[API](https://skmtc.net/tryreplicas/apis/replica-api.md) · [All operations](https://skmtc.net/tryreplicas/apis/replica-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tryreplicas/replica-api/versions/aa3b4c932f7a/schema)
