Skip to main content

env_vars

Creates, updates, deletes, gets or lists an env_vars resource.

Overview

Nameenv_vars
TypeResource
Idvercel.projects.env_vars

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstring
configuration_idstring (wire: configurationId)
edge_config_idstring (wire: edgeConfigId)
edge_config_token_idstring (wire: edgeConfigTokenId)
sunset_secret_idstringThis is used to identify variables that have been migrated from type secret to sensitive. (wire: sunsetSecretId)
commentstring
content_hint (wire: contentHint)
created_atnumber (wire: createdAt)
created_bystring (wire: createdBy)
custom_environment_idsarray (wire: customEnvironmentIds)
decryptedboolean (false, true)
git_branchstring (wire: gitBranch)
internal_content_hintobjectSimilar to contentHints, but should not be exposed to the user. (wire: internalContentHint)
keystring
legacy_valuestringLegacy now-encryption ciphertext, present after migration swaps value/vsmValue (wire: legacyValue)
target
typestring (encrypted, plain, secret, sensitive, system)
updated_atnumber (wire: updatedAt)
updated_bystring (wire: updatedBy)
valuestring
visibilitystringUser-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. (config, secret)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid_or_name, idteam_id, slugRetrieve the environment variable for a given project.
listselectid_or_namegit_branch, decrypt, source, custom_environment_id, custom_environment_slug, team_id, slugRetrieve the environment variables for a given project by passing either the project id or name in the URL.
createinsertid_or_name, targetupsert, team_id, slugCreate one or more environment variables for a project by passing its key, value, type and target and by specifying the project by either passing the project id or name in the URL. If you include upsert=true as a query parameter, a new environment variable will not be created if it already exists but, the existing variable's value will be updated.
updateupdateid_or_name, idteam_id, slugEdit 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.
deletedeleteid_or_name, idcustom_environment_id, team_id, slugDelete 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.
batch_deletedeleteid_or_nameteam_id, slugDelete multiple environment variables for a given project in a single batch operation.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
idstringThe unique environment variable identifier
id_or_namestringThe unique project identifier or the project name
custom_environment_idstringThe unique custom environment identifier within the project (wire: customEnvironmentId)
custom_environment_slugstringThe custom environment slug (name) within the project (wire: customEnvironmentSlug)
decryptstringIf true, the environment variable value will be decrypted
git_branchstringIf defined, the git branch of the environment variable to filter the results (must have target=preview) (wire: gitBranch)
slugstringThe Team slug to perform the request on behalf of.
sourcestringThe source that is calling the endpoint.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)
upsertstringAllow override of environment variable if it already exists

SELECT examples

Retrieve the environment variable for a given project.

SELECT
id,
configuration_id,
edge_config_id,
edge_config_token_id,
sunset_secret_id,
comment,
content_hint,
created_at,
created_by,
custom_environment_ids,
decrypted,
git_branch,
internal_content_hint,
key,
legacy_value,
target,
type,
updated_at,
updated_by,
value,
visibility
FROM vercel.projects.env_vars
WHERE id_or_name = '{{ id_or_name }}' -- required
AND id = '{{ id }}' -- required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

INSERT examples

Create one or more environment variables for a project by passing its key, value, type and target and by specifying the project by either passing the project id or name in the URL. If you include upsert=true as a query parameter, a new environment variable will not be created if it already exists but, the existing variable's value will be updated.

INSERT INTO vercel.projects.env_vars (
key,
value,
type,
target,
git_branch,
comment,
custom_environment_ids,
id_or_name,
upsert,
team_id,
slug
)
SELECT
'{{ key }}',
'{{ value }}',
'{{ type }}',
'{{ target }}' /* required */,
'{{ git_branch }}',
'{{ comment }}',
'{{ custom_environment_ids }}',
'{{ id_or_name }}',
'{{ upsert }}',
'{{ team_id }}',
'{{ slug }}'
RETURNING
created,
failed
;

UPDATE examples

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.

UPDATE vercel.projects.env_vars
SET
key = '{{ key }}',
target = '{{ target }}',
git_branch = '{{ git_branch }}',
type = '{{ type }}',
value = '{{ value }}',
custom_environment_ids = '{{ custom_environment_ids }}',
comment = '{{ comment }}'
WHERE
id_or_name = '{{ id_or_name }}' --required
AND id = '{{ id }}' --required
AND team_id = '{{ team_id}}'
AND slug = '{{ slug}}'
RETURNING
id,
configuration_id,
edge_config_id,
edge_config_token_id,
sunset_secret_id,
comment,
content_hint,
created_at,
created_by,
custom_environment_ids,
decrypted,
git_branch,
internal_content_hint,
key,
legacy_value,
target,
type,
updated_at,
updated_by,
value,
visibility;

DELETE examples

Delete 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.

DELETE FROM vercel.projects.env_vars
WHERE id_or_name = '{{ id_or_name }}' --required
AND id = '{{ id }}' --required
AND custom_environment_id = '{{ custom_environment_id }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;