---
title: "Update an environment variable"
method: PUT
path: "/projects/{project_id}/env-vars/{var_id}"
tags: ["Projects"]
---

# Update an environment variable

`PUT /projects/{project_id}/env-vars/{var_id}`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/env-vars/{var_id}`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required
- `var_id` integer, required

## Request body

- UpdateEnvironmentVariableRequest
  - `environment_ids` integer[], required
  - `include_in_preview` boolean
  - `is_secret` boolean, nullable: Optional secret-flag transition. - `Some(true)` promotes a regular var to a secret. - `Some(false)` is rejected if the row is already secret (one-way flag). - `None` (omitted) leaves the flag unchanged.
  - `key` string, required
  - `value` string, nullable: New plaintext value. `None` (omitted) keeps the existing ciphertext, which is the only way to edit a secret env var without re-typing its value (e.g. changing which environments it applies to).

## Response `200`

Environment variables updated successfully

- EnvironmentVariableResponse
  - `created_at` string, date-time, required
  - `environments` EnvironmentInfo[], required
    - `current_deployment_id` integer, nullable
    - `id` integer, required
    - `main_url` string, required
    - `name` string, required
  - `id` integer, required
  - `include_in_preview` boolean, required: Include this environment variable in preview environments
  - `is_secret` boolean, required: Whether the stored value is write-only. Marked secrets always have `value: None` in API responses and cannot be revealed.
  - `key` string, required
  - `secret_suggestion` SecretSuggestionResponse, nullable: Why a regular environment variable should probably be a secret.
    - `message` string, required: One sentence for the operator, e.g. "DATABASE_URL contains a password in its connection string".
    - `reason` 'connection_string_password' | 'private_key' | 'provider_token' | 'json_web_token' | 'credential_name', required: Why a regular variable looks like it holds a credential.
  - `updated_at` string, date-time, required
  - `value` string, nullable: Plaintext for regular variables in create/update responses, or `"***"` in list responses. Always `None` for marked secrets. Only regular variables can be read through the audited per-variable reveal endpoint.

## Other responses

- `400`: Invalid input
- `404`: Project or variable not found
- `500`: Internal server error

## Changes

- **2026-11-26** `e1864d950604`: 2 breaking
  - the `created_at` response's property type changed from `integer` to `string`, and format from `int64` to `date-time` for status `200`
  - the `updated_at` response's property type changed from `integer` to `string`, and format from `int64` to `date-time` for status `200`
- **2026-11-25** `480a86944327`: 1 info
  - the endpoint scheme security `bearer_auth` was added to the API
- **2026-11-01** `d73a147552a5`: 1 info
  - added the optional property `secret_suggestion` to the response with the `200` status
- **2026-05-30** `b72341d12f63`: 2 breaking, 4 info
  - the response property `value` became nullable for the status `200`
  - the response property `value` became optional for the status `200`
  - added the new optional request property `is_secret`
  - the request property `value` became nullable
  - …2 more

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/env-vars/:var_id/put.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
