---
title: "Update Workspace Env Var"
method: PATCH
path: "/api/public/v2/env-vars/{var_id}"
tags: ["env-vars"]
---

# Update Workspace Env Var

`PATCH /api/public/v2/env-vars/{var_id}`

## Path parameters

- `var_id` integer, required

## Request body

- object
  - `value` string, required — New value for the environment variable. Must be non-empty.

## Response `200`

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.
- `404` — Workspace env var not found.
- `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)
