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

  1. Open your project in the dashboard
  2. Click Environment Variables in the sidebar
  3. Click Add Variable
  4. Enter the key and value
  5. Select which environments this variable applies to (e.g. production, staging, or all)
  6. 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.


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:

KeyProductionStaging
API_URLhttps://api.yourapp.comhttps://api-staging.yourapp.com
LOG_LEVELwarndebug
ENABLE_DEBUG(not set)true

To set a variable for a specific environment:

  1. When adding or editing a variable, select only the environments you want it applied to
  2. 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:

  1. Go to Environment Variables in your project
  2. Find the variable you want to adjust
  3. 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

VariableValueDescription
HOST0.0.0.0Bind address for the application
PORTDetected from Dockerfile/config or 3000The port your application should listen on
TEMPS_API_URLhttps://your-temps-instance/apiTemps API endpoint (for SDK callbacks)
TEMPS_API_TOKENAuto-generatedA per-environment deployment token for API access

When managed services are linked

VariableSource
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

VariableValue
SENTRY_DSNYour project's error tracking DSN
NEXT_PUBLIC_SENTRY_DSNSame DSN (for Next.js client-side)
VITE_PUBLIC_SENTRY_DSNSame DSN (for Vite client-side)
SENTRY_RELEASEThe deployment commit SHA

When OpenTelemetry is enabled

VariableDescription
OTEL_EXPORTER_OTLP_ENDPOINTTemps OTLP endpoint
OTEL_EXPORTER_OTLP_PROTOCOLProtocol (e.g. http/protobuf)
OTEL_EXPORTER_OTLP_HEADERSAuthentication headers
OTEL_SERVICE_NAMEService name for tracing
OTEL_SERVICE_VERSIONService version (from commit)

Port resolution order

Temps determines the PORT value in this order of priority:

  1. EXPOSE directive in your Dockerfile
  2. exposed_port setting on the environment
  3. exposed_port setting on the project
  4. 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:

KeyValue
DATABASE_URL$POSTGRES_URL

The interpolation happens at deploy time. The deployed container receives the fully expanded value.

Was this page helpful?