---
title: "Errors"
description: "One envelope for every failure, and the codes worth branching on."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.nicer.travel/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

Every failure returns the same JSON body, whatever the status code.

```json
{
  "errorCode": "BOOKING_OFFER_UNAVAILABLE",
  "errorMessage": "The provider no longer offers this rate"
}
```

`errorCode` is stable and safe to branch on. `errorMessage` is written for a
person and may be reworded at any time, so never match on it.

> **401 is the one exception**
>
> A request rejected for authentication never reaches a handler, so it comes back
> from the edge as `{"message": "Unauthorized"}` instead of the envelope above.
> Check the status before you parse the body.

> **Server faults say nothing**
>
> An unexpected fault returns `errorMessage: "InternalServerError"` on purpose, so
> internal detail never reaches a client. If you see one, the cause is in Nicer's
> logs — send us the time and the request, not the message.

## Status codes

| Status | Meaning | Retry? |
| --- | --- | --- |
| 400 | The request failed schema validation | No — fix the request |
| 401 | No caller, or a token that is missing, expired or invalid | After refreshing the token |
| 403 | Authenticated, but not allowed to act on this resource or company | No |
| 404 | The resource does not exist, or has expired | No |
| 409 | Conflicts with current state, such as a replayed [idempotency key](https://docs.nicer.travel/developers/idempotency) with a different body | No |
| 422 | Valid, but cannot be served — for example a supplier not enabled for the company | No |
| 429 | [Rate limited](https://docs.nicer.travel/developers/rate-limits) | Yes, after backing off |
| 5xx | Something broke on our side | Yes, with backoff — safely, if you sent an idempotency key |

## Codes worth handling explicitly

Search and booking run against live supplier inventory, so offers go stale
between calls. These are normal operation, not bugs:

| Code | What happened | What to do |
| --- | --- | --- |
| `BOOKING_OFFER_UNAVAILABLE` | The supplier withdrew the rate | Search again and offer the traveler what is left |
| `BOOKING_SELECTION_NOT_FOUND` | The hold expired past `bookableUntil` | Search again; do not reuse the selection id |
| `COMMISSION_FILTER_FORBIDDEN` | Only advisors may filter to commissionable rates | Drop the filter for traveler-facing callers |
| `CRM_REVISION_CONFLICT` | The traveler, trip or settings changed after you read them | Read them again, reapply your change, send the new `revision` |
| `ERROR_COMPANY_REQUIRED` | The route needs a company and the token names none or several | Send `x-nicer-company` |
| `ERROR_DO_NOT_HAVE_PERMISSION` | The caller is real but not allowed here | Do not retry; this will not change on its own |
| `ERROR_ITEM_NOT_FOUND` | No such id, or it is not yours to read | Do not retry |
| `ERROR_BODY_VALIDATION` | A trip date change would orphan a segment already in the itinerary | Move the segments first, then the trip |

The CRM's own codes, and what to do about each, are in
[Travelers and the CRM](https://docs.nicer.travel/developers/crm#when-a-call-fails).

## Validation errors

Requests are validated at the edge, before any handler runs. The message names
the field that failed, as `path: reason`, joined by `; ` when more than one did:

```json
{
  "errorCode": "ERROR_INVALID_QUERY",
  "errorMessage": "query: Too small: expected string to have >=2 characters"
}
```

| Code | Where it came from |
| --- | --- |
| `ERROR_BODY_VALIDATION` | The JSON body did not match the schema |
| `ERROR_INVALID_QUERY` | A query parameter did not match the schema |
| `ERROR_MALFORMED_BODY` | The body was not valid JSON at all |

Rules that span several fields — a trip whose end date precedes its start, an
invite carrying neither a phone, an email nor a name — are checked in the same
place and come back the same way.

Source: https://docs.nicer.travel/developers/errors/index.mdx
