import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.environment.updateSharedEnvVariable({
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
updates: {
"env_2WjyKQmM8ZnGcJsPWMrHRHrE": {
key: "API_URL",
value: "https://api.vercel.com",
target: [
"production",
"preview",
],
projectIdUpdates: {
link: [
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
],
},
},
},
},
});
console.log(result);
}
run();{
"updated": [
{
"created": "2021-02-10T13:11:49.180Z",
"key": "my-api-key",
"ownerId": "team_LLHUOMOoDlqOp8wPE4kFo9pE",
"id": "env_XCG7t7AIHuO2SBA8667zNUiM",
"createdBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"deletedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"updatedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"createdAt": 1609492210000,
"deletedAt": 1609492210000,
"updatedAt": 1609492210000,
"value": "<string>",
"projectId": [
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
"prj_2WjyKQmM8ZnGcJsPWMrasEFg"
],
"type": "encrypted",
"target": "production",
"applyToAllCustomEnvironments": true,
"decrypted": true,
"comment": "<string>",
"lastEditedByDisplayName": "<string>"
}
],
"failed": [
{
"error": {
"code": "<string>",
"message": "<string>",
"key": "<string>",
"envVarId": "<string>",
"envVarKey": "<string>",
"action": "<string>",
"link": "<string>",
"value": "<string>",
"gitBranch": "<string>",
"target": [
"production"
],
"project": "<string>"
}
}
]
}Updates a given Shared Environment Variable for a Team.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.environment.updateSharedEnvVariable({
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
updates: {
"env_2WjyKQmM8ZnGcJsPWMrHRHrE": {
key: "API_URL",
value: "https://api.vercel.com",
target: [
"production",
"preview",
],
projectIdUpdates: {
link: [
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
],
},
},
},
},
});
console.log(result);
}
run();{
"updated": [
{
"created": "2021-02-10T13:11:49.180Z",
"key": "my-api-key",
"ownerId": "team_LLHUOMOoDlqOp8wPE4kFo9pE",
"id": "env_XCG7t7AIHuO2SBA8667zNUiM",
"createdBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"deletedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"updatedBy": "2qDDuGFTWXBLDNnqZfWPDp1A",
"createdAt": 1609492210000,
"deletedAt": 1609492210000,
"updatedAt": 1609492210000,
"value": "<string>",
"projectId": [
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
"prj_2WjyKQmM8ZnGcJsPWMrasEFg"
],
"type": "encrypted",
"target": "production",
"applyToAllCustomEnvironments": true,
"decrypted": true,
"comment": "<string>",
"lastEditedByDisplayName": "<string>"
}
],
"failed": [
{
"error": {
"code": "<string>",
"message": "<string>",
"key": "<string>",
"envVarId": "<string>",
"envVarKey": "<string>",
"action": "<string>",
"link": "<string>",
"value": "<string>",
"gitBranch": "<string>",
"target": [
"production"
],
"project": "<string>"
}
}
]
}Default authentication mechanism
The Team identifier to perform the request on behalf of.
"team_1a2b3c4d5e6f7g8h9i0j1k2l"
The Team slug to perform the request on behalf of.
"my-team-url-slug"
An object where each key is an environment variable ID (not the key name) and the value is the update to apply
Show child attributes
Show child attributes
The name of the Shared Environment Variable
"API_URL"
The value of the Shared Environment Variable
"https://api.vercel.com"
The target environment of the Shared Environment Variable
production, preview, development ["production", "preview"]Associate a Shared Environment Variable to projects.
[
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
"prj_2WjyKQmM8ZnGcJsPWMrHRCRV"
]Incrementally update project linking without specifying the full list
The new type of the Shared Environment Variable
encrypted, sensitive "encrypted"
A comment to add context on what this Shared Environment Variable is for
500"database connection string for production"
{
"env_2WjyKQmM8ZnGcJsPWMrHRHrE": {
"key": "API_URL",
"value": "https://api.vercel.com",
"target": ["production", "preview"],
"projectIdUpdates": { "link": ["prj_2WjyKQmM8ZnGcJsPWMrHRHrE"] }
}
}Show child attributes
The date when the Shared Env Var was created.
"2021-02-10T13:11:49.180Z"
The name of the Shared Env Var.
"my-api-key"
The unique identifier of the owner (team) the Shared Env Var was created for.
"team_LLHUOMOoDlqOp8wPE4kFo9pE"
The unique identifier of the Shared Env Var.
"env_XCG7t7AIHuO2SBA8667zNUiM"
The unique identifier of the user who created the Shared Env Var.
"2qDDuGFTWXBLDNnqZfWPDp1A"
The unique identifier of the user who deleted the Shared Env Var.
"2qDDuGFTWXBLDNnqZfWPDp1A"
The unique identifier of the user who last updated the Shared Env Var.
"2qDDuGFTWXBLDNnqZfWPDp1A"
Timestamp for when the Shared Env Var was created.
1609492210000
Timestamp for when the Shared Env Var was (soft) deleted.
1609492210000
Timestamp for when the Shared Env Var was last updated.
1609492210000
The value of the Shared Env Var.
The unique identifiers of the projects which the Shared Env Var is linked to.
[
"prj_2WjyKQmM8ZnGcJsPWMrHRHrE",
"prj_2WjyKQmM8ZnGcJsPWMrasEFg"
]The type of this cosmos doc instance, if blank, assume secret.
encrypted, sensitive, system, plain "encrypted"
environments this env variable targets
environments this env variable targets
production, preview, development "production"
whether or not this env varible applies to custom environments
whether or not this env variable is decrypted
A user provided comment that describes what this Shared Env Var is for.
The last editor full name or username.
Show child attributes
Show child attributes
production, preview, development, preview, development