---
title: "Create Workspace Env Var"
method: POST
path: "/api/public/v2/env-vars"
tags: ["env-vars"]
---

# Create Workspace Env Var

`POST /api/public/v2/env-vars`

## Request body

- object
  - `key` string, required — Environment variable name. Must start with a letter or underscore and contain only letters, digits, and underscores.
  - `value` string — Value to store. May be empty to create a placeholder that the user will fill in later.

## Response `201`

Successful Response

- object
  - `success` boolean
  - `workspace_env_var` object
    - `id` integer
    - `key` string
    - `value_suffix` string, nullable — Last 4 characters of the stored value. Null or empty when the value is empty.
    - `is_empty` boolean — True when the value has not been set yet (placeholder created by the AI assistant).
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `workspace_id` integer — Present on workspace-scoped env vars.
    - `tool_registry_id` integer — Present on tool-scoped env vars.

## Other responses

- `401` — Unauthorized - missing or invalid API key.
- `409` — An environment variable with that key already exists in this workspace.
- `422` — Validation error - request parameters or body are invalid.

---

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