Overview
Creates a single environment variable for a specific project and environment. When called from inside a task, theprojectRef and env arguments can be omitted and are inferred from the task’s runtime context.
To create or update multiple variables in one request, use the upload (bulk import) endpoint instead.
Endpoint
Path parameters
The project reference (e.g.
proj_yubjwjsfkxnylobaqvqz).The target environment:
dev, staging, prod, or preview.Request body
The name of the environment variable (e.g.
SLACK_API_KEY).The value to assign.
Response
true when the variable was created successfully.Examples
Response example
Related operations
| Operation | Endpoint |
|---|---|
| List variables | GET /api/v1/projects/{projectRef}/envvars/{env} |
| Retrieve variable | GET /api/v1/projects/{projectRef}/envvars/{env}/{name} |
| Update variable | PUT /api/v1/projects/{projectRef}/envvars/{env}/{name} |
| Delete variable | DELETE /api/v1/projects/{projectRef}/envvars/{env}/{name} |
| Bulk import | POST /api/v1/projects/{projectRef}/envvars/{env}/import |
Preview branches
To create a variable scoped to a specific preview branch, include thex-trigger-branch header or set previewBranch in the SDK configuration.
- SDK
- cURL