Files
supabase/apps/docs/content
Miranda Limonczenko 4d2bd0eacf docs: add the missing API key decision information (#49799)
Closes DOCS-1311
Closes FDBKIN-2926
Closes DOCS-694

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Docs update. Corrections and new content.

This is the PR that is to bring the Eval to green.

## What is the current behavior?

Two statements are wrong, and the gaps behind most logged confusion
about this page are unfilled.

- The Availability column marks publishable and secret keys
Platform-only. `supabase start` prints both.
- The page says Edge Functions only verify the legacy keys and to use
`--no-verify-jwt`. #49700 updated `guides/functions/auth-headers` to
document that `verify_jwt` accepts the new keys on either header, but
left this page and the migration guide stating the old behavior.
- The page has no code samples, so it never shows how a key reaches
code. An agent reading it falls back on `SUPABASE_SERVICE_ROLE_KEY`, the
legacy key this same page deprecates.
- Nothing maps `anon` and `service_role` to their replacements, or says
the replacements aren't `eyJ`-prefixed JWTs.
- The Postgres role table covers only publishable keys.

## What is the new behavior?

Corrections:

- Mark all four key types available on Platform and CLI, and note that
the local secret key takes the place of the local `service_role` key.
- Point the Edge Functions guidance at the `@supabase/server` SDK
instead of `--no-verify-jwt`. Fix the same bullet in the migration
guide.

Additions:

- "Coming from `anon` and `service_role`" gives the legacy-to-new
mapping and says the replacements aren't JWTs.
- Extend the Postgres role table to cover secret keys, and note that
grants are evaluated before Row Level Security, so a missing grant fails
even for `service_role`.
- State who does what. Copying a key needs a signed-in Dashboard
session, so it is a person's step, while code only refers to the
variable name. Add a `.env` sample naming the variables.
- Add the two `createClient` samples the page lacked, plus an "Inside an
Edge Function" subsection using `withSupabase`, which reads no key from
the environment.
- Cross-reference from the key decision to retrieving a value, wiring it
into code, or migrating an application that ships legacy keys.

## Additional context

PR 4 of 4. Base is #49797.

## Manual testing

1. Open the API keys guide on the deploy preview.
2. Check the Key types table. All four rows read "Platform, CLI".
3. Check Known limitations. It no longer mentions `--no-verify-jwt`.
4. Open the migration guide and check Known limitations. The Edge
Functions bullet matches.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Updated API key guidance with clearer instructions for finding,
selecting, and using publishable and secret keys.
* Added examples for environment variables, client applications, backend
code, and Edge Functions.
* Clarified key formats, CLI availability, local development output,
Postgres role mappings, and authorization behavior.
* Expanded guidance on `apikey` headers, RLS errors, and Edge Function
API key authorization.
* Refined migration guidance for API key authentication in Edge
Functions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-01 14:40:55 -07:00
..