Back to Journal
Developer Tools 4 min read

Supabase Is Deprecating anon and service_role Keys: What to Change

Publishable and secret keys replace them in early 2027. Both sets work side by side for now, so you can switch one part of your app at a time.

Key Takeaways

  • Supabase is deprecating the anon and service_role API keys in early 2027. Its documentation did not give an exact day as of December 4, 2026.
  • The publishable key (sb_publishable_...) replaces anon. The secret key (sb_secret_...) replaces service_role.
  • Creating new keys does not turn off the old ones, so you can switch gradually.
  • The new keys are not JWTs. Send them in the apikey header, not as Authorization: Bearer.

Supabase is deprecating its anon and service_role API keys in early 2027. Replace anon with a publishable key and service_role with a secret key. You can create the new keys now, because the old ones keep working until you disable them.

These details come from Supabase's API keys documentation, checked on December 4, 2026. It gave no exact day, so check it again before you plan around a date.

Which new key replaces which?

Old keyNew keyWhere it can go
anonPublishable, sb_publishable_...Browser, mobile app, or server
service_roleSecret, sb_secret_...Server only. It can bypass row-level security

How do you switch?

1. Find the old keys

Both old keys are long strings that start with eyJ. Start with the usual variable names in your code:

grep -rnE "SUPABASE_[A-Z_]*(ANON|SERVICE_ROLE)" . --exclude-dir=node_modules

Also check places a code search cannot see: hosting environment variables, CI secrets, mobile apps already in people's hands, and automation tools or AI agents that connect to Supabase.

2. Create the new keys

In the Supabase dashboard, open Settings > API Keys.

3. Replace one part at a time

Start with a small server job or a test environment, then move to your main app.

4. Check any code that sets its own headers

The old keys were JWTs, so some code sends them as a bearer token. The new keys are short strings and go in the apikey header:

curl "$SUPABASE_URL/rest/v1/products?select=id" \
  -H "apikey: $SUPABASE_PUBLISHABLE_KEY"

Keep Authorization: Bearer for a signed-in user's access token.

5. Disable the old keys

When nothing uses them, disable them on the same dashboard page. Leave time for people to update mobile apps, because old versions still contain the old key.

What might break?

  • A secret key used in a browser. Supabase answers with 401 Unauthorized. Move that call to your server.
  • Code that decodes the key. The new keys are not JWTs, so there is nothing to decode.
  • Tools that read the API description. The /rest/v1/ root accepts only secret keys.

What should you check for AI agents?

Look at any agent that uses service_role today. Swapping in a secret key keeps the same full access. This is a good moment to limit the agent to what its user can see. Our guide to letting an AI agent query Supabase without bypassing RLS shows how.

Keep Reading

Frequently Asked Questions

When will Supabase stop supporting the anon and service_role keys?

Supabase's documentation says it is deprecating them in early 2027. It did not give an exact day as of December 4, 2026.

Is the Supabase publishable key safe in the browser?

Yes. Supabase describes it as safe to expose online. Your row-level security policies still decide what it can read, so turn them on for every table you expose.

Does the Supabase secret key bypass RLS?

Yes, when the request carries no user access token. Like service_role, it belongs only on the server.

Will creating new keys break my app?

No. Creating publishable and secret keys does not revoke the old ones. They keep working until you disable them.

Free Tools

Game Changer Labs

Tell us what you're building — book a free scoping call.

Pick a time that works and walk us through your project — 30 minutes, straight to the point. You leave with a concrete plan, timeline, and cost. No sales pitch — if we're not the right fit, we'll say so.

Get new playbooks by email

Occasional, no-fluff field notes on building production AI — new guides and tools, straight to your inbox. Unsubscribe anytime.

Published: December 4, 2026Game Changer Labs