- Developers
- Ticket issuance and order legs
Ticket issuance and order legs
Confirming ticket issuance is the step that turns a tentative booking into valid electronic tickets on the ferry operator’s booking engine. Prior to this step, the operator has no record of the order and the passenger has no guaranteed seat; once completed, tickets are issued and passengers are clear to board.
Prerequisites before starting
Section titled “Prerequisites before starting”| Prerequisite | Business context | Reference |
|---|---|---|
| Valid API key | All ticket confirmation and file retrieval calls require partner authentication (bookings:write) | Authentication with an API key |
| Requested booking with complete passenger info | Order sits in Requested status (2) with all required passenger fields populated | The booking flow |
| Adequate available balance | Account balance or credit limit across the org hierarchy must cover the NET rate | Payments and balances |
| Verified operator capability | Confirm target operator supports API ticketing (uatexpress on UAT, 8 operators on Production) | See operator capabilities list below |
| Webhook endpoint configured | Register event URLs to receive immediate issuance notifications | Webhooks |
Zero-cost ticket issuance testing on UAT: On UAT (https://api.ferryvn.net), all real ferry operators are isolated via OPERATOR_ADAPTER_ALLOWLIST=uatexpress. Select voyages operated by UAT Express (uatexpress) to test confirmation, boarding pass PDF downloads, and test VAT e-invoices at zero cost; see Environments.
Ticket issuance execution sequence
Section titled “Ticket issuance execution sequence”The diagram below illustrates the sequence of actions that occur when confirming ticket issuance:
sequenceDiagram autonumber participant P as "Your system" participant API as "Ferry API" participant MONEY as "Balance check" participant OP as "Operator" participant WH as "Webhook"
P->>API: "Confirm issuance (POST /bookings/confirmToIssue/{id})" API->>API: "Verify 5 req/60s per-booking cap, 600s lock, passenger info" API->>MONEY: "Check balance and credit limits" alt Insufficient funds MONEY-->>API: "Insufficient balance" API-->>P: "HTTP 422 insufficient balance" else Sufficient funds MONEY-->>API: "Hold funds at partner NET rate" API->>OP: "Submit ticket order to operator" alt Operator issues tickets successfully OP-->>API: "Return electronic ticket identifiers" API->>WH: "Dispatch booking.issuedTicket" API-->>P: "Booking transitions to Issued (10)" else Operator rejects or encounters error OP-->>API: "Report issuance error" API->>MONEY: "Release held funds" API->>WH: "Dispatch booking.issuedTicketError" API-->>P: "Booking transitions to Issue Error (6)" end endThe table below summarizes the actions at each step:
| Step | Your system | Ferry API | Partner takeaway |
|---|---|---|---|
| 1 | Call confirm ticket issuance | Checks rate limit (max 5 calls/60s per IP + bookingId) and passenger completeness | Incomplete passenger info is rejected immediately with code 120145 |
| 2 | Await execution lock | Secures a 600-second lock on the booking | Concurrent calls return HTTP 422 processing (120100) |
| 3 | Await balance check and hold | Temporarily reserves funds based on partner NET rate | Insufficient credit at any ancestor tier halts issuance |
| 4 | Await operator communication | Invokes operator engine to issue tickets | Processing latency varies by operator on Production |
| 5 | Receive response or poll status | Advances booking to status 10 upon completion | Use periodic polling as your final verification checkpoint |
| 6 | Download electronic tickets | Serves issued operator ticket PDFs | Deliver finalized e-tickets to passengers |
The per-booking lock prevents concurrent issuance processes, but it is not an idempotency key for the entire call. There is no advance notification of lock expiry. If balance checks fail, funds already held are released; after issuance failure, refund timing is not guaranteed. Background reconciliation skips bookings already at status 10, so finalizing that state is safe to repeat.
Verifying issued ticket status
Section titled “Verifying issued ticket status”The flowchart below outlines how to verify issuance outcomes accurately:
flowchart TD A["Call ticket confirmation endpoint"] --> B{"Response outcome"} B -- "Success" --> C["Booking transitions to status 10"] B -- "Error reported" --> D["Inspect error code to retry or abort"] B -- "Timeout / Processing" --> E["Switch to periodic verification"] E --> F["Receive ticket issued webhook event"] E --> G["Poll booking details API"] F --> G G --> H{"Booking status"} H -- "Status 10 (Issued)" --> C H -- "Other status" --> I["Await background reconciliation or contact Ferry"] C --> J["Download tickets and deliver to passenger"]Coordinating Webhooks and Polling:
- Webhooks as signals: Webhooks are HMAC-signed and retried up to 3 times on transient errors, enabling fast UI updates. However, deliveries can still be delayed or drop after the final attempt.
- Polling as the source of truth: Calling the booking detail API (
GET /bookings/{id}) is the authoritative verification. When the status is 10 (Issued), tickets are confirmed on the carrier system. - Automated background reconciliation: If communication drops while the operator is processing, Ferry’s background worker reconciles with the operator and updates the order status within a few minutes.
Integration invariants and rules
Section titled “Integration invariants and rules”Complete passenger information required before issuance
Section titled “Complete passenger information required before issuance”Calling POST /bookings/confirmToIssue/{id} on a booking with missing required passenger details is rejected immediately with HTTP 422 and error code 120145 (PassengerInfoIncomplete), before holding balance or contacting the operator. Do not retry confirmation blindly on 120145; ensure complete passenger details are present first.
Partial issuance failures on multi-leg bookings
Section titled “Partial issuance failures on multi-leg bookings”On round-trip or multi-leg bookings, one leg may issue successfully while a subsequent leg is rejected by the operator:
- The booking does not transition to status 10; it retains an error state.
- Your balance is partially debited for the leg that issued successfully, while the failed leg amount is refunded.
- Resolution procedure: Inspect individual leg orders inside the booking (
GET /bookings/{id}) to identify issued legs, then contact Ferry with the booking code. Do not create replacement bookings or retry confirmation to repair a partial failure: confirmation reruns the entire chain, not just the missing leg.
Fare recalculation at issuance
Section titled “Fare recalculation at issuance”Ferry recalculates all fare components at the moment ticket confirmation is called rather than locking in search-time prices. If operator tariffs or addition rules have changed, the actual debited amount will reflect the latest recalculation. See Ticket pricing and multi-level markup.
Read-only nature of the Orders API group
Section titled “Read-only nature of the Orders API group”On the partner integration tier, you cannot create or confirm orders directly via the Orders API group. The entire order lifecycle must be driven through the Bookings group. The Orders group is provided solely to inspect details of individual leg orders.
Partners also have no dedicated standalone invoice read API, despite receiving events such as invoice.created, invoice.updated, invoice.published, and invoice.failed (with lookup metadata attached to the order once published). Do not design an invoice event handler that calls a standalone partner invoice endpoint; see Webhooks.
Eight ticketing operators, four schedule-only operators
Section titled “Eight ticketing operators, four schedule-only operators”Among the 12 real ferry operators connected to Ferry on Production (MaiLinhExpress has been removed):
- 8 operators support ticket issuance: Seven fully automated operators (
PhuQuocExpress,SuperDong,GreenLines,Lightning68,HoaBinhShip,PhuQuyExpress,ChanKhaLuxury) plusCangSaKy(connected to the operator system with semi-automated handoff). Some carriers can take 5–8 minutes to finish; automated issuance does not guarantee sub-second responses. - 4 operators support schedule and fare lookup only: Binh An Ha Tien (
BinhAnHaTien), Thanh Thoi (ThanhThoi), Hang Chau Tourist (HangChauTourist), and Saigon WaterGo (SaiGonWaterGo). Bookings for these 4 operators can be created on Production, but confirming ticket issuance returns an unimplemented error. Filter out these carriers or arrange manual booking through Ferry operations.
On the UAT environment, only simulated uatexpress accepts bookings and ticket issuance; attempting to issue tickets on real operators in UAT is rejected.
Re-downloading issued tickets
Section titled “Re-downloading issued tickets”If a booking’s ticket file encountered an initial download glitch or a passenger needs another copy, call the ticket re-download endpoint (GET /bookings/download-ticket/{id}). This applies only to bookings that have already issued tickets, returning the issued ticket files without creating new orders or incurring charges.
Common errors and remedies
Section titled “Common errors and remedies”| Symptom | Probable cause | Recommended action | Retry safe |
|---|---|---|---|
HTTP 422 code 120145 (PassengerInfoIncomplete) | Booking is missing required passenger details | Ensure complete, valid passenger details are provided before issuing | Do not retry until completed |
HTTP 422 code 120100 reported as processing | 600-second lock currently held for this booking | Wait several minutes and poll booking status | Yes, after waiting |
Exceeded 5 calls/60s cap (429 or 120140) | Repeated confirmation attempts on the same bookingId | Wait out the 60-second window and inspect booking status first | Yes, after 60 seconds |
| Insufficient balance error | Partner account or an upstream parent lacks credit | Top up balance or request credit increase from parent | Yes, after funding |
| Unimplemented connector or UAT blocked operator | Voyage belongs to the 4 lookup-only operators (Prod) or a real operator on UAT | Switch to uatexpress on UAT; use Ferry operations on Production | Do not retry via API |
| Request hangs without responding | Operator engine connection slow (takes 5–8 minutes) | Do not abort; switch to periodic status polling | Do not issue new call |
| Booking failed but balance partially debited | Partial issuance failure on a multi-leg booking | Inspect individual leg orders and contact Ferry support | Do not create duplicate |
Where to look on Scalar
Section titled “Where to look on Scalar”To inspect exact request schemas and test calls directly, open the Scalar UI under the relevant tags:
| Capability | Scalar tag |
|---|---|
| Confirm ticket issuance and re-download ticket files | Bookings |
| Inspect list and details of individual leg orders | Orders |
| View passenger details linked to tickets | Customers |
For instructions on configuring your API key in Scalar, see API Reference.
Read next
Section titled “Read next”| Page | Related topic |
|---|---|
| The booking flow | Booking lifecycle and payment timers |
| Payments and balances | Balance deduction mechanics and credit limits |
| Webhooks | Real-time event notifications for ticket issuance |
| Cancellation and refunds | Ticket cancellation procedures and refund terms |
| Environments | The uatexpress UAT sandbox and 12 Production operators |