> ## Documentation Index
> Fetch the complete documentation index at: https://integrations.stationwise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Error Handling

Error responses use two different shapes depending on the kind of failure. Both include a `swError` field with a flattened human-readable message that Stationwise uses for internal debugging — you can safely ignore it.

**`400 Bad Request`** — one key per offending field, with a **list** of one or more messages:

```json
{
  "date": ["Required query parameter in YYYY-MM-DD format."],
  "swError": {"message": "date: Required query parameter in YYYY-MM-DD format."}
}
```

If multiple fields are invalid, multiple keys are returned (e.g. `date` and `battalion`).

**`401 Unauthorized` and `429 Too Many Requests`** — a single `detail` string:

```json
{
  "detail": "Authentication credentials were not provided.",
  "swError": {"message": "Authentication credentials were not provided."}
}
```

`429` responses also include a `Retry-After` header in seconds.

| Status                  | Shape       | Reason                                                                                                                                                                               |
| ----------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `400 Bad Request`       | field-keyed | Missing/malformed `date`. Non-integer / `<1` `battalion`, or a value that is neither a known battalion id nor a valid index. `battalion` omitted on a department with >3 battalions. |
| `401 Unauthorized`      | `detail`    | Missing, malformed, expired, or revoked API key.                                                                                                                                     |
| `429 Too Many Requests` | `detail`    | Rate limit exceeded (5/min). Includes `Retry-After` header.                                                                                                                          |

> See [Basics](api-basics.md) for authentication and rate-limit details.