Round trip flight API integration is not simply a search with a return date; multi-city flight API workflows make the distinction especially important. A production workflow must preserve journey structure, passenger identity, offer validity, segment-specific services, payment evidence, and subsequent changes. Multi-city trips add another layer: the system must distinguish a requested journey slice from the individual flights that fulfil it. This implementation walkthrough uses a fictional two-adult itinerary and illustrative responses, amounts, identifiers, and times. Nothing below describes a TravelTech365 customer deployment, an actual airline schedule, or a guaranteed Duffel offer.
Model the journey before search
The fictional travellers start at London Heathrow, connect in Frankfurt, and arrive in Rome. They then fly Rome to Madrid and finally Madrid to Heathrow. Their journey contains three requested slices but four flight segments. The distinction is foundational: Frankfurt is a connection inside the first slice, not an independent stopover requested by the shopper.
| Slice | Requested route and date | Illustrative segment detail | Product meaning |
|---|---|---|---|
| S1 | LHR to FCO, 6 May 2027 | LHR–FRA, then FRA–FCO | One outbound slice with a Frankfurt connection |
| S2 | FCO to MAD, 9 May 2027 | FCO–MAD | Independent middle journey |
| S3 | MAD to LHR, 14 May 2027 | MAD–LHR | Final return to the original city |
A conventional two-slice return from London to Rome would instead request LHR–FCO and FCO–LHR. Although the fictional three-slice journey eventually returns to London, it should be sold and serviced as multi-city, not compressed into a standard round-trip control. The distinction affects search parameters, fare construction, itinerary review, and which slice an agent can request to change.
Internally, keep stable application labels S1, S2, and S3, then attach provider-issued slice and segment IDs once received. Never submit those application labels as if they were Duffel resource IDs.
Construct a three-slice offer request
Duffel models an offer request with passengers, slices, and optional filters. Its official Offer Requests API reference defines one slice per requested origin, destination, and departure date. A connection is discovered in an offered slice's segments; it is not reliably forced by adding Frankfurt as another slice. Requesting LHR–FRA and FRA–FCO separately would express a different commercial journey.
Illustrative search payload
The following request body is a synthetic integration example. Both travellers are adults; no real passenger identities are supplied at search. A maximum of one connection permits the two-segment S1 candidate. It does not require Frankfurt, guarantee a connection, or constrain every slice to the same number of segments.
{
"data": {
"slices": [
{
"origin": "LHR",
"destination": "FCO",
"departure_date": "2027-05-06"
},
{
"origin": "FCO",
"destination": "MAD",
"departure_date": "2027-05-09"
},
{
"origin": "MAD",
"destination": "LHR",
"departure_date": "2027-05-14"
}
],
"passengers": [
{"type": "adult"},
{"type": "adult"}
],
"cabin_class": "economy",
"max_connections": 1
}
}
Send this body to POST /air/offer_requests from a trusted backend, not from client-side code containing supplier credentials. Choose return_offers=true for immediate offers or false when the application will fetch and paginate offers separately. Record the returned offer-request ID, request timestamps, live/test mode, search filters, and an internal correlation key.
The supplier timeout concerns airline search responses; it is not a booking deadline. Set your own HTTP deadline longer than the supplier timeout, then make partial-results handling visible. Validate chronological ordering of requested dates, but validate connections using actual arrival and departure timestamps, time zones, and airport identifiers from the selected offer. Dates alone cannot establish feasible transfers.
For supplier identifiers and expiry, see the travel API session and offer guide.
Normalise offers without flattening slices
An offer contains priced transport that satisfies the request. Its first slice may have two segments, while the remaining slices have one each. Store the returned nested arrays and IDs without reconstructing them from airport text. A practical internal record separates search_id, offer_id, slice_id, segment_id, and passenger_id. These keys answer different questions during booking and servicing.
Illustrative returned itinerary
Assume one fictitious matching offer reports S1 flights departing Heathrow at 08:10, departing Frankfurt at 12:05, and arriving Rome at 13:55, local times. S2 departs Rome at 10:15 and arrives Madrid at 12:55. S3 departs Madrid at 16:20 and arrives London at 17:55. These are synthetic values for interface testing, not operating schedules. Display date, airport, terminal when returned, connection duration, and time-zone context alongside each segment.
Preserve the complete offer ID in persistent storage and order submission. Truncating it for display is acceptable only in a separate presentation field; never reconstruct it from a shortened label. In test fixtures, represent an ID as FULL_OFFER_ID_FROM_RESPONSE, explicitly a placeholder, and substitute the exact complete returned string at runtime. Similarly, store every segment's returned ID for service eligibility checks rather than generating an ID from its flight number.
A normalised view is valuable for sorting, but it must not discard conditions, baggage associations, currency, operating carrier, or the offer's expiry state. When results are repriced, compare structured IDs and attributes rather than assuming the previously rendered row remains bookable.
Distinguish cabins, carriers, and fare conditions
A requested economy cabin is a search preference, not a promise that every marketed product has identical inclusions. For each returned segment, inspect the passenger-specific cabin, its marketing label when provided, the marketing carrier, and the operating carrier. A codeshare may be sold under one carrier and operated by another. Display the actual operating carrier prominently with the first offer presentation, as Duffel's reference instructs.
For results that display estimated emissions, see how to match sustainability data to the operating flight and cabin.
Do not conflate a fare brand called Flex with a changeable order. Read the returned conditions at the offer level and, where present, at slice level. Duffel's official guide to displaying offer and order conditions distinguishes change_before_departure from refund_before_departure, each with allowance and possible penalty data.
For a fictitious fare, suppose changes are allowed with a GBP 35 penalty, while refunds before departure are not allowed. Show both statements, not a generic “flexible” badge. A change can still require additional fare difference. Penalty currency can differ from offer currency, so retain currency with every amount and recalculate display conversions rather than silently assuming parity. Missing or unsupported conditions must be shown as unknown, never interpreted as free changes.
Scope optional baggage to returned identifiers
Passenger P1 asks for one optional checked bag covering the two segments of S1. Passenger P2 wants only the allowance already included with the booking and purchases no extra service. That requirement must be translated from user intent into supplier-returned passenger and segment associations. A bag for P1 is not automatically a bag for P2 or for every subsequent slice.
Fetch the chosen offer again using GET /air/offers/{id}?return_available_services=true. Duffel's official Adding Extra Bags guide describes available services and their passenger_ids, segment_ids, type, metadata, quantities, and amounts. Extra baggage booking is not available for every airline or offer; availability must come from the current response.
Illustrative eligibility check
Assume the refreshed response contains service BAG_SERVICE_ID_FROM_RESPONSE, with passenger IDs containing P1_PROVIDER_ID only, segment IDs containing both S1A_PROVIDER_SEGMENT_ID and S1B_PROVIDER_SEGMENT_ID, maximum quantity one, and GBP 42 total for one unit. These capitalised values are test placeholders, not real Duffel IDs. Permit the selection only after matching all returned associations. If the service covers just the first segment, label that limitation explicitly and do not imply through-journey baggage.
- Render P1's included baggage separately from the optional GBP 42 service, with exact segment coverage.
- Render P2's included allowance from each returned passenger-segment baggage record; do not manufacture an extra-bag service for P2.
- Keep cabin baggage distinct from checked baggage, and avoid inferring weight or piece limits not returned.
- If a refreshed offer removes the service or changes its applicability, require explicit reselection before booking.
When the order succeeds, reconcile its purchased services with the ordinary segment passenger baggage arrays. Duffel notes that booked ancillary bags appear in the order's services rather than automatically being added to the standard baggage arrays. Without this merge, an itinerary receipt can omit paid bags despite a successful purchase.

