// troubleshooting guide · supabase

Supabase 'Invalid API Key' Error (New Publishable and Secret Keys)

Status
Ongoing
platforms:
All clients, Edge Functions
updated:
November 22, 2026
reports:
3
Method
how we research
Share

RUNBOOK · supabase/invalid-api-key4 FIXES

// quick answer

Usually a disabled legacy key, a key from another project, or a secret key sent from the wrong place. Use the sb_publishable_ key in the apikey header and update Edge Function env vars.

Most likely fix: Use the new keys

How to fix it

// try these in order, the most common fix is first

  1. FIX 1Use the new keys

    1. 01Open Project Settings > API Keys
    2. 02Copy the publishable key (sb_publishable_...) for client code
    3. 03Copy a secret key (sb_secret_...) for servers only
    4. 04Send them in the apikey header
    Did this fix it?
  2. FIX 2Update Edge Functions

    1. 01Read SUPABASE_PUBLISHABLE_KEYS and SUPABASE_SECRET_KEYS instead of the old variables
    2. 02Redeploy the function
    Did this fix it?
  3. FIX 3Temporary fallback

    1. 01Re-enable the legacy keys if the project still has them
    2. 02Migrate before the end-of-2026 deprecation
    Did this fix it?
  4. FIX 4Check project match

    1. 01Confirm the URL ref and the key come from the same project
    2. 02Check the environment variables in your host (Vercel, Netlify) were redeployed
    Did this fix it?

SANDBOX · supabase RUNS IN YOUR BROWSER

Try it: edit a table, call it from your app, run SQL

A hands-on Supabase-style sandbox, including the spots where users get stuck. See where problems like this one start. 1-2 minutes, nothing is saved.

Symptoms

Requests return 401 'Invalid API key', often after migrating to new keys or restoring a paused project.

Why it happens

  • C-01Legacy anon/service_role key disabled during migration
  • C-02Key copied from a different project
  • C-03Restored paused project without legacy keys
  • C-04Edge Function still reads SUPABASE_SERVICE_ROLE_KEY
  • C-05Secret key used in browser code

// this guide also covers

  • supabase invalid api key
  • supabase publishable key
  • supabase service_role deprecated

Still not working?

If Supabase keeps failing, you're not alone. See every Supabase problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us

Watch Supabase Get an email when its price changes, it has an outage, or we publish a new fix. No spam.

Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other Supabase errors

All 16 Supabase errors and fixes →