Skip to content

Variables

Variables are how you pass configuration and secrets into a service. They are available during the build and in the running container.

Changing a variable stages a config update. Deploy (or the automatic rolling deploy when you save from the service sheet) applies it.

Open a service on the canvas → Variables. Add a key and value, or paste a .env file.

Use plaintext for flags and URLs. Mark secrets (API keys, passwords) so they are encrypted at rest and redacted in the UI and build logs.

examples
NODE_ENV=production
LOG_LEVEL=info
DATABASE_URL=postgresql://…

In your app, read them as environment variables (process.env.DATABASE_URL, os.environ["DATABASE_URL"], and so on).

When you add a database on the same canvas, do not paste the URL by hand. In stackblaze.yaml use fromDatabase:

Variables from a database fromDatabase injects the live connection string postgres canvas database tile connectionString fromDatabase name: postgres property: connectionString in stackblaze.yaml api service DATABASE_URL injected at build and runtime Production own connection string for this environment Preview own string · not copied from production prefer fromDatabase over pasting a URL · values are scoped per environment
stackblaze.yaml
envVars:
- key: DATABASE_URL
fromDatabase:
name: postgres
property: connectionString
- key: REDIS_URL
fromDatabase:
name: cache
property: connectionString

The platform injects the live connection string for that environment. See Config as Code.

In config as code, fromGroup attaches a named group of variables to a service so you are not copying the same keys onto every tile. Prefer groups or fromDatabase over duplicating secrets.

Variables are scoped to the environment you are viewing (production, a custom environment, or a PR preview). Production values are not automatically copied into previews — preview databases get their own connection strings.

Variables live on the service spec. Create a kbr_pat_ token, then read or update the service:

terminal
export STACKBLAZE_TOKEN=kbr_pat_
curl -sS https://api.stackblaze.cloud/api/apps/acme-app/production/api \
-H "Authorization: Bearer $STACKBLAZE_TOKEN"

From the CLI: stackblaze variables list / set / delete. See the CLI and the API reference.