Keys / Supabase

SUPABASE_SECRET_KEY

The Supabase key your server uses to reach all of a project's data, bypassing Row Level Security. It replaces the legacy service_role key.

Starts with
sb_secret_
Expires
no expiry in the docs; it works until you delete it
API
create, list and delete, with an access token

Get it

Create one on supabase.com/dashboard/project/_/settings/api-keys. The steps aren't recorded yet.

Set it

SUPABASE_SECRET_KEY=sb_secret_...

@supabase/server reads it when SUPABASE_SECRET_KEYS isn't set; with supabase-js, your app passes it to createClient. Edge Functions get every secret key by name in SUPABASE_SECRET_KEYS. Or keep it out of .env with keypin: keypin run -- npm run dev

Replace it

  1. Create a new secret key in Settings > API Keys. A project can have several, each with its own name. Every project starts with one named default; keypin rotate refuses that one, so give each app its own named key.
  2. Deploy it everywhere that uses the old key.
  3. An Edge Function that checks withSupabase({ auth: 'secret' }) accepts only the key named default, and auth: 'secret:<name>' only that name. Use auth: 'secret:*' to accept any secret key, so a new key with a new name works, and deploy it.
  4. Check that nothing still uses the old key, then delete it. Deleting a secret key can't be undone.
Sources, checked 2026-11-17