Skip to navigation

Errors

Which status codes the Atlas API and the Atlas CLI return, what the error body looks like, and what to do about each one.

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.

ShapeWhere you see it
{"message": "..."}The most common. Gateway errors and most endpoint errors.
{"message": "...", "code": "..."}Some gateway errors, such as API key limits.
{"message": "...", "errors": ["..."]}Validation failures with a list of reasons, for example {"message":"Validation failed","errors":["Missing campaignId"]}.
{"error": "..."}, sometimes with messageSome endpoints put a short code in error, for example {"error":"file_too_large"} or {"error":"OUT_OF_CREDITS","message":"Out of credits. Buy credits or turn on auto top-up to continue."}.
{"error": {"message": "...", "code": "...", "requestId": "..."}}Endpoints that use the shared error handler.

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

StatusMeaningWhat to do
200 OKIt worked. The body has the result.On batch endpoints, check the body. Failed items can sit inside a 200.
201 CreatedA new item exists.Read the new item from the body.
202 AcceptedAtlas took the work and runs it in the background.Check the resource later. Don’t send it again.
204 No ContentIt worked. There is no body.Nothing to parse.

Client errors

StatusMeaningWhat to do
400 Bad RequestA required value is missing or invalid. The most common error.Read the message. Fix the request. Don’t retry it unchanged.
401 UnauthorizedNo key, or the key isn’t valid.Check the key. See 401 in detail.
402 Payment RequiredYou are out of credits (code OUT_OF_CREDITS, for example when you schedule a call), or a card payment failed (code PAYMENT_FAILED).Buy credits or turn on auto top-up, or check billing in the Atlas app.
403 ForbiddenYour key is valid but the action isn’t allowed.Don’t retry. Check the action and your account.
404 Not FoundThe job, call or other item doesn’t exist for your account.Check the ID. List first.
409 ConflictThe request clashes with the current state. For example, you already have 5 active API keys.Read code if there is one. Change the state, then try again.
413 Payload Too LargeA file you uploaded is too big, for example a call-forward CSV.Send a smaller file.
422 UnprocessableThe request is well formed but can’t be applied in the current state, for example a flow or business verification that blocks the change.Read the message. Fix the state first.
429 Too Many RequestsYou hit the rate limit.Wait, then retry. See Rate limits and pagination.

Server errors

StatusMeaningWhat to do
500 Internal Server ErrorSomething failed on our side.Retry reads after a pause. Check before you retry a write. See Retrying safely.
502 Bad GatewayA service Atlas depends on failed or answered badly.Same as 500.
503 Service UnavailableA dependency isn’t available right now.Wait, then retry.

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):

{"message":"Missing Api-Key header."}

The key is wrong, deleted or turned off:

{"message":"Invalid or inactive Api-Key."}

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

RequestSafe to retry?
GETYes. Wait a little longer after each failure.
DELETEUsually. A second delete may return 404. That means it is already gone.
PUTUsually. Same body, same result.
POSTNot by default. The API has no idempotency key. A retry can create a second item.

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:

Exit codeNameWhen
0okIt worked.
2usageA bad flag or argument, invalid JSON in --body, a file it can’t read, or atlas whoami with no key set up.
3auth401 or 403, or no API key for an API command.
4clientAny other 4xx, including 404, 409 and 429.
5serverAny 5xx, or a network failure (DNS, connect, TLS, timeout).

With the default JSON output, the error is one JSON object on stderr. status and body are there when the API answered:

{"error":{"body":{"message":"Invalid or inactive Api-Key."},"code":"auth","exit_code":3,"message":"Invalid or inactive Api-Key.","status":401}}

With -o table or -o yaml, it is one line of text:

Error: unauthorized (401): Invalid or inactive Api-Key. | body: {"message":"Invalid or inactive Api-Key."}

atlas help --json lists the same exit codes under exit_codes. More in Atlas CLI commands.