# Errors and limits

The error format, all error codes and what your site does about them, the rate limits and the Idempotency-Key.

## Error format

Every error has the same shape, with the HTTP status of the code:

```json
{
  "error": {
    "code": "slot_unavailable",
    "message": "This time is not available. Fetch the times again.",
    "details": { "reason": "full" },
    "request_id": "req_8Kq2…"
  }
}
```

- Decide on `code`, not on `message` (the text may change).
- `details` is optional. For `invalid_input` it contains `details.fields`, a list of messages per field. For `not_enabled`, `details.reason` sometimes says why: `plan` (plan lower than Starter), `booking_limit` (monthly limit reached) or `venue_in_setup` (venue still in the setup phase).
- Every response (successful ones too) has the header `Callyndar-Request-Id`. Include it when you ask Callyndar for help.
- With a `server_error` you never get internal details; those are in Callyndar's logs under the `request_id`.

## Error codes

| Code | HTTP | Meaning | What does your site do? |
|---|---|---|---|
| `unauthorized` | 401 | No key, an unknown key or a revoked key. | Check the key on /integrations; a revoked key never works again. |
| `forbidden_origin` | 403 | The page's Origin is not on the key's domain list. | Add the domain to the key (exactly https://domain) or switch on "allow localhost" while building. |
| `not_enabled` | 403 | Online booking through the API is not available for this venue (plan below Starter, venue inactive or stopped, monthly limit reached, or a server setting is missing). A venue a partner is still setting up answers this on every write with details.reason "venue_in_setup"; reads do work. | Show a friendly message and point to the venue's phone or e-mail. With "venue_in_setup": wait until the owner has activated the venue. |
| `turnstile_failed` | 403 | The Turnstile token is missing, expired or already used. | Let the visitor do the Turnstile check again (turnstile.reset) and send the new token. |
| `not_found` | 404 | The hold, payment or route does not exist for this key. | Start again at picking a time. |
| `method_not_allowed` | 405 | This HTTP method does not exist on this path. | Use the method from the reference. |
| `invalid_input` | 422 | The request does not match the schema (details lists the fields). | Fix the fields from details.fields; do not resend the same request unchanged. |
| `slot_unavailable` | 409 | The chosen time is not (or no longer) bookable. | Fetch the times again with GET /availability and let the visitor pick another time. |
| `hold_expired` | 409 | The hold or slot confirmation expired, was already used or was released. | Request a new hold with POST /holds (the time may still be free). |
| `deposit_required` | 409 | This booking needs a deposit, or the payment sent along is not (yet) valid. | Start the deposit with POST /holds/{id}/deposit, then book with payment_intent_id. |
| `idempotency_conflict` | 409 | The same Idempotency-Key was used with a different body, or the first request is still running. | Use a new Idempotency-Key per booking attempt; with Retry-After, wait and try again. |
| `payload_too_large` | 413 | The body is larger than 16 KB. | Send only the fields from the reference. |
| `rate_limited` | 429 | Too many requests (per key or per visitor). | Wait the number of seconds from the Retry-After header. |
| `server_error` | 500 | Unexpected error on Callyndar's side. | Try again later; mention the request_id if it keeps happening. |

### Limits (generated)

All routes together: 600 requests per minute per key. At most 50 active holds per key at once.

| Write route | per key / min | per key + visitor IP / min |
|---|---|---|
| POST /holds | 120 | 30 |
| DELETE /holds/{id} | 240 | 60 |
| POST /bookings | 60 | 20 |
| POST /holds/{id}/deposit | 30 | 10 |
| POST /bookings/recover | 60 | 20 |

## Rate limits

| What | Limit |
|---|---|
| Per key, all routes combined | 600 requests per minute |
| Per visitor IP, all routes combined | 300 requests per minute |
| `POST /holds` | 120 per minute per key, 30 per minute per visitor |
| `DELETE /holds/{id}` | 240 per minute per key, 60 per minute per visitor |
| `POST /bookings` | 60 per minute per key, 20 per minute per visitor |
| `POST /holds/{id}/deposit` | 30 per minute per key, 10 per minute per visitor |
| `POST /bookings/recover` | 60 per minute per key, 20 per minute per visitor |
| Active holds at once | max. 50 per key |

"Per visitor" is the real IP address of the browser making the call. Above a limit you get `429 rate_limited` with the `Retry-After` header (seconds). Wait at least that long before trying again, and show the visitor a calm message ("One moment, please try again shortly").

Tip: fetch `/venue` and `/services` once per visit and keep them in a variable; only request `/availability` when the guest picks a day.

## Idempotency-Key

`POST /bookings` requires the `Idempotency-Key` header (8–128 characters: letters, digits and `. _ -`). Create a new one per **booking attempt**, e.g. `crypto.randomUUID()`.

- **Same key + same body**: you get the first response again (header `Idempotent-Replayed: true`). This lets you retry safely after a network error without booking twice. The `turnstile_token` does not count towards "same body": a retry with a new token is the same booking.
- **Same key + a different body**: `409 idempotency_conflict`.
- **The first request is still running**: `409 idempotency_conflict` with `Retry-After: 1`.
- Only **successful** responses are stored. After an error (e.g. `slot_unavailable`) you may reuse the same key; a hold only ever becomes one booking anyway.
- Keys expire after 24 hours.

## What your site does per situation

- **Time gone** (`slot_unavailable`, `hold_expired`): fetch the times again, let the guest choose a new time.
- **Deposit required** (`deposit_required`): start `POST /holds/{id}/deposit` and then book with `payment_intent_id`.
- **Bot check** (`turnstile_failed`): `turnstile.reset()` and try again.
- **Venue unavailable** (`not_enabled`): show the venue's phone number and email address from `/venue`.
- **Venue still in the setup phase** (`not_enabled` with `details.reason = "venue_in_setup"`): the partner is still setting up the venue and the owner has not activated it yet. Reading works, every write call (holds, deposit, booking) is rejected. Show "Online booking is coming soon"; see [Testing](/developers/en/testing#during-the-setup-phase).
- **Configuration** (`unauthorized`, `forbidden_origin`): this is an error in the site, not with the guest; check the key and domain list at `/integrations`.
