← Errors and troubleshooting

HTTP 401 · UNAUTHORIZED

UNAUTHORIZED: the API could not identify your key

Every calculation and chat endpoint needs Authorization: Bearer <key>. A 401 means the header was missing, malformed, or named a key the API will not accept. The message tells you which.

Updated · every example recorded from a real API call

HTTP status
401 Unauthorized
Retry?
No. The same key will keep failing; fix the header or use another key.
Rate-limit headers?
No - the request never reached the limiter.
Returned by
Every authenticated endpoint on api.astronode.dev and the chat API.

Which message, which cause

UNAUTHORIZED messages, produced by real requests
messageWhat happenedWhat to check
Missing or invalid Authorization headerNo Authorization header, or one that does not start with Bearer (a Token … or bearer … scheme counts as missing).The header name and the exact prefix Bearer with one space. Proxies and some HTTP clients drop Authorization on redirects.
Invalid API keyThe token was read but matches no active key. A revoked key returns this same message - the API does not say "revoked".Whitespace or quotes copied with the key; a key revoked in the dashboard; a key from another environment's .env.
Account suspended or unavailableThe key is valid but the account behind it is suspended or deleted.Contact support - a new key on the same account will get the same answer.

A key that was revoked in the dashboard - indistinguishable from a typo:

json
{
  "request_id": "req_01M8RK47C62W1HPGTD7ZVCKZSC",
  "error": { "code": "UNAUTHORIZED", "message": "Invalid API key" }
}

Sending the key correctly

bash
curl -X POST https://api.astronode.dev/v1/charts/birth \
  -H "Authorization: Bearer aie_test_..." \
  -H "Content-Type: application/json" \
  -d '{"date":"1973-04-24","time":"17:25:00","tz_offset_minutes":330,"lat":19.076,"lng":72.8777}'
  • Keys start with aie_test_ or aie_live_. The prefix is part of the key - send it.
  • Leading and trailing whitespace is ignored, but quotes are not: a .env value pasted as "aie_test_..." sends the quotes as part of the key.
  • Call the API from your server. A key in a mobile app or browser bundle can be extracted, and once it is revoked every copy of the app gets this 401.
  • A broken body does not hide an auth problem: the key is checked first, so a request with no key and an invalid body still gets this 401. Once the key is accepted, body problems come back as VALIDATION_ERROR.

On the chat API

POST /v1/chat/respond uses the same keys and the same messages. Its envelope adds "success": false:

json
{
  "success": false,
  "request_id": "req_01M8RK37C2FPH1TSEN6H032WAV",
  "error": { "code": "UNAUTHORIZED", "message": "Missing or invalid Authorization header" }
}