Errors
The error envelope, status codes, and error_code identifiers.
Response envelope
Successful responses are wrapped as:
{ "data": { "...": "payload" }, "status": true }Errors return an error envelope instead:
{
"message": "Missing or invalid API key",
"status": 401,
"error_code": "unauthorized"
}| Field | Description |
|---|---|
message | Human-readable description, safe to log. |
status | The HTTP status code, repeated in the body. |
error_code | A stable, machine-readable identifier. Branch on this, not on message. |
Status codes
| Status | When |
|---|---|
400 | Malformed body or failed validation. This includes a promo code that cannot be applied, an add-on that cannot be bought, a wrong sale password, a sale that is not open, a waitlist that has closed, an expired reservation, and tickets to Seat Map events (not supported). |
401 | Missing or invalid API key. |
403 | A valid key of the wrong type (jt_public_... everywhere except the attendee lookups, which need jt_private_...), or an event with a waiting room (event_queue_not_admitted, not supported). |
404 | The resource doesn't exist for this host. Other hosts' events and sales look like 404s. Also returned for an unknown or expired promo code, and for an order that is not confirmed yet (see Checkout flow). |
409 | An order for this reservation is already being processed. |
429 | Too many requests for this API key (too_many_requests), or too many add-on reservations from one IP address. Wait for the seconds in the Retry-After header, or a few seconds when it is missing, then retry. |
The message on a 400 is written to be shown to the attendee, for example
"invalid password" or "Event is closed".
Handling errors with the SDK
The SDK throws a typed ApiError for every non-2xx
response, with the parsed envelope on the error object:
import { ApiError } from '@jetronticket/api'
try {
await client.getEvent('missing-event')
} catch (err) {
if (err instanceof ApiError) {
console.error(err.status, err.errorCode, err.message)
}
}
