Verifying... VPN may block this. Sign in to skip.
"where do I find my supabase service role key?"
4.3s
Add to Favorites
Cozy Upvote
Share
Export

Click any AI circle above with a to read their individual answer!

The Supabase service‑role key is located in the Settings → API page of your project’s dashboard and should only be used in trusted server‑side code.

Quick Facts
  • Find it under Project Settings → APIService Role.
  • It is a secret JWT that bypasses all Row‑Level Security policies.
  • Never expose the key in client‑side code or public repositories.
  • For local development, the key is stored in the `.supabase/kong/kong.yml` file.
AI Consensus
Models Agreed
  • All models agree the key is located under Settings → API in the Supabase dashboard.
  • All models stress that the service‑role key is a secret and must not be used in client‑side code.
Points of Debate
  • Only the first model mentions the local CLI file .supabase/kong/kong.yml as a place to find the key; the others do not cover local development.

How to locate your Supabase Service‑Role key

1. In the Supabase Dashboard (Hosted projects)

  1. Go to the Supabase Dashboard at https://app.supabase.com and sign in.
  2. Select the project you need the key for.
  3. In the left‑hand navigation, click Settings (gear icon) → API.
  4. Scroll to the Project API keys section.
  5. The key labeled service_role (sometimes shown as secret_key) is your service‑role key. Use the Copy button to copy it to your clipboard.

⚠️ Security warning: The service‑role key can bypass any Row‑Level Security (RLS) rules. It must only be used in server‑side environments (e.g., backend services, cloud functions) and never be shipped to browsers or stored in public repos. [1]

2. In a local Supabase development environment (Supabase CLI)

If you are running Supabase locally:

  1. Open the root folder of your Supabase project.

  2. Open the file .supabase/kong/kong.yml.

  3. Near the bottom, under the consumers section, you will see a line similar to:

    service_role: <your‑service‑role‑key>
    

    This is the same secret used by the hosted dashboard.

3. Best practices for handling the key

  • Store securely: Use environment variables (e.g., SUPABASE_SERVICE_ROLE_KEY) in your deployment platform.
  • Rotate when needed: Changing the service‑role key will generate new JWT secrets for both anon and service keys. [2]
  • Limit exposure: Do not commit the key to source control; add it to .gitignore if stored in local files.

Quick recap

Where How to find Usage
Dashboard Settings → API → Service Role Server‑side code, cloud functions
Local CLI .supabase/kong/kong.yml Local development, testing

For further details, see the official Supabase docs on API keys [1] and community discussions on key management [2][4].

AI can make mistakes. Verify important information.

No follow-up threads yet

Dive deeper into this topic with a follow-up.

Sign in to start a follow-up thread