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, failed validation, missing reservation token, or a Seat Map event (not supported). |
401 | Missing or invalid API key. |
403 | Valid key of the wrong type (use a jt_public_... key). |
404 | The resource doesn't exist for this host. Other hosts' events look like 404s. |
409 | An order for this reservation is already being processed. |
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)
}
}
