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:

{
  "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:

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

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

StatusShapeReason
400 Bad Requestfield-keyedMissing/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 UnauthorizeddetailMissing, malformed, expired, or revoked API key.
429 Too Many RequestsdetailRate limit exceeded (5/min). Includes Retry-After header.

See Basics for authentication and rate-limit details.