PATCH
/
v9
/
projects
/
{idOrName}
/
env
/
{id}
editProjectEnv
import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.projects.editProjectEnv({
    idOrName: "prj_XLKmu1DyR1eY7zq8UgeRKbA7yVLA",
    id: "XMbOEya1gUUO1ir4",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      key: "GITHUB_APP_ID",
      target: [
        "preview",
      ],
      gitBranch: "feature-1",
      type: "plain",
      value: "bkWIjbnxcvo78",
      customEnvironmentIds: [
        "env_1234567890",
      ],
      comment: "database connection string for production",
    },
  });

  console.log(result);
}

run();
{
  "target": [
    "<string>"
  ],
  "type": "system",
  "sunsetSecretId": "<string>",
  "decrypted": true,
  "value": "<string>",
  "id": "<string>",
  "key": "<string>",
  "configurationId": "<string>",
  "createdAt": 123,
  "updatedAt": 123,
  "createdBy": "<string>",
  "updatedBy": "<string>",
  "gitBranch": "<string>",
  "edgeConfigId": "<string>",
  "edgeConfigTokenId": "<string>",
  "contentHint": {
    "type": "redis-url",
    "storeId": "<string>"
  },
  "internalContentHint": {
    "type": "flags-secret",
    "encryptedValue": "<string>"
  },
  "comment": "<string>",
  "customEnvironmentIds": [
    "<string>"
  ]
}

Authorizations

Authorization
string
header
required

Default authentication mechanism

Path Parameters

idOrName
string
required

The unique project identifier or the project name

Example:

"prj_XLKmu1DyR1eY7zq8UgeRKbA7yVLA"

id
string
required

The unique environment variable identifier

Example:

"XMbOEya1gUUO1ir4"

Query Parameters

teamId
string

The Team identifier to perform the request on behalf of.

Example:

"team_1a2b3c4d5e6f7g8h9i0j1k2l"

slug
string

The Team slug to perform the request on behalf of.

Example:

"my-team-url-slug"

Body

application/json
key
string

The name of the environment variable

Example:

"GITHUB_APP_ID"

target
enum<string>[]

The target environment of the environment variable

Example:
["preview"]
gitBranch
string | null

If defined, the git branch of the environment variable (must have target=preview)

Maximum length: 250
Example:

"feature-1"

type
enum<string>

The type of environment variable

Available options:
system,
secret,
encrypted,
plain,
sensitive
Example:

"plain"

value
string

The value of the environment variable

Example:

"bkWIjbnxcvo78"

customEnvironmentIds
string[]

The custom environments that the environment variable should be synced to

comment
string

A comment to add context on what this env var is for

Maximum length: 500
Example:

"database connection string for production"

Response

The environment variable was successfully edited

type
enum<string>
required
Available options:
system,
secret,
encrypted,
plain,
sensitive
value
string
required
key
string
required
target
sunsetSecretId
string

This is used to identiy variables that have been migrated from type secret to sensitive.

decrypted
boolean
id
string
configurationId
string | null
createdAt
number
updatedAt
number
createdBy
string | null
updatedBy
string | null
gitBranch
string
edgeConfigId
string | null
edgeConfigTokenId
string | null
contentHint
object
internalContentHint
object | null

Similar to contentHints, but should not be exposed to the user.

comment
string
customEnvironmentIds
string[]