Environment Variables
Environment variables let you store configuration values like API keys, database URLs, and feature flags for your project. They are encrypted at rest and injected into the workspace when it starts.How It Works
- You set environment variables on a project
- When a workspace starts, the variables are written to a
.envfile in the project directory - Your application and the agent can read them from the environment
Setting Variables
- Web
- CLI
Go to your project’s Settings > Environment Variables. Enter the key and value, then click Save.
Listing Variables
Getting a Variable
Deleting Variables
Importing from a File
You can import variables in bulk from a.env file:
.env format:
Importing merges with existing variables. If a key already exists, its value is updated. Existing keys not in the file are left unchanged.
API Endpoints
For programmatic access, environment variables are available through the REST API:| Method | Endpoint | Description |
|---|---|---|
GET | /projects/{id}/env-vars | List all variable keys |
GET | /projects/{id}/env-vars/{key} | Get a variable’s value |
PUT | /projects/{id}/env-vars/{key} | Set or update a variable |
DELETE | /projects/{id}/env-vars/{key} | Delete a variable |
POST | /projects/{id}/env-vars/import | Import from .env format |
Workspace Injection
When a workspace starts, all project environment variables are written to the.env file in the project’s working directory. This means:
- Frameworks like Next.js, Vite, and Express automatically pick them up
- The agent can reference them in code and configuration
- Restarting the workspace refreshes the values from the latest project settings
If you update an environment variable while a workspace is running, the change takes effect on the next workspace restart. The
.env file is only written during workspace startup.