> This page is for version v2.
> For other versions, use one of these documentation indexes:
> - v1 (default): https://doc.youratlas.com/v1/llms.txt
> - v2: https://doc.youratlas.com/v2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://doc.youratlas.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://doc.youratlas.com/_mcp/server.

# 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.

| Shape                                                              | Where 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 `message`                       | Some 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](mailto:support@youratlas.com).

## Status codes

### Success

| Status           | Meaning                                            | What to do                                                               |
| ---------------- | -------------------------------------------------- | ------------------------------------------------------------------------ |
| `200` OK         | It worked. The body has the result.                | On batch endpoints, check the body. Failed items can sit inside a `200`. |
| `201` Created    | A new item exists.                                 | Read the new item from the body.                                         |
| `202` Accepted   | Atlas took the work and runs it in the background. | Check the resource later. Don't send it again.                           |
| `204` No Content | It worked. There is no body.                       | Nothing to parse.                                                        |

### Client errors

| Status                  | Meaning                                                                                                                                   | What to do                                                                                  |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `400` Bad Request       | A required value is missing or invalid. The most common error.                                                                            | Read the message. Fix the request. Don't retry it unchanged.                                |
| `401` Unauthorized      | No key, or the key isn't valid.                                                                                                           | Check the key. See [401 in detail](#401-in-detail).                                         |
| `402` Payment Required  | You 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` Forbidden         | Your key is valid but the action isn't allowed.                                                                                           | Don't retry. Check the action and your account.                                             |
| `404` Not Found         | The job, call or other item doesn't exist for your account.                                                                               | Check the ID. List first.                                                                   |
| `409` Conflict          | The 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 Large | A file you uploaded is too big, for example a call-forward CSV.                                                                           | Send a smaller file.                                                                        |
| `422` Unprocessable     | The 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 Requests | You hit the rate limit.                                                                                                                   | Wait, then retry. See [Rate limits and pagination](/v2/developers/rate-limits-and-pagination). |

### Server errors

| Status                      | Meaning                                              | What to do                                                                                          |
| --------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `500` Internal Server Error | Something failed on our side.                        | Retry reads after a pause. Check before you retry a write. See [Retrying safely](#retrying-safely). |
| `502` Bad Gateway           | A service Atlas depends on failed or answered badly. | Same as `500`.                                                                                      |
| `503` Service Unavailable   | A 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):

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

The key is wrong, deleted or turned off:

```json
{"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

| Request  | Safe to retry?                                                                    |
| -------- | --------------------------------------------------------------------------------- |
| `GET`    | Yes. Wait a little longer after each failure.                                     |
| `DELETE` | Usually. A second delete may return `404`. That means it is already gone.         |
| `PUT`    | Usually. Same body, same result.                                                  |
| `POST`   | Not 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 code | Name     | When                                                                                                          |
| --------- | -------- | ------------------------------------------------------------------------------------------------------------- |
| `0`       | `ok`     | It worked.                                                                                                    |
| `2`       | `usage`  | A bad flag or argument, invalid JSON in `--body`, a file it can't read, or `atlas whoami` with no key set up. |
| `3`       | `auth`   | `401` or `403`, or no API key for an API command.                                                             |
| `4`       | `client` | Any other `4xx`, including `404`, `409` and `429`.                                                            |
| `5`       | `server` | Any `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:

```json
{"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](/v2/developers/cli/commands#when-something-goes-wrong).