---
title: "Create Environment Variable"
method: POST
path: "/v1/convai/environment-variables"
tags: ["Agents Platform"]
---

# Create Environment Variable

`POST /v1/convai/environment-variables`

Create a new environment variable for the workspace

## Headers

- `xi-api-key` string, nullable — Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

## Request body

- union
  - CreateStringEnvironmentVariableRequest
    - `type` 'string', required
    - `label` string, required — Unique label for the environment variable.
    - `values` object, required — Environment-specific values. Must include 'production' key.
  - CreateSecretEnvironmentVariableRequest
    - `type` 'secret', required
    - `label` string, required — Unique label for the environment variable.
    - `values` object, required — Environment-specific secret references. Must include 'production' key.
  - CreateAuthConnectionEnvironmentVariableRequest
    - `type` 'auth_connection', required
    - `label` string, required — Unique label for the environment variable.
    - `values` object, required — Environment-specific auth connection references. Must include 'production' key.

## Response `200`

Successful Response

- EnvironmentVariableResponse
  - `label` string, required
  - `created_at_unix_secs` integer, required
  - `updated_at_unix_secs` integer, required
  - `created_by_user_id` string, nullable
  - `type` 'string' | 'secret' | 'auth_connection', required
  - `id` string, required
  - `workspace_id` string, required
  - `values` union, required
    - object
    - object
    - object

## Other responses

- `400` — Invalid parameters
- `409` — Environment variable with this label already exists
- `422` — Validation Error

---

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