Skip to content

Set an environment variable

PUT/v1/deployments/{uid}/env-vars

Creates the variable, or replaces its value if a variable with the same key exists. The value is stored encrypted. Every variable is available both at build time and at runtime.

Changes are staged: the running app keeps its old environment until the next deploy, and Get a deployment reports env_changes_pending: true until then. Apply them with Deploy a deployment.

Requires a workspace role that can manage secrets.

Authentication

Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.

Path parameters

uidstringRequired

The deployment's uid.

Headers

X-Workspace-SlugstringRequired

Slug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.

Request body

keystringRequired

Variable name. Starts with a letter or underscore, then letters, digits and underscores, up to 128 characters.

valuestringRequired

Variable value. Must not be empty. Trailing newlines are removed (surrounding whitespace is trimmed for env_vars on create).

scopestring

Kept for older clients. Every variable is available at build time and at runtime whatever you send, and it is stored as build.

One ofbuildruntimeboth

is_secretboolean

Marks the value as secret.

Default true

Response

200

The saved variable, without its value.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
uidstringRequired

Unique identifier of the variable.

keystringRequired

Variable name.

scopestringRequired

Always build. Every variable is available at build time and at runtime.

is_secretbooleanRequired

Whether the value is marked secret.

masked_valuestringRequired

Always ••••••••. The value is never returned here.

created_atstring (date-time)Required

When the variable was created.

updated_atstring (date-time)Required

When it was last changed.

Errors

StatusMeaning
400invalid request (missing key or value), key must start with a letter or underscore and contain only letters, numbers, and underscores, scope must be runtime or build, or value is required.
401The API key is missing, invalid, expired or revoked.
403You cannot access the workspace, your role does not allow this action, or the account is suspended.
404The resource does not exist or you cannot access it.

Errors use the standard error format.