How to fix unauthorized (HTTP 401)
The request reached the API but carried no usable key.
What the API returns
{
"error": {
"code": "unauthorized",
"message": "missing or invalid Authorization header — expected: Bearer <key>",
"request_id": "770372810e5f2a70"
}
}Why it happens
- No Authorization header, or the header is "Authorization: <key>" without the word Bearer.
- The key was read from an environment variable that is empty in this environment (CI, serverless, a new shell).
- The key was revoked or rotated in Dashboard → API Keys, or it belongs to a different account.
- A dv_test_* key is being used against the production host (test keys only work locally).
How to fix it
- Send exactly: Authorization: Bearer dv_live_… (one space, capital B).
- Print the key length at startup; an empty string means the variable is not set where the code runs.
- Open Dashboard → API Keys and confirm the key is listed and not revoked; create a new one if unsure and update the variable.
Should your code retry?
No. The request is deterministically rejected; fix the key, IP or parameters and send it again.
Confirm the fix
This free call returns 200 when the key and header are right:
curl -s -o /dev/null -w "%{http_code}\n" "https://api.lifeastroapi.com/v1/meta/version" -H "Authorization: Bearer $LIFEASTRO_API_KEY"See all codes on the troubleshooting index and the error envelope on Errors. Still stuck? Email [email protected] with the request_id.