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 theAuthorization: Bearerheader. - The secret key is omitted from the
apikeyheader. - The request is sent from a client-side browser.
How to resolve it
- Send requests from a server environment: Browser requests using secret keys are blocked.
- Set the
apikeyheader: Include the secret key directly in theapikeyheader. AnAuthorization: Bearerheader 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> - 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.
- 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-idresponse header.