OpheliaDocs
Search docs⌘K
DashboardCreate an account
v3 · Guide

Handle errors

Every failure answers one question first: did it book? There are four answers: it may have booked, it is not confirmed, nothing was booked, or check first. Each one tells you what to do next.

How a failure looks

A failed drive answers status: "failed" with an error_code you can branch on, an error sentence for people, and a failure_class. terminal means this attempt is over. retryable_elsewhere means the site blocked Ophelia and nothing was committed: try again after Retry-After.

json
{
"status": "failed",
"path": "live",
"served_by": "form",
"drive_id": "drv_d0e571d14248a647033e9c35",
"failure_class": "terminal",
"error_code": "no_results",
"error": "the session ended without results: no_results: the site says 'No results'"
}

A 409 means this request failed. Do not send the same request again. Whether a new attempt is fine depends on the code, as the groups below say. A new attempt always takes a new idempotency_key: the same key answers the first answer again, a failure included.

Requests refused before anything runs use shorter bodies. {"error_code", "error"} carries the code in error_code, as for invalid_input, wrong_key_environment and no_organization. {"error": "invalid request body", "field", "detail"} names a field. Five codes sit in error itself, with no error_code: insufficient_scope, rate_limited, unauthorized, billing_required and billing_check_unavailable. Every shape is on Request rules, and every code on Statuses and error codes.

May have booked: stop and tell the person

Never resend these, with any key. The site may hold a booking or an order. v3 cannot cancel it, and a second request can book twice. Stop, tell the person what happened, and check with the site.
AnswerWhat happened
409 not_confirmed_after_otp
A final press landed and no confirmation was seen. The booking may exist.
409 transaction_status_unknown
The drive was lost after a press, or after a code was typed. The booking may exist.
409 booked_a_different_entity
The drive completed a booking, and it is for a different thing than the one you named. The person must undo it with the site now.
json
{
"status": "failed",
"booking_id": "bk_54fafca4b13d2804d4cb40a3",
"attempt_id": "att_b85fa71bb6b6c6f858925d30",
"cancellable": false,
"cancel_via": "contact the venue directly using the confirmation on this booking",
"failure_class": "terminal",
"error_code": "not_confirmed_after_otp",
"error": "the booking was authorized to commit and never reached a confirmation — the drive ended on challenge: stalled on challenge at https://opheliapractice.com/restaurant/practice-bistro — the page says: That code isn't right. (a finalizing press DID land — 1 commit(s) — so this attempt may have created a booking and must not be retried)"
}
StepWhat to do
1. Stop
Do not send the booking again, with any key.
2. Tell the person
Say the booking may exist. Show error, the place and the time.
3. Read it later
GET /v3/bookings/{booking_id} reads the booking as it stands, with its ids and error.
4. Check with the site
The person, or you on their behalf, asks the site, or the place itself, whether it holds a booking or an order.

Not confirmed: almost certainly not booked

The pause ended before its code was typed, so the booking was almost certainly not made. v3 cannot confirm that. Check with the site if it matters. Then you may start a new booking with a new idempotency_key.

AnswerWhat happened
410 attempt_expired
The pause lapsed (after 600 seconds, or if Ophelia restarted) before the code arrived. GET /v3/bookings/{booking_id} reads failed with the same code.
200 attempt_abandoned
You abandoned the pause.
json
{
"status": "failed",
"booking_id": "bk_ac12c8f2543da9a840e906e1",
"attempt_id": "att_6cf2814d9eb72b0945453f1d",
"failure_class": "terminal",
"error_code": "attempt_abandoned",
"error": "the held session was released and its browser closed. The challenge was never answered, so the booking was almost certainly not completed — but v3 cannot confirm that and cannot cancel, so treat the outcome as unknown and check with the venue if a commitment matters"
}

Pauses have their own page: When a drive pauses.

Nothing was booked: fix it and try again

Every 400, 404, 422, 502 and 503 booked nothing, and so did the 409 codes below: each one is answered before any press that could book. Fix what the code names and try again with a new idempotency_key.

