Auth error: {401: UNAUTHORIZED_MISSING_API_KEY} on admin endpoints

Requests to GET /auth/v1/admin/users/{id} fail with HTTP 401 and header sb-error-code: UNAUTHORIZED_MISSING_API_KEY (“No API key found in request”).

Why this happens

This error occurs when:

  • The secret key (sb_secret_) is sent only within the Authorization: Bearer header.
  • The secret key is omitted from the apikey header.
  • The request is sent from a client-side browser.

How to resolve it

  1. Send requests from a server environment: Browser requests using secret keys are blocked.
  2. Set the apikey header: Include the secret key directly in the apikey header. An Authorization: Bearer header is not required for this endpoint:
    curl -i -H "apikey: sb_secret_YOUR_KEY" \
    https://<project-ref>.supabase.co/auth/v1/admin/users/<user-uuid>
  3. Verify the key is active: In the Supabase Dashboard, check Project Settings > API Keys. Secret keys do not have an enable/disable switch; if the key is listed, it is active.
  4. Inspect edge logs: Test with a placeholder UUID. A 404 response confirms the secret key was accepted and authenticated. To troubleshoot other status codes, check Logs > API Gateway using the sb-request-id response header.