projects

Edit an environment variable

Changed on

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.

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

Path parameters

idOrNamestring required

The unique project identifier or the project name

Example:prj_XLKmu1DyR1eY7zq8UgeRKbA7yVLA
idstring required

The unique environment variable identifier

Example:XMbOEya1gUUO1ir4

Query parameters

teamIdstring
Example:team_1a2b3c4d5e6f7g8h9i0j1k2l

The Team identifier to perform the request on behalf of.

slugstring
Example:my-team-url-slug

The Team slug to perform the request on behalf of.

Request body

keystring

The name of the environment variable

targetstring[]

The target environment of the environment variable

gitBranchstring nullable

If defined, the git branch of the environment variable (must have target=preview)

type'system' | 'encrypted' | 'plain' | 'sensitive'

The type of environment variable

valuestring

The value of the environment variable

customEnvironmentIdsstring[]

The custom environments that the environment variable should be synced to

commentstring

A comment to add context on what this env var is for

Example request

{
  "key": "GITHUB_APP_ID",
  "target": [
    "preview"
  ],
  "gitBranch": "feature-1",
  "type": "plain",
  "value": "bkWIjbnxcvo78",
  "customEnvironmentIds": [
    "env_1234567890"
  ],
  "comment": "database connection string for production"
}

Response

commentstring
configurationIdstring nullable
createdAtnumber
createdBystring nullable
customEnvironmentIdsstring[]
decryptedfalse | true
edgeConfigIdstring nullable
edgeConfigTokenIdstring nullable
gitBranchstring
idstring
keystring required
legacyValuestring

Legacy now-encryption ciphertext, present after migration swaps value/vsmValue

sunsetSecretIdstring

This is used to identify variables that have been migrated from type secret to sensitive.

type'encrypted' | 'plain' | 'secret' | 'sensitive' | 'system' required
updatedAtnumber
updatedBystring nullable
valuestring 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.

Changes