Skip to main content

Flight v2 API Guideline

Flight v2 is the multi-provider flight flow. A single set of endpoints fans out to every flight provider enabled for your partner account, merges the results, and completes the booking through the shared Unified Booking checkout used by all Onlynx products.

:::info Flight v1 vs Flight v2 The Flight section documents the original single-provider (Fliggy) flow, where booking was submitted to a flight-only make-order endpoint. Flight v2 keeps the same search → enrich → pricing → ancillary stages, but the booking itself is created through /unified-booking/checkout and /unified-booking/checkout/confirm, so a flight can share a cart, a payment and a booking number with hotels, tours and transfers.

Both are live. Flight v2 is the recommended integration for new partners. :::

Providers

Three providers sit behind the same endpoints:

Providerprovider in responseIdentifier prefixNotes
FliggyFLIGGY(none)Legacy default. No seat map.
HititHITITHITIT_Baggage + meal ancillaries, seat map.
FlightRouteFLIGHTROUTEFR24_Baggage ancillaries, seat map.

You never select a provider explicitly. Every identifier you receive (solutionId, session_id) carries its provider prefix, and the API routes the follow-up call for you. Which providers are queried is controlled by the flight providers enabled on your partner account, so an account may see results from one, two or all three.

Base URLs

  • UAT (Testing/Development): https://api.dev.onlynx.co.th
  • Production: https://api.onlynx.co.th

All Flight v2 endpoints are under the /api/v1 prefix.

Headers

Every endpoint in this section accepts the same headers.

HeaderValueRequiredDescription
Partner-Access-TokenBase64 StringYesYour encrypted AES-256 time-sensitive token.
X-CurrencyCurrency CodeOptionalDisplay currency, e.g. THB, MMK, USD. Falls back to your partner default, then THB.
Accept-LanguageLanguage CodeOptionale.g. en, th, my. Falls back to en.
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes

The four My Bookings endpoints additionally require an end-user token:

HeaderValueRequiredDescription
AuthorizationBearer <token>YesCustomer access token from the Login endpoint.

Response Envelope

Every JSON endpoint returns the same envelope.

{
"result": 1,
"message": "success",
"data": { },
"meta": { }
}
FieldTypeDescription
resultInteger1 on success, 0 on failure.
messageStringHuman-readable status or error message.
dataObject/ArrayPayload. Omitted on plain failure responses.
metaObjectPresent only on endpoints that return one (pricing, checkout, booking list).

A failed call still returns HTTP 200 with "result": 0 and a message. Validation errors are returned as HTTP 422 in Laravel's standard shape:

{
"message": "The products.0.passengers.0.document_number field is required.",
"errors": {
"products.0.passengers.0.document_number": [
"Passenger document number is required."
]
}
}

Authentication failures return HTTP 401 with {"error": "..."}.

Key Casing

The two endpoint families differ, and this catches integrations out:

EndpointsCasing
/flights/*Provider payloads keep their original camelCase keys — solutionId, journeyList, segmentList, pricingDetails.
/unified-booking/*The whole response is converted to snake_casesolution_id, journey_list, segment_list, pricing_details.
/bookings*Not converted. Nested provider payloads keep camelCase.

All-uppercase keys (ADT, CHD) and keys containing punctuation or spaces ("0-0", "Checked Baggage") are never converted.

Booking Flow

Identifier Lifecycle

This is the part that most often trips up an integration. Flight v2 uses three different identifiers, and each one is produced by one endpoint and consumed by another.

IdentifierProduced byConsumed byMeaning
solutionId/flights/search/flights/enrich, /flights/pricing, /flights/ancillary, /flights/seat-map (as solution_id)A specific priced itinerary from a provider.
session_id (pricing)/flights/pricing/unified-booking/checkout and /checkout/confirm (as products[].solution_id)The confirmed, margined price snapshot.
session_id (ancillary / seat map)/flights/ancillary, /flights/seat-mappassengers[].ancillary.session_id, passengers[].selected_seats[].session_idThe priced add-on snapshot.

:::danger The most common integration mistake At checkout, products[0].solution_id must be the session_id returned by /flights/pricingnot the solutionId you got from /flights/search.

Passing the search solutionId will fail with Flight pricing details not found or expired. Please search again. :::

Sessions are short-lived. If the customer idles between pricing and checkout, re-run /flights/pricing to obtain a fresh session_id before confirming.

Currency Layers

Three currencies are in play on every flight response. Knowing which is which prevents reconciliation surprises.

LayerField suffixDescription
Providerprovider_price, original_priceThe raw amount the airline/provider quoted, in the provider's own currency.
System_thb (e.g. grand_total_thb, fare_thb)THB. The internal base currency all margin maths and stored booking totals use.
Displayno suffix (e.g. grand_total, fare)The customer-facing amount, in the currency you requested via X-Currency.

Margins (admin + partner) are applied at the THB layer, then converted out to the display currency. The amount the customer is charged is the display value; the amount stored on the booking is the system value.

Product Type

Flights are product type pd9 in the Unified Booking payload, for all three providers.

Endpoints

#EndpointMethodPurpose
1/api/v1/flights/airportsGET/POSTAirport & city lookup. See Flight › Airports.
2/api/v1/flights/searchPOSTMulti-provider availability search.
3/api/v1/flights/enrichPOSTBaggage allowance and refund/change rules.
4/api/v1/flights/pricingPOSTFinal price + pricing session_id.
5/api/v1/flights/ancillaryPOSTExtra baggage and meals.
6/api/v1/flights/seat-mapGETSeat map with per-seat pricing.
7/api/v1/flights/bookings/*POSTDirect flight booking, ticket issue, cancel, refund.
8/api/v1/unified-booking/checkoutPOSTCart review and totals.
9/api/v1/unified-booking/checkout/confirmPOSTCreate the booking.
10/api/v1/unified-booking/resultPOSTPost-payment booking result.
11/api/v1/bookingsGET/POSTCustomer's booking list.
12/api/v1/bookings/{booking_number}GET/POSTFull booking detail.
13/api/v1/bookings/{id}/voucherGETDownload voucher PDF. KKday only — not for flights.
14/api/v1/bookings/{booking_number}/items/{id}/cancelPOSTCancel a booking item. Tour and KKday only — flights cancel via Booking.

:::caution Two shared endpoints do not cover flights /bookings/{id}/voucher and /bookings/{booking_number}/items/{id}/cancel are shared across all Onlynx products but do not currently handle flight items. Each page explains the flight alternative. :::