---
title: "createEnvironmentVariable"
method: POST
path: "/v1/environments"
tags: ["environments"]
---

# createEnvironmentVariable

`POST /v1/environments`

Create a new environment variable or secret for the organization. If `group` is provided and the group does not yet exist, it is created automatically.

## Request body

- EnvironmentVariableCreateRequest
  - `key` string, required
  - `type` 'String' | 'SecretString', required
  - `description` string
  - `group` string
  - `value` string
  - `protected` boolean — Whether the variable is protected from editing

## Response `201`

Created environment variable

- EnvironmentVariable
  - `key` string, required
  - `type` 'String' | 'SecretString', required
  - `description` string
  - `group` string — Optional group name for organising variables in the UI
  - `value` string — Value is returned for String type, omitted for SecretString
  - `protected` boolean — Whether the variable is protected from editing
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `403` — Forbidden
- `409` — Environment variable with this key already exists
- `500` — Internal server error

---

[API](https://skmtc.dev/epilot/apis/environments-api.md) · [All operations](https://skmtc.dev/epilot/apis/environments-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/epilot/environments-api/revisions/6e9b212bbe77/schema)
