StoicBuilder

HandbookV the OfficinaSending auth headers

Vthe Officina, Use the tools

Sending auth headers

1 min readUpdated 28 November

In plain words

An auth header is a line on a request, usually Authorization: Bearer followed by a token, that tells the server who is asking so it can decide what to allow.

Where you see it

In the Network tab, click a request to your API and scroll to Request Headers: the Authorization line is what your app sends. In an HTTP client, open the Auth tab, pick Bearer Token and paste a token, and the client adds the header for you.

Terminalterminal
curl "https://abcd1234.supabase.co/rest/v1/notes?select=id,title" \ -H "apikey: $SUPABASE_PUBLISHABLE_KEY" \ -H "Authorization: Bearer $USER_ACCESS_TOKEN"
Supabase wants two headers: the project's public key, and the signed-in user's token, which decides whose notes come back.

What goes wrong

  1. Using the secret key to make it work

    Supabase's secret (service role) key skips every access rule, so the request succeeds and proves nothing. Test with a real user's token to see what that user can see.

  2. Leaving out the word Bearer

    Most APIs expect Authorization: Bearer, one space, then the token. Send the token alone and you get a 401 that looks like a bad token.

    Authorization: eyJhbGciOiJIUzI1NiIs...
  3. Reusing a token that has expired

    Sign-in tokens are short-lived, and Supabase's last an hour by default. A 401 that says JWT expired means copy a fresh token, not rewrite the code.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Show me exactly which headers each API route expects and where a valid token comes from in this app. Then give me one request with a normal user's token and one with no token, and tell me what each should return.

Quick check

Sign in to earn +10 XP for it

Your request to Guildhall's API returns 401. The header reads Authorization: Bearer and a token you copied yesterday. Most likely cause?

Got a prompt that touches sending auth headers?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.