On this page

Environment and secrets

Every function gets its project's URL and keys, plus the secrets you add.

#Built-in variables

VariableValue
STITCHDB_URLYour project URL, https://<project-ref>.p.stitchdb.com
STITCHDB_ANON_KEYThe public anon key
STITCHDB_SERVICE_ROLE_KEYThe service role key (bypasses Row Level Security)
STITCHDB_DB_URLA Postgres connection string for the transaction pooler (port 6543), as the project owner, TLS required
STITCHDB_PROJECT_REFThe project reference
STITCHDB_FUNCTION_SLUGThe name of the running function

#Your secrets

Studio → Edge Functions → Secrets → Add secrets takes one NAME=value per line, like a .env file. Secrets are shared by every function of the project, stored encrypted, and never shown again: the list shows each name with a SHA-256 digest of its value so you can check which value is set. Read them with Deno.env.get():

TypeScript
const url = Deno.env.get('STITCHDB_URL')!
const stripeKey = Deno.env.get('STRIPE_SECRET_KEY')
if (!stripeKey) return new Response('STRIPE_SECRET_KEY is not set', { status: 500 })

Names use letters, digits and _ and don't start with a digit. Names starting with STITCHDB_ are reserved. Up to 100 secrets per project, 64 KB each. Changes apply from the next request; no redeploy is needed.

#With the API

Terminal
curl -X POST 'https://stitchdb.com/platform/v1/projects/<project-ref>/secrets' \
  -H "Authorization: Bearer $STITCHDB_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '[{ "name": "STRIPE_SECRET_KEY", "value": "sk_live_..." }]'

GET on the same URL lists names and digests; DELETE with a JSON array of names removes them.