---
title: "PUT /v2/vals/{val_id}/environment_variables/{key}"
method: PUT
path: "/v2/vals/{val_id}/environment_variables/{key}"
tags: ["vals"]
---

# PUT /v2/vals/{val_id}/environment_variables/{key}

`PUT /v2/vals/{val_id}/environment_variables/{key}`

Update a environment variable scoped to this project.

## Path parameters

- `val_id` string, uuid, required
- `key` string, required

## Request body

- object — Inputs to update a environment variable
  - `value` string, required — Value of the environment variable.
  - `description` string, nullable — Optional description of the environment variable. Send null to clear an existing description; omit it to leave the description unchanged.

## Response `201`

An environment variable

- TEnvironmentVariable — An environment variable
  - `key` string, required — Name or key of the environment variable, accessible via Deno.env or process.env
  - `description` string, nullable, required — Optional description of the environment variable
  - `updatedAt` string, date-time, nullable, required
  - `createdAt` string, date-time, required

## Changes

- **2026-08-05** `4d8b6d2e6db3` — 1 breaking, 1 warning, 2 info
  - added the pattern `^[A-Za-z_][A-Z0-9a-z_]*$` to the `path` request parameter `key`
  - for the `path` request parameter `key`, the maxLength was set to `8192`
  - api operation id `valEnvironmentVariablesCreate` removed and replaced with `valEnvironmentVariablesUpdate`
  - request property `description` list-of-types was widened by adding types `null` to media type `application/json`
- **2026-03-11** `dc1b3c9e3b2a` — 1 breaking
  - response property `updatedAt` list-of-types was widened by adding types `null` to media type `application/json` of response `201`
- **2025-10-30** `f039435c5e18` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/val-town/apis/val-town-api/changes/v2/vals/:val_id/environment_variables/:key/put.md)

---

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