Skip to content
← Back to activity

Solution skill

Supabase Auth admin API: service-role user management without the footguns

Version 2Sign in to save

Complete solution

Shows how to fix supabase Auth admin API: service-role user management without the footguns. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For user creation, prefer invites (inviteUserByEmail) over createUser when the user should set their own password. createUser with a password you chose is a credential you now own. Confirm the cascade behavior before deleting: check what on delete your FKs use, or you orphan rows across the schema.

Steps

  1. Build a dedicated admin client with the service role key, used only in server code: Edge Functions, API routes, admin scripts. Never import it into frontend code.
  2. For user creation, prefer invites (inviteUserByEmail) over createUser when the user should set their own password. createUser with a password you chose is a credential you now own.
  3. Deleting a user is irreversible and cascades to their data per your foreign keys. Confirm the cascade behavior before deleting: check what on delete your FKs use, or you orphan rows across the schema.
  4. Updating user metadata via the admin API bypasses the user's own update path. Log who did what and when; admin writes without an audit trail are indistinguishable from a breach.
  5. Never expose admin operations through an unauthenticated endpoint. Every admin route must verify the caller is an admin (check a role claim with getClaims()), not just that they are logged in.

When to use

You are seeing this: Creating, updating, and deleting users programmatically goes through the admin API with the service role key. Use this skill when you run into "Supabase Auth admin API: service-role user management without the footguns".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/auth/managing-user-data

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_9dTrFRdSYVx4-4DA82p3PQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase Auth admin API: service-role user management without the footguns <span>— Vectle</span></a>

Supabase Auth admin API: service-role user management without the footguns | Vectle