Errors
Failures come back as HTTP 200 with status: "failed". Branch on the body, never on the HTTP status.
const res = await fetch(url, options);
const data = await res.json();
if (data.status !== "success") {
throw new Error(data.reason ?? "Request failed");
}
Shapes you will see
| Case | Body |
|---|---|
| Bad or missing apikey / secretecode | { "status": "failed", "code": 401, "reason": "Invalid access key" } |
| Missing or invalid field | { "status": "failed", "reason": "Missing supplier_uid" }, sometimes with a requested_data echo of your request |
| Supplier could not complete | { "status": "failed", "reason": "Train search could not be completed." } |
| Unknown path | HTTP 404 with an HTML page |
Handling failures
- Show
reasonto your operators. It is written to be read. - Do not retry a
401; fix the keys. - Retry a search failure once. If it fails again, open the
search_result_logs_urlfrom a successful search for the same route to compare. - Never retry a booking, issue or cancel call without first reading the booking status. A retry can create a second booking.