env_vars
Creates, updates, deletes, gets or lists an env_vars resource.
Overview
| Name | env_vars |
| Type | Resource |
| Id | vercel.projects.env_vars |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
id | string | |
configuration_id | string | (wire: configurationId) |
edge_config_id | string | (wire: edgeConfigId) |
edge_config_token_id | string | (wire: edgeConfigTokenId) |
sunset_secret_id | string | This is used to identify variables that have been migrated from type secret to sensitive. (wire: sunsetSecretId) |
comment | string | |
content_hint | | (wire: contentHint) |
created_at | number | (wire: createdAt) |
created_by | string | (wire: createdBy) |
custom_environment_ids | array | (wire: customEnvironmentIds) |
decrypted | boolean | (false, true) |
git_branch | string | (wire: gitBranch) |
internal_content_hint | object | Similar to contentHints, but should not be exposed to the user. (wire: internalContentHint) |
key | string | |
legacy_value | string | Legacy now-encryption ciphertext, present after migration swaps value/vsmValue (wire: legacyValue) |
target | | |
type | string | (encrypted, plain, secret, sensitive, system) |
updated_at | number | (wire: updatedAt) |
updated_by | string | (wire: updatedBy) |
value | string | |
visibility | string | User-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) |
The list of environment variables for the given project
| Name | Datatype | Description |
|---|---|---|
id | string | |
configuration_id | string | (wire: configurationId) |
edge_config_id | string | (wire: edgeConfigId) |
edge_config_token_id | string | (wire: edgeConfigTokenId) |
sunset_secret_id | string | This is used to identify variables that have been migrated from type secret to sensitive. (wire: sunsetSecretId) |
comment | string | |
content_hint | | (wire: contentHint) |
created_at | number | (wire: createdAt) |
created_by | string | (wire: createdBy) |
custom_environment_ids | array | (wire: customEnvironmentIds) |
decrypted | boolean | (false, true) |
git_branch | string | (wire: gitBranch) |
internal_content_hint | object | Similar to contentHints, but should not be exposed to the user. (wire: internalContentHint) |
key | string | |
legacy_value | string | Legacy now-encryption ciphertext, present after migration swaps value/vsmValue (wire: legacyValue) |
security_issues | array | (wire: securityIssues) |
system | boolean | (false, true) |
target | | |
type | string | (encrypted, plain, secret, sensitive, system) |
updated_at | number | (wire: updatedAt) |
updated_by | string | (wire: updatedBy) |
value | string | |
visibility | string | User-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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | id_or_name, id | team_id, slug | Retrieve the environment variable for a given project. |
list | select | id_or_name | git_branch, decrypt, source, custom_environment_id, custom_environment_slug, team_id, slug | Retrieve the environment variables for a given project by passing either the project id or name in the URL. |
create | insert | id_or_name, target | upsert, team_id, slug | 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. |
update | update | id_or_name, id | team_id, slug | 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. |
delete | delete | id_or_name, id | custom_environment_id, team_id, slug | 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. |
batch_delete | delete | id_or_name | team_id, slug | Delete 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.
| Name | Datatype | Description |
|---|---|---|
id | string | The unique environment variable identifier |
id_or_name | string | The unique project identifier or the project name |
custom_environment_id | string | The unique custom environment identifier within the project (wire: customEnvironmentId) |
custom_environment_slug | string | The custom environment slug (name) within the project (wire: customEnvironmentSlug) |
decrypt | string | If true, the environment variable value will be decrypted |
git_branch | string | If defined, the git branch of the environment variable to filter the results (must have target=preview) (wire: gitBranch) |
slug | string | The Team slug to perform the request on behalf of. |
source | string | The source that is calling the endpoint. |
team_id | string | The Team identifier to perform the request on behalf of. (wire: teamId) |
upsert | string | Allow override of environment variable if it already exists |
SELECT examples
- get
- list
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 }}'
;
Retrieve the environment variables for a given project by passing either the project id or name in the URL.
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,
security_issues,
system,
target,
type,
updated_at,
updated_by,
value,
visibility
FROM vercel.projects.env_vars
WHERE id_or_name = '{{ id_or_name }}' -- required
AND git_branch = '{{ git_branch }}'
AND decrypt = '{{ decrypt }}'
AND source = '{{ source }}'
AND custom_environment_id = '{{ custom_environment_id }}'
AND custom_environment_slug = '{{ custom_environment_slug }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: env_vars
props:
- name: id_or_name
value: "{{ id_or_name }}"
description: Required parameter for the env_vars resource.
- name: key
value: "{{ key }}"
description: |
The name of the environment variable
- name: value
value: "{{ value }}"
description: |
The value of the environment variable
- name: type
value: "{{ type }}"
description: |
The type of environment variable
valid_values: ['system', 'encrypted', 'plain', 'sensitive']
- name: target
value: "{{ target }}"
description: |
The target environment of the environment variable
- name: git_branch
value: "{{ git_branch }}"
description: |
If defined, the git branch of the environment variable (must have target=preview)
- name: comment
value: "{{ comment }}"
description: |
A comment to add context on what this environment variable is for
- name: custom_environment_ids
value:
- "{{ custom_environment_ids }}"
description: |
The custom environment IDs associated with the environment variable
- name: upsert
value: "{{ upsert }}"
description: Allow override of environment variable if it already exists
description: Allow override of environment variable if it already exists
- name: team_id
value: "{{ team_id }}"
description: The Team identifier to perform the request on behalf of.
description: The Team identifier to perform the request on behalf of.
- name: slug
value: "{{ slug }}"
description: The Team slug to perform the request on behalf of.
description: The Team slug to perform the request on behalf of.
UPDATE examples
- update
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
- batch_delete
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 }}'
;
Delete multiple environment variables for a given project in a single batch operation.
DELETE FROM vercel.projects.env_vars
WHERE id_or_name = '{{ id_or_name }}' --required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;