Environment variables

Every variable a hosted app runs under, who sets it, what it means; the CLI's own variables; the reserved names.

Open in CursorView as Markdown

This page lists every variable a hosted app's deployment carries, what each means and who sets it. It teaches two rules: the platform's variables are set at provisioning and never by you (secrets set refuses their names), and your own secrets reach the app only through durable-sdk secrets set.

A variable is read by the code where it is used, never copied into a step's output, a log line or a ledger image; the redaction policy refuses the shapes. .env.example in the template names every one with a local value where one is safe.

The platform's variables#

Set on the app's project at apps create, per target (production, preview), rewritten by the platform alone.

Variable Target Meaning
DATABASE_URL both, per target The pooled connection string of the app's database: the production branch for production, the one shared preview branch for preview. What durable.config.ts opens its pool on.
DATABASE_URL_UNPOOLED both, per target The direct connection string of the same branch. Read by the build's durable-sdk migrate alone: DDL and the migrate lock stay off the pooler.
CRON_SECRET both The bearer the minute cron sends to /jobs/dispatch. The engine refuses a tick without it.
ADMIN_TOKEN both The write bearer of the app's operator API (/admin/api/*). Held sealed by the platform for the console proxy; never shown to you.
ADMIN_READ_TOKEN both The read bearer of the same; what the platform check reads with.
CONSOLE_SESSION_PUBLIC_KEYS both The platform's public key (ES256) as the JSON list the operator API's verifier reads, so the dashboard's console sessions are signed by the platform and no session secret lives on the app.
DURABLE_SESSION_AUDIENCE both, per target durable-app:<slug>:<target>: a session minted for production opens nothing on a preview.
DURABLE_ALIAS_URL both https://<slug>.durablesdk.com: what the dispatcher's self-requests call and the deployment marker is adopted from.
DURABLE_WAKE both inline: a write that needs a wake drains inside the request that made it; the cron is the fallback.
DURABLE_SCHEMA both durable: the schema the engine's tables live in.
DURABLE_NAMING both snake: the naming the migrator wrote.
DURABLE_ENV_NAME both, per target production or preview: this deployment's name on the stream and the instance row's name.
DURABLE_HOSTNAMES both, per target The hostnames the app answers for, comma-separated (my-app.durablesdk.com, the deployment alias pattern my-app-*.durablesdk.com the deploy's check reads, and a verified custom domain for production; the preview's hostname for a preview). A request under any other Host is 404. Rewritten at domains verify.
DURABLE_PLANE_URL both https://durablesdk.com: where the app's docs and its platform are.

Every name above is reserved: PUT /apps/:slug/secrets/<name> with one of them is refused plane.secret.reserved. No variable of the platform's own providers is written to your project, and no bypass secret exists.

Your secrets#

durable-sdk secrets set NAME writes a sensitive variable for the targets you name (both by default). The name is [A-Z][A-Z0-9_]{1,62}. The value is never read back by the platform and applies at the next build (--redeploy makes one). Read it in the app as any variable:

// src/services/payments.ts
export function paymentsClient() {
  const key = process.env.PAYMENTS_KEY;
  if (!key) throw new Error("PAYMENTS_KEY is not set");
  return { key };
}

Bind it in durable.config.ts as a services factory so a step reads it at use, and the redaction policy keeps it out of every stored shape.

The CLI's variables#

Read by durable-sdk on your machine or in CI, never on the app.

Variable Meaning
DURABLE_API_KEY An API key; wins over the credentials file. What a CI job or an agent sets.
DURABLE_PLANE_URL The platform's base (https://durablesdk.com by default). Honoured only when it and DURABLE_API_KEY both come from the process environment; https:// only (http://localhost excepted).
DURABLE_CONFIG_DIR Where credentials.json lives; else $XDG_CONFIG_HOME/durable-sdk, else ~/.config/durable-sdk.
# .github/workflows/deploy.yml
name: deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - run: pnpm install --frozen-lockfile
      - run: pnpm durable-sdk deploy --prod --message "${{ github.sha }}" --json > deployment.json
        env:
          DURABLE_API_KEY: ${{ secrets.DURABLE_API_KEY }}

Local development#

.env on your machine carries DATABASE_URL and DATABASE_URL_UNPOOLED of a local or a branch database, DURABLE_ENV_NAME=local, CRON_SECRET and ADMIN_TOKEN of your own minting, and DURABLE_HOSTNAMES empty (every host admitted). durable-sdk dev reads it and ticks the dispatcher every ten seconds. Never commit .env; the upload refuses .env* files.

The engine's own variables#

The engine reads a few more where an app sets them: DURABLE_SESSION_PRIVATE_KEY and DURABLE_SESSION_KID (an app signing its own console sessions on a laptop), CONSOLE_SESSION_SECRET (the HS256 secret of a session minted by hand; the platform uses the public-key list instead), DURABLE_MCP_AGENT (the MCP's actor name). A hosted app needs none of them.