Edit an environment variable
PATCH
https://api.vercel.com/v9/projects/{idOrName}/env/{id}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.https://api.vercel.com/v9/projects/{idOrName}/env/{id}
const response = await fetch('https://api.vercel.com/v9/projects/idOrName/env/id?teamId=string&slug=string', { method: 'PATCH', headers: { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json', }, body: JSON.stringify({ "key": "GITHUB_APP_ID", "target": [], "gitBranch": "feature-1", "type": "plain", "value": "bkWIjbnxcvo78", "customEnvironmentIds": [], "comment": "database connection string for production" }),});
const data = await response.json();console.log(data);Response
{ "type": "encrypted", "value": "string", "edgeConfigId": "example_id", "edgeConfigTokenId": "example_id", "createdAt": "123", "updatedAt": "123", "id": "icfg_1234567890", "key": "string", "target": [], "gitBranch": "string", "createdBy": "string", "updatedBy": "string", "sunsetSecretId": "example_id", "legacyValue": "string", "decrypted": "false", "configurationId": "example_id", "visibility": "config", "contentHint": { "type": "redis-url", "storeId": "example_id" }, "internalContentHint": { "type": "flags-secret", "encryptedValue": "string" }, "comment": "string", "customEnvironmentIds": []}AuthorizationbearerToken
Default authentication mechanism
application/json
If defined, the git branch of the environment variable (must have target=preview)
The custom environments that the environment variable should be synced to
200Success
This is used to identify variables that have been migrated from type secret to sensitive.
Legacy now-encryption ciphertext, present after migration swaps value/vsmValue
User-facing config/secret model. When set, authoritative for new code paths when the env-var-config-secret-ui flag is enabled. Legacy rows omit this field; legacy rows omit it and callers fall back to existing
type behavior.400One 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
401The request is not authorized.
403You do not have permission to access this resource.
404Error
409The project is being transfered and removing an environment variable is not possible
410Error
429Error
500Error