Skip to content
Docs

Edit an environment variable

PATCHhttps://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

idOrNamestringRequired
The unique project identifier or the project name
idstringRequired
The unique environment variable identifier
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
keystringOptional
The name of the environment variable
targetarrayOptional
The target environment of the environment variable
gitBranchstringOptional
If defined, the git branch of the environment variable (must have target=preview)
typestringOptional
The type of environment variable
valuestringOptional
The value of the environment variable
customEnvironmentIdsarrayOptional
The custom environments that the environment variable should be synced to
commentstringOptional
A comment to add context on what this env var is for
200Success
typestringRequired
valuestringRequired
edgeConfigIdstringOptional
edgeConfigTokenIdstringOptional
createdAtnumberOptional
updatedAtnumberOptional
idstringOptional
keystringRequired
targetobjectOptional2 variants
gitBranchstringOptional
createdBystringOptional
updatedBystringOptional
sunsetSecretIdstringOptional
This is used to identify variables that have been migrated from type secret to sensitive.
legacyValuestringOptional
Legacy now-encryption ciphertext, present after migration swaps value/vsmValue
decryptedbooleanOptional
configurationIdstringOptional
visibilitystringOptional
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.
contentHintobjectOptional17 variants
internalContentHintobjectOptional
Similar to contentHints, but should not be exposed to the user.
commentstringOptional
customEnvironmentIdsarrayOptional
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