Refresh prices at the commit boundary
Search prices are offers to review, not amounts to reuse indefinitely. Before collecting final consent, retrieve the exact chosen offer again, inspect validity and current fields, and include returned services if extras are selected. Call this the fresh repricing gate. Reject an expired or unavailable offer, and reopen traveller confirmation if schedule, conditions, applicable services, or price differs materially from the previously accepted snapshot.
Illustrative payment calculation
Assume the fresh offer total for both adults is GBP 640.00, including the fare and applicable included taxes represented by that offer total. P1's eligible optional bag is GBP 42.00; P2 has no optional purchase. The illustrative amount due becomes GBP 682.00. Use decimal-safe arithmetic for display and payment reconciliation; do not perform currency maths with binary floating-point values or silently convert currencies.
| Component | Evidence | Amount |
|---|---|---|
| Flight offer, P1 and P2 | Fresh selected offer total | 640.00 |
| P1 optional bag, S1 only | Returned eligible service, quantity one | 42.00 |
| P2 optional services | None selected; booking allowance only | 0.00 |
| Illustrative payment total | Sum of current eligible components | 682.00 |
Persist separate values for the offer amount, ancillary amount, payment instruction, and final order amount. If the offer refresh yields different currency, service IDs, or passenger applicability, rebuild the ledger and ask for renewed acceptance.
Create the order with one controlled submit
The checkout service needs an application booking intent with a unique internal identifier, an immutable review snapshot, and a single active submission state. Bind the actual provider passenger IDs from the fresh offer to the complete passenger details supplied at checkout. Validate identity fields against the API's applicable requirements before submitting; an app-local P1 label is not a substitute for a returned passenger ID.
Illustrative order creation fragment
This fragment shows the significant Duffel fields, not an executable request. A production request must replace placeholders with returned complete IDs and supply valid passenger detail objects. The payment type shown assumes the merchant is eligible and funded to use balance payment.
{
"data": {
"selected_offers": [
"FULL_OFFER_ID_FROM_RESPONSE"
],
"passengers": [
{
"id": "P1_PROVIDER_ID",
"given_name": "Jordan",
"family_name": "Vale"
},
{
"id": "P2_PROVIDER_ID",
"given_name": "Casey",
"family_name": "Vale"
}
],
"services": [
{
"id": "BAG_SERVICE_ID_FROM_RESPONSE",
"quantity": 1
}
],
"payments": [
{
"type": "balance",
"currency": "GBP",
"amount": "682.00"
}
]
}
}
Submit through POST /air/orders once the customer accepts the latest terms and payable amount. Do not invent a slice_id in the service payload; the returned available service already carries the passenger and segment scope. Capture the created order ID, booking references where available, returned services, prices, itinerary, and operational state before showing a confirmed status.
Order creation can fail after payment preparation or after an uncertain network response. Therefore booking status must come from authoritative order evidence, not a successful click, a pending spinner, or an optimistic client transition.
Recover from uncertain submission and timeouts
Timeout handling is a correctness problem, not only an infrastructure problem. A client may lose the response after the supplier has created an order. Retrying order creation blindly can create duplicate reservations or payment liabilities. Separate search timeout, offer refresh failure, booking validation rejection, and unknown booking outcome into different states.
Illustrative recovery sequence
- Write the booking intent, full selected offer ID, passenger mapping, payment amount, and submission timestamp before sending the create request.
- If an order ID was received, query
GET /air/orders/{id}and compare the returned passengers, slices, and booking status with the intent. - If the response was lost before any order ID was captured, mark the outcome
confirmation_unknown; examine authoritative platform records and any provider-supported reconciliation path. Do not assume an app correlation key is searchable in Duffel. - Hold further checkout attempts for the same intent until operations reconciles the result; escalate through the supplier's supported support process when necessary.
- Notify the traveller of a pending confirmation without generating a ticket, booking reference, or success receipt that has not been verified.
A safe implementation records every state transition and the reason for it. Once a confirmed order is found, attach that existing order to the intent rather than creating a second order. If the provider confirms no order exists, a new attempt still needs a fresh offer and a renewed checkout decision.
Change only the third slice when supported
After booking, imagine P1 and P2 want to move the Madrid–Heathrow return from 14 May to 16 May 2027. The request affects S3 only. It does not authorise replacing the Heathrow–Frankfurt–Rome journey or the Rome–Madrid middle slice. Retrieve the current order first, map the returned slice IDs to local S1/S2/S3 labels, and confirm that available_actions includes change.
Duffel's official Changing an Order guide describes an order change request, returned change offers, creation of a pending change, and subsequent confirmation. These steps are conditional: not every order supports changes, and a fare condition saying changes are allowed does not by itself guarantee API servicing eligibility for this particular order.
Illustrative S3-only request
{
"order_id": "FULL_EXISTING_ORDER_ID",
"slices": {
"remove": [
{
"slice_id": "RETURNED_S3_SLICE_ID"
}
],
"add": [
{
"origin": "MAD",
"destination": "LHR",
"departure_date": "2027-05-16",
"cabin_class": "economy"
}
]
}
}
The fragment represents the change-request data, not a promise that a particular airline will return an alternative. Crucially, the remove array contains only the order's returned S3 ID. Assert in automated tests that S1 and S2 IDs are absent from the removal list. Compare offered new S3 flights, updated booking conditions, penalty, and price difference against the customer's request.
Next, select a returned order change offer and create a pending order change. Re-fetch that pending change to obtain its latest price before acceptance; the quote can move. Present the final amount and penalty distinctly. Only then confirm the pending change with the supported payment details. Check its confirmation evidence and retrieve the updated order.
Do not present a quote as a completed amendment. If there is no change action, no suitable change offer, or the pending change cannot be confirmed, keep the existing order intact and route the request for appropriate manual handling. The original S3 remains the travel plan until an authoritative confirmation says otherwise.
Separate changeability, refunds, and cancellation
Customers say “cancel my return” ambiguously. They may mean remove S3 and retain credit, obtain a refund for an unused slice, or cancel the entire booking. Those are materially different operations. The offer and order conditions explain potential refund and change rights, while order actions determine which servicing operations can be executed through the API.
Do not substitute whole-order cancellation for an S3-only change. A full order cancellation may affect all remaining journeys and both passengers. For this fictional itinerary, cancelling the order is not the same as removing MAD–LHR while retaining LHR–FCO and FCO–MAD. Require an explicit whole-order confirmation, display the applicable quoted refund or penalty, and verify the resulting order status before treating cancellation as complete.
Slice-level change conditions can differ from the overall order condition. An order-wide change flag, an individual slice rule, and the API's available action are three separate pieces of evidence. Also distinguish cancellation eligibility from refund amount: a non-refundable fare may have a different permitted service path, and an unknown penalty must not be displayed as zero.
Identify open jaws and surface gaps
The main scenario is continuous between slices: S1 ends at FCO where S2 begins; S2 ends at MAD where S3 begins. Frankfurt is a flight connection within S1. There is no inter-slice surface sector in this base itinerary, even though the shopper spends time in Rome and Madrid.
Now consider a deliberate variation: S1 ends at FCO, but S2 begins at Naples (NAP). The journey has a FCO-to-NAP surface gap not provided by the flight offer. Or suppose S3 ends at London Gatwick rather than Heathrow: the last airport differs from the starting airport. Depending on how the itinerary is marketed, this is an open-jaw or multi-airport return characteristic that deserves explicit review.
Implement a gap detector by comparing each slice's destination airport with the next slice's origin airport. Flag unequal codes, but do not silently substitute city-level equivalence or assume a transfer exists. Show the exact endpoints, an “independent ground transport required” warning when appropriate, and whether the first and final airports match. If the airport difference is within one metropolitan area, still disclose the change of airport.
These checks belong in results, checkout, itinerary documents, and modification screens. Never bill a ground transfer unless one is independently selected and confirmed. An incomplete ground plan is not itself a reason to alter the provider's flight graph.
Trace evidence from request to servicing
A request-to-servicing evidence matrix makes it possible to distinguish data that the shopper requested, data the supplier actually returned, and decisions the application must enforce. The following filled matrix uses synthetic values and named placeholders; its observations are illustrative fixture outcomes, not live API responses or production success claims.
| Stage | Illustrative evidence captured | Required decision or handoff |
|---|---|---|
| Search | Two adults; 6, 9, 14 May; economy; max one connection | Persist request and returned offer-request ID |
| Journey | S1 LHR–FRA–FCO; S2 FCO–MAD; S3 MAD–LHR | Keep three slices and four segment records |
| Offer | FULL_OFFER_ID_FROM_RESPONSE; illustrative GBP 640.00 | Store exact full ID and original snapshot |
| Operating data | Four segment operators and per-passenger cabin values | Show operators, cabin distinctions, local times |
| Included bags | P2: fixture shows one cabin bag per segment, no purchased extras | Verify independently for each segment |
| P1 extra bag | One GBP 42.00 service eligible for P1 on S1A and S1B | Match returned passenger and segment IDs |
| Conditions | Illustrative GBP 35 change penalty; refund disallowed | Display exact scope and currency |
| Repricing | Refreshed offer GBP 640.00 plus bag GBP 42.00 | Reconfirm GBP 682.00 before submit |
| Confirmation | FULL_EXISTING_ORDER_ID and returned services | Issue receipt only after order verification |
| Timeout | Unknown response, order ID potentially unavailable | Reconcile status; block blind duplicate create |
| S3 servicing | Remove RETURNED_S3_SLICE_ID, request 16 May | Quote pending change, then confirm if supported |
| Cancellation | Whole-order action distinct from S3 replacement | Require separate explicit customer intent |
For operational use, attach request and response timestamps, a redacted provider payload reference, acceptance version, internal user or agent actor, and a final reconciliation status to each row.
Design resilient boundaries and tests
Separate search, pricing, order orchestration, and servicing modules. Search can be retried with fresh requests; order creation needs duplicate-prevention controls; a confirmed order requires identity-bound servicing permissions.
Build contract fixtures for an S1 with two segments, an S3 with a single segment, missing baggage services, mixed marketing and operating carriers, expired offers, and penalty currencies different from offer currency. Test optional bag association with deliberately wrong passenger and segment IDs; the checkout must reject both. Test display strings for local date rollover and airports within the same city but different codes.
Exercise a booking timeout at the point after the provider accepts the request but before the response reaches your server. The application should enter an unknown state and forbid immediate resubmission. Also test S3-only change requests against orders without change in available_actions, against empty change offers, and against a changed pending quote. None should quietly mutate S1 or S2.
Verification and handoff checklist
Before shipping, require a reproducible test packet containing the request, redacted result, fresh offer, selected service associations, consented pricing ledger, order confirmation, and any servicing evidence. The following checklist is the acceptance contract for engineering, QA, product, and support; every unchecked item blocks release or requires a documented scope exception.
- Verify two adult passengers and exactly S1 LHR–FCO, S2 FCO–MAD, S3 MAD–LHR; show Frankfurt only as S1's connecting segment.
- Verify all displayed flight times, terminals, operators, cabin labels, and included baggage against returned segment and passenger objects.
- Verify full offer, passenger, segment, slice, service, and order IDs are retained without truncation in machine-to-machine requests.
- Verify P1's optional bag matches the returned allowed passenger and S1 segment IDs; P2 has no purchased service and keeps only confirmed booking allowance.
- Verify current offer conditions and fresh repricing are displayed with currencies and accepted before payment or order creation.
- Verify a timeout triggers authoritative order lookup or supplier reconciliation, never an immediate duplicate order submission.
- Verify an S3-only change removes only the returned S3 slice ID, compares available offers, refreshes the pending quote, and confirms solely when supported.
- Verify whole-order cancellation is a distinct authorised workflow, not an accidental shortcut for changing a return leg.
- Verify open jaws, surface gaps, and alternate-airport returns are visibly marked without inventing transfer coverage.
- Hand off redacted fixtures, API field mappings, failure-state runbooks, customer-copy wording, audit identifiers, and ownership for unresolved provider cases.
The implementation is ready for handoff only when a reviewer can reproduce both the successful booking path and the uncertain or unsupported paths without guessing which supplier object, passenger, journey slice, or payment amount the system intended to act upon.
