---
title: "Edit an environment variable"
method: PATCH
path: "/v9/projects/{idOrName}/env/{id}"
tags: ["projects"]
---

# Edit an environment variable

`PATCH /v9/projects/{idOrName}/env/{id}`

## Request

- Base URL: `https://api.vercel.com`
- URL: `https://api.vercel.com/v9/projects/{idOrName}/env/{id}`
- Auth: HTTP bearer

Edit a specific environment variable for a given project by passing the environment variable identifier and either passing the project `id` or `name` in the URL.

## Path parameters

- `idOrName` string, required: The unique project identifier or the project name
- `id` string, required: The unique environment variable identifier

## Query parameters

- `teamId` string
- `slug` string

## Request body

- object
  - `key` string: The name of the environment variable
  - `target` string[]: The target environment of the environment variable
  - `gitBranch` string, nullable: If defined, the git branch of the environment variable (must have target=preview)
  - `type` 'system' | 'encrypted' | 'plain' | 'sensitive': The type of environment variable
  - `value` string: The value of the environment variable
  - `customEnvironmentIds` string[]: The custom environments that the environment variable should be synced to
  - `comment` string: A comment to add context on what this env var is for

## Response `200`

- object, nullable
  - `comment` string
  - `configurationId` string, nullable
  - `contentHint` union
    - object
      - `storeId` string, required
      - `type` 'redis-url', required
    - object
      - `storeId` string, required
      - `type` 'redis-rest-api-url', required
    - object
      - `storeId` string, required
      - `type` 'redis-rest-api-token', required
    - object
      - `storeId` string, required
      - `type` 'redis-rest-api-read-only-token', required
    - object
      - `storeId` string, required
      - `type` 'blob-read-write-token', required
    - object
      - `storeId` string, required
      - `type` 'blob-store-id', required
    - object
      - `storeId` string, required
      - `type` 'blob-webhook-public-key', required
    - object
      - `storeId` string, required
      - `type` 'postgres-url', required
    - object
      - `storeId` string, required
      - `type` 'postgres-url-non-pooling', required
    - object
      - `storeId` string, required
      - `type` 'postgres-prisma-url', required
    - object
      - `storeId` string, required
      - `type` 'postgres-user', required
    - object
      - `storeId` string, required
      - `type` 'postgres-host', required
    - object
      - `storeId` string, required
      - `type` 'postgres-password', required
    - object
      - `storeId` string, required
      - `type` 'postgres-database', required
    - object
      - `storeId` string, required
      - `type` 'postgres-url-no-ssl', required
    - object
      - `integrationConfigurationId` string, required
      - `integrationId` string, required
      - `integrationProductId` string, required
      - `storeId` string, required
      - `type` 'integration-store-secret', required
    - object
      - `projectId` string, required
      - `type` 'flags-connection-string', required
  - `createdAt` number
  - `createdBy` string, nullable
  - `customEnvironmentIds` string[]
  - `decrypted` false | true
  - `edgeConfigId` string, nullable
  - `edgeConfigTokenId` string, nullable
  - `gitBranch` string
  - `id` string
  - `internalContentHint` object, nullable: Similar to `contentHints`, but should not be exposed to the user.
    - `encryptedValue` string, required: Contains the `value` of the env variable, encrypted with a special key to make decryption possible in the subscriber Lambda.
    - `type` 'flags-secret', required
  - `key` string, required
  - `legacyValue` string: Legacy now-encryption ciphertext, present after migration swaps value/vsmValue
  - `sunsetSecretId` string: This is used to identify variables that have been migrated from type secret to sensitive.
  - `target` union
    - string[]
    - 'development' | 'development' | 'preview' | 'preview' | 'production'
  - `type` 'encrypted' | 'plain' | 'secret' | 'sensitive' | 'system', required
  - `updatedAt` number
  - `updatedBy` string, nullable
  - `value` string, required
  - `visibility` 'config' | 'secret': User-facing config/secret model. When set, authoritative for new code paths. Legacy rows omit this field and callers fall back to existing `type` behavior.

## Other responses

- `400`: One of the provided values in the request body is invalid. One of the provided values in the request query is invalid. At least one environment variable failed validation
- `401`: The request is not authorized.
- `403`: You do not have permission to access this resource.
- `404`
- `409`: The project is being transfered and removing an environment variable is not possible
- `410`
- `429`
- `500`

## Changes

- **2026-07-26** `01c71864fa50`: 1 info
  - added the optional property `visibility` to the response with the `200` status
- **2026-07-21** `2ae10ee9d21c`: 1 info
  - added the non-success response with the status `410`
- **2026-06-11** `14b4658f819e`: 2 breaking
  - removed the enum value `secret` of the request property `type`
  - added `subschema #6, subschema #7` to the `contentHint` response property `oneOf` list for the response status `200`
- **2026-01-22** `c12186034433`: 3 breaking, 21 info
  - request body became required
  - the response's body became nullable
  - the response's body type changed from no type to `object` for status `200`
  - removed `subschema #1, subschema #2` from the response body `oneOf` list for the response status `200`
  - …20 more
- **2025-10-09** `50caddad4ae7`: 3 info
  - added the non-success response with the status `404`
  - added the non-success response with the status `429`
  - added the non-success response with the status `500`

[Operation history](https://skmtc.dev/vercel/apis/vercel-api/changes/v9/projects/:idOrName/env/:id/patch.md)

---

[API](https://skmtc.dev/vercel/apis/vercel-api.md) - [All operations](https://skmtc.dev/vercel/apis/vercel-api/llms.txt) - [OpenAPI document](https://skmtc.dev/vercel/apis/vercel-api/revisions/60686c0e1f6a?raw)
