Skip to content
Docs

Create one or more shared environment variables

POSThttps://api.vercel.com/v1/env
Creates shared environment variable(s) for a team.
https://api.vercel.com/v1/env
const response = await fetch('https://api.vercel.com/v1/env?teamId=string&slug=string', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"evs": [
{
"key": "API_URL",
"value": "https://api.vercel.com",
"comment": "database connection string for production"
}
],
"type": "encrypted",
"target": [],
"projectId": []
}),
});
const data = await response.json();
console.log(data);
Response
{
"created": [
{
"applyToAllCustomEnvironments": "false",
"comment": "string",
"created": "2021-02-10T13:11:49.180Z",
"createdAt": "1609492210000",
"createdBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"customEnvironmentIds": [],
"decrypted": "false",
"deletedAt": "1609492210000",
"deletedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"id": "env_XCG7t7AIHuO2SBA8667zNUiM",
"key": "my-api-key",
"lastEditedByDisplayName": "Example Name",
"lastEditedByPrincipal": {
"avatar": "string",
"id": "icfg_1234567890",
"name": "Example Name",
"type": "user",
"username": "string"
},
"ownerId": "team_LLHUOMOoDlqOp8wPE4kFo9pE",
"projectId": [],
"target": [],
"type": "encrypted",
"updatedAt": "1609492210000",
"updatedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"value": "string"
}
],
"failed": [
{
"error": {
"action": "string",
"code": "string",
"envVarId": "example_id",
"envVarKey": "string",
"gitBranch": "string",
"key": "string",
"link": "string",
"message": "string",
"project": "string",
"target": [],
"value": "string"
}
}
]
}
AuthorizationbearerToken

Default authentication mechanism

teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
evsarrayRequired
typestringOptional
The type of environment variable
targetarrayRequired
The target environment of the Shared Environment Variable
projectIdarrayOptionalDeprecated
Associate a Shared Environment Variable to projects.
201Success
createdarrayRequired
failedarrayRequired
400One of the provided values in the request body is invalid.
401The request is not authorized.
402The account is missing a payment so payment method must be updated
403You do not have permission to access this resource.
404Error
410Error