Manage Environment Variables
Environment variables let you pass configuration to your application without hardcoding values. Temps lets you scope variables to specific environments, control their visibility in previews, and automatically injects variables for linked services.
Add a variable
- Open your project in the dashboard
- Click Environment Variables in the sidebar
- Click Add Variable
- Enter the key and value
- Select which environments this variable applies to (e.g. production, staging, or all)
- Click Save
The variable takes effect on the next deployment. Existing running containers are not updated — you need to redeploy for changes to take effect.
Sensitive values: Environment variables are stored in the database. For secrets like API keys and database passwords, use Temps' managed services where possible — they handle credential generation and injection automatically. For other secrets, consider that anyone with dashboard access to your project can view these values.
Scope variables to environments
Each variable can be assigned to one or more environments. This is how you use different configurations across production, staging, and development.
Common pattern:
| Key | Production | Staging |
|---|---|---|
API_URL | https://api.yourapp.com | https://api-staging.yourapp.com |
LOG_LEVEL | warn | debug |
ENABLE_DEBUG | (not set) | true |
To set a variable for a specific environment:
- When adding or editing a variable, select only the environments you want it applied to
- Create separate variables with the same key but different values for different environments
If the same key exists for multiple environments, each environment gets its own value. There is no inheritance — a variable scoped to production does not automatically appear in staging.
Preview environment controls
Each variable has an Include in Preview toggle. When disabled, the variable is not injected into preview environments.
Use this to:
- Keep production API keys out of preview branches
- Exclude payment processor credentials from temporary environments
- Control feature flags per environment type
To change this setting:
- Go to Environment Variables in your project
- Find the variable you want to adjust
- Toggle Include in Preview on or off
Variables from linked managed services (like POSTGRES_URL) are always included in all environments, including previews. Each preview gets its own isolated database.
Auto-injected variables
Temps automatically injects several variables at deploy time. You do not need to set these manually.
Always injected
| Variable | Value | Description |
|---|---|---|
HOST | 0.0.0.0 | Bind address for the application |
PORT | Detected from Dockerfile/config or 3000 | The port your application should listen on |
TEMPS_API_URL | https://your-temps-instance/api | Temps API endpoint (for SDK callbacks) |
TEMPS_API_TOKEN | Auto-generated | A per-environment deployment token for API access |
When managed services are linked
| Variable | Source |
|---|---|
POSTGRES_URL, POSTGRES_HOST, etc. | Linked PostgreSQL service |
REDIS_URL, REDIS_HOST, etc. | Linked Redis service |
MONGODB_URL, MONGODB_HOST, etc. | Linked MongoDB service |
S3_BUCKET, S3_ENDPOINT, etc. | Linked S3/RustFS service |
See Deploy with a Database for the full list.
When error tracking is configured
| Variable | Value |
|---|---|
SENTRY_DSN | Your project's error tracking DSN |
NEXT_PUBLIC_SENTRY_DSN | Same DSN (for Next.js client-side) |
VITE_PUBLIC_SENTRY_DSN | Same DSN (for Vite client-side) |
SENTRY_RELEASE | The deployment commit SHA |
When OpenTelemetry is enabled
| Variable | Description |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | Temps OTLP endpoint |
OTEL_EXPORTER_OTLP_PROTOCOL | Protocol (e.g. http/protobuf) |
OTEL_EXPORTER_OTLP_HEADERS | Authentication headers |
OTEL_SERVICE_NAME | Service name for tracing |
OTEL_SERVICE_VERSION | Service version (from commit) |
Port resolution order
Temps determines the PORT value in this order of priority:
EXPOSEdirective in your Dockerfileexposed_portsetting on the environmentexposed_portsetting on the project- Default:
3000
Use the API
List variables
curl "https://your-temps-instance/api/projects/{project_id}/env-vars?environment_id={env_id}" \
-H "Authorization: Bearer YOUR_TOKEN"
Create a variable
curl -X POST "https://your-temps-instance/api/projects/{project_id}/env-vars" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key": "API_KEY",
"value": "your-api-key",
"environment_ids": [1, 2],
"include_in_preview": false
}'
Update a variable
curl -X PUT "https://your-temps-instance/api/projects/{project_id}/env-vars/{var_id}" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key": "API_KEY",
"value": "new-value",
"environment_ids": [1, 2],
"include_in_preview": false
}'
Delete a variable
curl -X DELETE "https://your-temps-instance/api/projects/{project_id}/env-vars/{var_id}" \
-H "Authorization: Bearer YOUR_TOKEN"
Get a single value
curl "https://your-temps-instance/api/projects/{project_id}/env-vars/{key}/value" \
-H "Authorization: Bearer YOUR_TOKEN"
Variable interpolation
You can reference other variables using $VARIABLE_NAME syntax. This is useful for composing values from auto-injected variables.
Common use case — creating a DATABASE_URL alias for frameworks that expect it:
| Key | Value |
|---|---|
DATABASE_URL | $POSTGRES_URL |
The interpolation happens at deploy time. The deployed container receives the fully expanded value.