Errors
The API uses normal HTTP status codes. 2xx means it worked. 4xx means the request needs fixing. 5xx means something went wrong on our side.
The body is not one fixed shape
Error bodies come from several layers, so they differ. Read the HTTP status first. Then look for the message.
Write your code to try these in order: error.message, then message, then error as a string. Keep the whole body in your logs.
If an error carries a requestId, quote it when you contact support@youratlas.com.
Status codes
Success
Client errors
Server errors
Redirects
A few endpoints meant for a browser return 302 to send a person to a sign-in or connect page. Your code won’t normally meet these.
401 in detail
There are two cases. Both return JSON.
No api-key header (or the key was sent somewhere other than the header):
The key is wrong, deleted or turned off:
Common causes:
- The header name is wrong. It is
api-key. - A space or newline got copied with the key.
- The key was deleted or refreshed.
- The key belongs to a different account.
Batch endpoints
Endpoints that take a list check each item on its own. If some items fail, you can still get 200. The reasons are in the body, for example under invalid. Create contact manually works this way. Read the body, not only the status.
Retrying safely
For a POST that times out or returns 5xx, list the resource first. Check whether the first call landed. Then decide.
Never loop on a 4xx other than 429. It fails the same way each time.
In the CLI
The Atlas CLI writes errors to stderr and exits with a code that tells you the kind of failure:
With the default JSON output, the error is one JSON object on stderr. status and body are there when the API answered:
With -o table or -o yaml, it is one line of text:
atlas help --json lists the same exit codes under exit_codes. More in Atlas CLI commands.
