Skip to content
Docs

Edit an environment variable

PATCH/__remote/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.
/__remote/api.vercel.com/v9/projects/{idOrName}/env/{id}
const response = await fetch('/__remote/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
{
"comment": "string",
"configurationId": "example_id",
"contentHint": {
"storeId": "example_id",
"type": "redis-url"
},
"createdAt": "123",
"createdBy": "string",
"customEnvironmentIds": [],
"decrypted": "false",
"edgeConfigId": "example_id",
"edgeConfigTokenId": "example_id",
"gitBranch": "string",
"id": "icfg_1234567890",
"internalContentHint": {
"encryptedValue": "string",
"type": "flags-secret"
},
"key": "string",
"legacyValue": "string",
"sunsetSecretId": "example_id",
"target": [],
"type": "encrypted",
"updatedAt": "123",
"updatedBy": "string",
"value": "string",
"visibility": "config"
}
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
commentstringOptional
configurationIdstringOptional
contentHintobjectOptional17 variants
createdAtnumberOptional
createdBystringOptional
customEnvironmentIdsarrayOptional
decryptedbooleanOptional
edgeConfigIdstringOptional
edgeConfigTokenIdstringOptional
gitBranchstringOptional
idstringOptional
internalContentHintobjectOptional
Similar to contentHints, but should not be exposed to the user.
keystringRequired
legacyValuestringOptional
Legacy now-encryption ciphertext, present after migration swaps value/vsmValue
sunsetSecretIdstringOptional
This is used to identify variables that have been migrated from type secret to sensitive.
targetobjectOptional2 variants
typestringRequired
updatedAtnumberOptional
updatedBystringOptional
valuestringRequired
visibilitystringOptional
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.
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