Category: Supabase and databases

Supabase Admin: createUser returns a refusal for an anon key

Read this guide in Polish

The administrative function tries to create users using a public client.

How to identify the source of the problem

Check whether the admin API call is performed in the browser and what role the token uses.

Compare the result for the authorized and unauthorised user, project name and exact error code.

Repair steps

Transfer admin API to trusted backend with service key and your own permission control.

How to Test Solution

Only the authorized administrator can create accounts, and the public client does not see the service key.

Security and restrictions

Change permissions and scheme first on test data with backup. Do not put service role in your browser.