Fix the request: 400, 404, 422
json
{
"status": "failed",
"failure_class": "terminal",
"error_code": "wrong_id_namespace",
"error": "id \"ven_123\" is not a ent id — v1 and v3 mint separate namespaces and an id from one never resolves in the other"
}
AnswerWhat to do
400 invalid_input or a field
A value breaks a rule. error or detail names it. See Request rules.
400 wrong_id_namespace
A v1 id on v3. Use the ent_ and off_ ids v3 gave you.
400 offer_entity_mismatch
The offer_id belongs to another entity.
400 ambiguous_vertical
Name the vertical (GET /v3/verticals).
404 unknown_entity, unknown_offer, unknown_booking, unknown_attempt
No such id for your organization. An id belongs to the organization whose key got it.
422 needs_input
The request must add something, and missing lists it. It can come after a drive ran; nothing was pressed. Send again with what missing lists. See When a drive pauses.
422 max_total_required
Add authorize.max_total and authorize.currency. See Order from a store.
401, 403
The key or its scopes. A scope refusal reads {"error": "insufficient_scope", "required_scope", "accepted_scopes"}. A site not switched on for the key reads 403 merchant_not_enabled_for_key, with allowed_sites. See Keys and scopes.
402 "error": "billing_required"
A live key (or an existing beta key), and your organization has no payment method on file. Add billing in the dashboard. A test key past its free allowance gets "error": "free_tier_exhausted": switch to a live key with billing.
The drive stopped before any booking press: 409
AnswerWhat to do
no_site, unresolvable_site, private_address
Name a public website in site.
no_results, search_error, term_not_applied, location_not_applied, no_availability
The site found nothing, or the search could not be done as asked. error carries the site's words. See Find something.
offer_gone, offer_expired
The offer is no longer on the page, or is past its expires_at. Read availability again for a fresh offer_id.
entity_not_reached
The drive no longer reaches the entity you named. Nothing was substituted. Search again.
unaddressable_entity, no_bookable_action, no_action_found, not_bookable_here
The page has no way to book this online. Pick another result.
commitment_refused
The max_commitment does not fit the route: a search or availability read takes read or begin, a booking takes begin or commit.
booking_error
The drive stalled before any final press. The booking report says where.
over_max_total, total_unreadable, cart_mismatch, currency_mismatch, variant_unavailable, selection_unconfirmed, out_of_stock, address_rejected, payment_method_unavailable, payment_link_expired
An order stopped before its order press. See Order from a store.
order_refused
The store refused the order press. It was pressed, and nothing was bought.
card_declined
The store declined the card. No order was placed.
quote_unavailable
This site's booking cannot be stopped short at begin, so it was not run. Nothing was pressed.
drive_lost
The drive ended on Ophelia's side before any press that could book.
Try again later: 502, 503
AnswerWhat to do
503 drive_capacity
Ophelia is busy. Wait the Retry-After seconds (60).
503 with failure_class: "retryable_elsewhere"
The site turned Ophelia away with a bot wall or a block. Wait the Retry-After seconds (30).
503 v3_disabled, billing_check_unavailable
v3 is switched off, or Ophelia could not check billing. Try later.
502
The drive broke off on Ophelia's side (for example search_nav_failed). Nothing was committed. Send it again.

Always wait at least Retry-After seconds before you try again.

Slow down: 429
AnswerWhat to do
429 "error": "rate_limited"
Your organization used up a 5-minute budget. Wait Retry-After seconds.
429 site_paced
The site asked Ophelia to slow down. Wait before asking that site again.
json
{
"error": "rate_limited",
"limit": 10,
"message": "rate limit exceeded",
"retry_after_seconds": 231
}

Some routes share one budget. Bookings and POST /v3/sessions share 10 per 5 minutes, and the two continue routes share 20, so connecting accounts uses up bookings. The budgets are on Rate limits.

Check first: any other failure at commit

Any other failure on a booking at commit does not say when it happened. That includes timeout, runner_error, unknown_status, session_expired, card_fill_failed, the otp_ codes, and the failures on Ophelia's side. Read GET /v3/bookings/{booking_id} and check with the site before you book again. Do not tell the person nothing was booked.

The same goes for 500 with error_code: "internal" on a booking at commit. (500 with "error": "rate limiter unavailable" is answered before anything runs, so nothing was booked.)

A booking at begin, a search and an availability read never press a final button, so these codes booked nothing there. The one exception is the alarm below.

If a begin answer carries ALERT_BOOKING_CREATED in its booking report, the drive landed on a confirmation anyway. A booking may have been made that you did not authorize. Tell the person and check with the site.

processing with continue_in_flight is not a failure: a code is still being entered. Read GET /v3/bookings/{booking_id} and do not resend the code.

If your client times out

A booking call can stay open for minutes. If your client gives up on POST /v3/bookings, send the same request with the same idempotency_key. You get the booking as it stands, processing while the drive runs, and never a second booking.

While a booking reads processing, read GET /v3/bookings/{booking_id} again until it changes, or let a webhook tell you.

Next: Test on the practice site.