{"openapi":"3.0.3","info":{"title":"SERVER FLIGHT API","version":"2.1.0","description":"Aggregator API gộp chuyến bay + đặt chỗ + xuất vé từ 3 NCC (BGT/HNH/HPL), phục vụ đại lý & website đối tác.\n\n## Quick start\n1. Xin `X-API-Key` từ DLV Tech (env var `API_KEY_DEFAULT` / `AGENCY_KEY_<name>`).\n2. `POST /api/v1/flights/search` → lấy `data.fares[].fareSelectionId` của 1 option.\n3. `POST /api/v1/flights/bookings` với `fareSelectionId + passengers + contact` → nhận `data.bookingRef`.\n4. `POST /api/v1/flights/bookings/{ref}/issue` → xuất vé.\n5. Mọi op sau đều qua `bookingRef` hoặc `ticketNo` — aggregator tự dispatch về NCC sở hữu.\n\n## Quan trọng\n- **Raw envelope**: mọi response dạng `{ ok, traceId, supplier, operation, data, error? }`. Parse `data` khi `ok=true`.\n- **Cache**: search có SWR cache (`fresh<180s`, `stale<900s`). Stale vẫn dùng được — server refresh background.\n- **totalPrice**: unified = `(fareAdt+taxAdt)*adt + (fareChd+taxChd)*chd + (fareInf+taxInf)*inf`. Raw supplier total giữ trong `totalPriceSupplier`.\n- **SSE /search-stream** emit per-NCC chunk `{type:\"supplier\", ...}` khi ready, kết thúc `{type:\"envelope\"}` + `[DONE]`.\n- **Multi-city**: pass `flights[]` array. **Round-trip**: pass `returnDate`. Cache key bao gồm filter.\n- **Codeshare**: filter `airlines:[BL]` match cả `leg.operatingCarrier=BL` (VN-sell/BL-operate).\n- **Supplier limits**: GDS quốc tế qua `airdata`; `tripota` hỗ trợ VN/VJ/QH/9G/1A; `skeeper` hiện chỉ VU (VN/QH tạm ẩn — HPL data thiếu kg baggage). Mở rộng qua env `AIRDATA_SOURCES`, `TRIPOTA_SYSTEMS`, `SKEEPER_AIRLINES`.\n\n## Vòng đời sau vé (canonical modules)\nCác nghiệp vụ sau-vé dùng module chuẩn hoá thay cho passthrough adapter trực tiếp. Mỗi module theo cùng khuôn: **đọc state NCC trước (retrieve/eligibility) → báo giá (quote/options) → thực thi idempotent → đối soát (retrieve)**.\n- **Refund** `/flights/refunds/*` — retrieve / quote / submit / status.\n- **Exchange** `/flights/exchanges/*` — eligibility / search-options / quote / execute / {ref}/retrieve.\n- **Upgrade** `/flights/upgrades/*` — retrieve / options / reprice / confirm / {ref}/retrieve-after / capability.\n- **Split** `/flights/splits/*` — eligibility / (execute) / {ref}/retrieve.\nĐặc điểm chung: **deny-default** (chỉ live khi bật env `FLIGHT_<MODULE>_ENABLED` + `..._LIVE_EXECUTE_ENABLED` + supplier nằm trong `..._SUPPORTED_SUPPLIERS`), **idempotent** (gửi `X-Idempotency-Key`), eligibility-gate TRƯỚC khi gọi NCC, và **timeout/5xx → state `unknown`** (KHÔNG bao giờ auto-retry — tra lại qua endpoint `retrieve`/`status`).\n\n## Idempotency\nMọi op mutate-tiền (book/issue/void/refund/exchange/upgrade/split) nhận header `X-Idempotency-Key`. Gửi lại cùng key sẽ **replay** kết quả cũ thay vì gọi NCC lần nữa (header `x-idempotent-replay: true`). Bắt buộc để IPN/retry không double-book/issue.\n\n## Error model\nEnvelope `ok=false` kèm `error.code`:\n- `VALIDATION` — schema sai (Zod reject) → 400\n- `BOOKING_NOT_FOUND` / `TICKET_NOT_FOUND` → 404\n- `FARE_EXPIRED` — `fareSelectionId` quá 60 phút → 404\n- `SUPPLIER_REJECTED` — NCC upstream trả lỗi (giữ raw trong `supplierMessage`) → 409\n- `SOURCE_POLICY_BLOCKED` — vé VJ/VN do GDS (1A/1G/GALILEO_NDC) phân phối, KHÔNG được bán → 409. `details` gồm `operation`, `supplier`, `supplierSource`, `sourceSystem`, `carriers[]`. Không gọi NCC. Xem `docs/dlv-source-policy.md`.\n- `DISPLAY_POLICY_BLOCKED` — chính sách hiển thị của KÊNH đang gọi ẩn vé này (tắt NCC hoặc tắt hãng) → 409 ở /price-quote và /bookings, `retryable: false`. `details.reason`: `SUPPLIER_HIDDEN` (được mời vé cùng chuyến của NCC khác) | `AIRLINE_HIDDEN` (tìm lại). Kèm `supplier`, `airlines[]`, `market`, `channel`, `policyVersion`. Không gọi NCC. Đơn đã có (issue / huỷ / hoàn…) không bị chặn.\n- `NOT_SUPPORTED_BY_OWNING_SUPPLIER` → 501\n- `NO_SUPPLIER` — không NCC nào có capability → 501\n- `SELLING_PRICE_CHANGED` — lúc book, khoản giảm giá bán của vé GDS nhỏ hơn lúc search (rule hết hạn / bị tắt, chế độ chuyển `off`) → 409. `data` có `oldSellingPrice`, `newSellingPrice`, `oldDiscountTotal`, `newDiscountTotal`, `currency` (+ `legs[]` khi book nhiều vé). Chưa gọi `book` của NCC. Xác nhận giá mới với khách rồi book lại **bằng Idempotency-Key mới** — lần book lại dùng giá mới\n\n## Giá bán vé GDS (selling price)\nChế độ đặt theo từng NCC qua API admin (`/admin/selling-price/*`), đổi lúc đang chạy:\n- `off` — `totalPrice` = giá NCC, không có field nào thêm (mặc định).\n- `shadow` — `totalPrice` vẫn = giá NCC; vé GDS có thêm `sellingPrice`, `discountTotal`, `pricing` để đối soát. Khách chưa thấy.\n- `on` — `totalPrice` = **giá bán**; `netTotalPrice` = giá NCC; thêm `discountTotal`, `pricing`. Giá từng khách `fareAdt/taxAdt/priceAdt` (Chd, Inf) **cũng đã trừ giảm** (giá NCC ở `netFareAdt/netTaxAdt/netPriceAdt`), nên `(fareAdt+taxAdt)×adt + … = totalPrice`.\n\nMỗi vé GDS mang `pricing.mode`, response search mang `data.pricing` (`version`, `mode`, `modeByPartner`, `validUntil`) → luôn biết `totalPrice` là giá bán hay giá NCC. Vé không phải GDS không có `pricing`.\n- **Price-quote**: tính từ giá NCC vừa verify; ở `on` thì `totalPrice` = giá bán, `netTotalPrice` = giá NCC. Giá có giảm được **giữ 60 phút** (`pricing.lockedUntil`): book trong thời hạn giữ nguyên khoản giảm đã báo dù rule vừa tắt (`pricing.locked = true` ở lần báo giá sau).\n- **Book / retrieve / issue**: `data.totalPrice` **luôn là giá NCC của PNR** ở mọi chế độ. Booking có giảm giá thêm `sellingPrice`, `discountTotal`; `price_breakdown.flight_total` = giá NCC, `price_breakdown.discount_total` = khoản giảm, **số tiền thu khách = `price_breakdown.payable_total`**.\n\n## Chính sách hiển thị (NCC + hãng bay, theo kênh)\nCấu hình qua API admin `/admin/display/*` (key admin riêng). **Kênh** = nhóm tên key API ở gateway; key không thuộc kênh nào dùng profile `DEFAULT`. Mỗi profile: bật/tắt NCC (+ ưu tiên, nhãn, ghi đè theo hãng) và bật/tắt hãng theo thị trường Nội địa / Quốc tế (nội địa = mọi sân bay ở Việt Nam). Server tự áp cho người gọi:\n- **Search** (JSON + mọi event SSE, gồm `meta.suppliers`): vé của NCC / hãng bị tắt không xuất hiện ở bất kỳ view nào; `equivalentFares` không chứa NCC tắt; nhóm gộp giữa các NCC chọn đại diện trong NCC đang bật (`mode: all` → rẻ nhất, `priority` → ưu tiên rồi giá). `data.totals.display` cho biết đã ẩn gì. Cache dùng chung, không phụ thuộc chính sách — bật lại có ngay, không search lại.\n- **Chọn NCC theo hãng × thị trường**: `markets.<m>.airlines.<IATA>` = `{ shown?, suppliers?: { <ncc>: bool } }` (bool cũ = `{ shown }`). `suppliers` GHI ĐÈ công tắc NCC cho hãng × thị trường đó: `true` bật NCC kể cả khi NCC tắt toàn cục, `false` tắt, thiếu key = theo công tắc toàn cục. NCC không chạy hoặc bị công tắc ops ẩn thì `true` không bật được. Chuyến nhiều hãng: NCC phải được phép với MỌI hãng bán. Dòng khai `suppliers` thắng `supplierAirlines` (deprecated) cho hãng × thị trường đó. `airline` ghép kiểu `\"FD | XJ\"` được tách từng mã.\n- **Lịch min-fare**: dòng của NCC / hãng bị tắt bị loại trước khi chọn giá rẻ nhất mỗi ngày.\n- **Đặt vé**: `DISPLAY_POLICY_BLOCKED` (xem Error model).\nĐọc cấu hình của chính mình (nhãn, ưu tiên, version): `GET /flights/display-policy` bằng key thường. Chưa cấu hình → mọi response như cũ.\n\n## Test UI\n- Swagger UI: [`/api/v1/docs-ui`](/api/v1/docs-ui) — try-it-out interactive\n- Raw spec JSON: [`/api/v1/openapi.json`](/api/v1/openapi.json) — import Postman/Insomnia\n- Search playground: [`/`](/)","contact":{"name":"DLV Tech","email":"dat.le@blueboltsoftware.com"},"license":{"name":"Internal"}},"servers":[{"url":"/api/v1","description":"Current host (relative)"}],"security":[{"ApiKeyAuth":[]}],"tags":[{"name":"Search","description":"Tìm kiếm chuyến bay (fan-out 3 NCC + merge + filter)"},{"name":"Pricing","description":"Báo giá lại, fare rules, min-fare calendar"},{"name":"PreBookAncillary","description":"Seat-map / hành lý / dịch vụ theo fareSelectionId (chưa đặt)"},{"name":"Booking","description":"Hold / retrieve / hold-status / events / cancel / issue (gồm RT 2-PNR parent)"},{"name":"BookingAncillary","description":"Seat / hành lý / dịch vụ trên PNR đã đặt"},{"name":"Modify","description":"Thêm-đổi-hủy hành trình, thêm em bé, sửa pax, tách PNR"},{"name":"PNROps","description":"Remarks / OSI / SK / passport / membership"},{"name":"Tickets","description":"Void + (legacy) refund/exchange passthrough theo bookingRef hoặc ticketNo. Dùng module Refund/Exchange chuẩn hoá bên dưới cho luồng production."},{"name":"Refund","description":"Module hoàn vé chuẩn (retrieve → quote → submit → status) — eligibility-gated + idempotent"},{"name":"Exchange","description":"Module đổi vé/reissue chuẩn (eligibility → search-options → quote → execute → retrieve)"},{"name":"Upgrade","description":"Module nâng hạng (retrieve → options → reprice → confirm → retrieve-after)"},{"name":"Split","description":"Tách hành khách ra PNR riêng (eligibility → execute → retrieve)"},{"name":"Comms","description":"Email / queue / face / print / update contact"},{"name":"FlightInfo","description":"Tình trạng chuyến bay"},{"name":"Ops","description":"Tiện ích đại lý: credit balance, distributor khả dụng"},{"name":"Meta","description":"Health / OpenAPI / suppliers"},{"name":"SellingPriceAdmin","description":"Bật / tắt giá bán vé GDS và quản lý rule giảm giá. **Key admin riêng** (`ADMIN_KEY_<TÊN>`, gửi qua `X-API-Key`) — key đại lý bị từ chối."},{"name":"DisplayPolicyAdmin","description":"Chính sách hiển thị theo kênh: bật/tắt NCC (ưu tiên, nhãn, ghi đè theo hãng) và bật/tắt hãng bay theo Nội địa / Quốc tế. **Key admin riêng** (`ADMIN_KEY_<TÊN>`) — key đại lý bị từ chối."}],"paths":{"/health":{"get":{"tags":["Meta"],"summary":"Health check (gateway + aggregator)","security":[],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"service":"api-gateway","status":"ok","aggregator":{"service":"flight-aggregator","status":"ok","traceId":"abc"}}}}}}}},"/openapi.json":{"get":{"tags":["Meta"],"summary":"Spec này (JSON)","security":[],"responses":{"200":{"description":"OpenAPI 3.0 document"}}}},"/docs-ui":{"get":{"tags":["Meta"],"summary":"Swagger UI (try-it-out)","security":[],"responses":{"200":{"description":"HTML page","content":{"text/html":{}}}}}},"/docs":{"get":{"tags":["Meta"],"summary":"Legacy docs JSON (deprecated — dùng /openapi.json)","security":[],"deprecated":true,"responses":{"200":{"description":"Legacy format"}}}},"/suppliers":{"get":{"tags":["Meta"],"summary":"Danh sách NCC + capability matrix","responses":{"200":{"description":"Suppliers & their supported operations","content":{"application/json":{"example":{"ok":true,"suppliers":[{"code":"airdata","ops":["search","book","issue"]},{"code":"tripota","ops":["search","book","issue","void","refund"]},{"code":"skeeper","ops":["search","book","issue"]}],"matrix":{}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/flights/search":{"post":{"tags":["Search"],"summary":"Tìm chuyến bay (REST fan-out 3 NCC)","description":"Fan-out BGT/HNH/HPL song song, merge + sort theo `totalPrice`. Filter `airlines/preferCabin/promoCode` apply post-aggregation, cache key bao gồm filter. Cold miss 5-40s; hit cache < 50ms.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"},"example":{"startPoint":"SGN","endPoint":"HAN","departDate":"2026-12-20","returnDate":"2026-12-25","adt":2,"chd":1,"inf":1,"airlines":["VN","VJ","QH","VU","BL"],"preferCabin":"Y","promoCode":""}}}},"responses":{"200":{"description":"Envelope chứa `data.fares[]`, `data.combos[]` (RT only, GDS-bundled), `data.suppliers{}`, `data.totals{}` (incl. `combosBuilt`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchEnvelope"},"example":{"ok":true,"traceId":"abc123","supplier":"aggregator","operation":"search","capability":{"supported":true,"notes":null},"latencyMs":35327,"data":{"fares":[{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","supplier":"airdata","supplierSource":"VN1A","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"selectionMode":"SEPARATE_LEGS","pairingMode":"USER_SELECT","currency":"VND","totalPrice":11165500,"totalPriceSupplier":3741000,"fareAdt":2937000,"taxAdt":804000,"fareChd":2644000,"taxChd":721500,"fareInf":294000,"taxInf":24000,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"05:00","arriveTime":"07:10","duration":130,"aircraft":"321","cabin":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","seatsAvailable":9,"baggage":"1 PCs x 23kg"}],"fareConditions":{"cabinName":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","groupClass":"EF","refundable":true,"baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"penalties":null},"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","supportedOps":["book","hold","issue","retrieveBooking","faceBooking","modifyCancelFlights","seatAdd","baggageAdd","ancillaryAdd"],"unsupportedOps":["void","refund","exchange","addRemark","addOsi","addSk","addDocument","addMembership","split","modifyAddFlights","modifyPaxInfo","modifyAddInfant","sendEmail","queuePlace","printTicket","checkinOnline","computeEmission","ancillaryDelete","baggageDelete","seatDelete","cancelBooking"]}],"fareGroups":[{"groupId":"fg_3a9c1f0b8e2d4a67","grouped":true,"flightKey":"VN|VN6002|2026-12-20|05:00|SGN|HAN","tripDirection":"oneway","airline":"VN","supplier":"tripota","supplierSource":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","fareFamily":"Economy Lite","fareFamilyCode":"ECONOMY_LITE","currency":"VND","baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"conditions":{"refundable":true,"changeable":null,"penalties":null},"representativeFareId":"fs_1","priceFrom":1480000,"priceTo":1500000,"fareCount":2,"alternativeCount":1,"members":[{"fareSelectionId":"fs_1","totalPrice":1480000,"currency":"VND","fareBasis":"TLOWVN","bookingClass":"T","supplier":"tripota","supplierSource":"VN","airline":"VN","holdSupported":true,"requiresManualIssue":false},{"fareSelectionId":"fs_2","totalPrice":1500000,"currency":"VND","fareBasis":"NLOWVN","bookingClass":"N","supplier":"tripota","supplierSource":"VN","airline":"VN","holdSupported":true,"requiresManualIssue":false}],"reason":{"basis":"fare-family","matched":["flight","cabin","fareFamily","baggage"],"fareFamily":"Economy Lite","fareFamilyCode":"ECONOMY_LITE","cabinCanonical":"ECONOMY","baggageText":{"checked":"1 PCs x 23kg","carryOn":"(1 piece + 1 accessory) not exceed 10kg"},"penaltiesKnown":false}}],"groupedFlights":[{"flightKey":"VN|VN6002|2026-12-20|SGN|HAN","groupKey":"VN|VN6002|2026-12-20|SGN|HAN::VNA_DIRECT","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"2026-12-20T05:00:00Z","arriveTime":"2026-12-20T07:10:00Z","duration":130,"aircraft":"321"}],"startPoint":"SGN","endPoint":"HAN","departTime":"2026-12-20T05:00:00Z","arriveTime":"2026-12-20T07:10:00Z","tripDirection":"oneway","minPrice":1480000,"maxPrice":5500000,"currency":"VND","supplierCount":2,"suppliers":["airdata","tripota"],"fareCount":3,"cabinOptions":[{"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","minPrice":1480000,"maxPrice":1500000,"suppliers":["airdata","tripota"],"fareCount":2,"fareSelectionIds":["fs_1","fs_2"]},{"cabinCanonical":"BUSINESS","cabinDisplay":"Thương gia","minPrice":5500000,"maxPrice":5500000,"suppliers":["airdata"],"fareCount":1,"fareSelectionIds":["fs_3"]}],"fares":[{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","supplier":"airdata","supplierSource":"VN1A","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"selectionMode":"SEPARATE_LEGS","pairingMode":"USER_SELECT","currency":"VND","totalPrice":11165500,"totalPriceSupplier":3741000,"fareAdt":2937000,"taxAdt":804000,"fareChd":2644000,"taxChd":721500,"fareInf":294000,"taxInf":24000,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"05:00","arriveTime":"07:10","duration":130,"aircraft":"321","cabin":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","seatsAvailable":9,"baggage":"1 PCs x 23kg"}],"fareConditions":{"cabinName":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","groupClass":"EF","refundable":true,"baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"penalties":null},"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","supportedOps":["book","hold","issue","retrieveBooking","faceBooking","modifyCancelFlights","seatAdd","baggageAdd","ancillaryAdd"],"unsupportedOps":["void","refund","exchange","addRemark","addOsi","addSk","addDocument","addMembership","split","modifyAddFlights","modifyPaxInfo","modifyAddInfant","sendEmail","queuePlace","printTicket","checkinOnline","computeEmission","ancillaryDelete","baggageDelete","seatDelete","cancelBooking"]}]}],"suppliers":{"airdata":{"supplier":"airdata","name":"airdata","count":148,"traceId":"gO930n37ozubnyUVtJWe","latencyMs":30658,"fromCache":null,"fares":[{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","supplier":"airdata","supplierSource":"VN1A","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"selectionMode":"SEPARATE_LEGS","pairingMode":"USER_SELECT","currency":"VND","totalPrice":11165500,"totalPriceSupplier":3741000,"fareAdt":2937000,"taxAdt":804000,"fareChd":2644000,"taxChd":721500,"fareInf":294000,"taxInf":24000,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"05:00","arriveTime":"07:10","duration":130,"aircraft":"321","cabin":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","seatsAvailable":9,"baggage":"1 PCs x 23kg"}],"fareConditions":{"cabinName":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","groupClass":"EF","refundable":true,"baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"penalties":null},"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","supportedOps":["book","hold","issue","retrieveBooking","faceBooking","modifyCancelFlights","seatAdd","baggageAdd","ancillaryAdd"],"unsupportedOps":["void","refund","exchange","addRemark","addOsi","addSk","addDocument","addMembership","split","modifyAddFlights","modifyPaxInfo","modifyAddInfant","sendEmail","queuePlace","printTicket","checkinOnline","computeEmission","ancillaryDelete","baggageDelete","seatDelete","cancelBooking"]}]},"tripota":{"supplier":"tripota","name":"tripota","count":79,"traceId":"gO930n37ozubnyUVtJWe","latencyMs":30658,"fromCache":null,"fares":[{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","supplier":"airdata","supplierSource":"VN1A","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"selectionMode":"SEPARATE_LEGS","pairingMode":"USER_SELECT","currency":"VND","totalPrice":11165500,"totalPriceSupplier":3741000,"fareAdt":2937000,"taxAdt":804000,"fareChd":2644000,"taxChd":721500,"fareInf":294000,"taxInf":24000,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"05:00","arriveTime":"07:10","duration":130,"aircraft":"321","cabin":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","seatsAvailable":9,"baggage":"1 PCs x 23kg"}],"fareConditions":{"cabinName":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","groupClass":"EF","refundable":true,"baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"penalties":null},"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","supportedOps":["book","hold","issue","retrieveBooking","faceBooking","modifyCancelFlights","seatAdd","baggageAdd","ancillaryAdd"],"unsupportedOps":["void","refund","exchange","addRemark","addOsi","addSk","addDocument","addMembership","split","modifyAddFlights","modifyPaxInfo","modifyAddInfant","sendEmail","queuePlace","printTicket","checkinOnline","computeEmission","ancillaryDelete","baggageDelete","seatDelete","cancelBooking"]}]},"skeeper":{"supplier":"skeeper","name":"skeeper","count":79,"traceId":"gO930n37ozubnyUVtJWe","latencyMs":30658,"fromCache":null,"fares":[{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","supplier":"airdata","supplierSource":"VN1A","airline":"VN","_dlvSourceSystem":"VNA_DIRECT","_dlvSourceGroup":"DIRECT","_dlvSourceRank":0,"selectionMode":"SEPARATE_LEGS","pairingMode":"USER_SELECT","currency":"VND","totalPrice":11165500,"totalPriceSupplier":3741000,"fareAdt":2937000,"taxAdt":804000,"fareChd":2644000,"taxChd":721500,"fareInf":294000,"taxInf":24000,"legs":[{"airline":"VN","operatingCarrier":"BL","flightNumber":"VN6002","startPoint":"SGN","endPoint":"HAN","departTime":"05:00","arriveTime":"07:10","duration":130,"aircraft":"321","cabin":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","seatsAvailable":9,"baggage":"1 PCs x 23kg"}],"fareConditions":{"cabinName":"ECONOMY FLEX","fareBasis":"BVNF","bookingClass":"B","groupClass":"EF","refundable":true,"baggage":{"checked":{"included":true,"pieces":1,"weight":23,"unit":"KG","text":"1 PCs x 23kg"},"carryOn":{"included":true,"pieces":1,"text":"(1 piece + 1 accessory) not exceed 10kg"}},"penalties":null},"cabinCanonical":"ECONOMY","cabinDisplay":"Phổ thông","supportedOps":["book","hold","issue","retrieveBooking","faceBooking","modifyCancelFlights","seatAdd","baggageAdd","ancillaryAdd"],"unsupportedOps":["void","refund","exchange","addRemark","addOsi","addSk","addDocument","addMembership","split","modifyAddFlights","modifyPaxInfo","modifyAddInfant","sendEmail","queuePlace","printTicket","checkinOnline","computeEmission","ancillaryDelete","baggageDelete","seatDelete","cancelBooking"]}]}},"totals":{"totalFares":306,"crossNccCollapsed":0,"totalFlights":87,"totalFareGroups":290,"totalSuppliers":3,"skippedSuppliers":[],"degraded":false}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"502":{"$ref":"#/components/responses/BadGateway"}}}},"/flights/search-stream":{"post":{"tags":["Search"],"summary":"Tìm chuyến bay (SSE stream per-NCC)","description":"Server-Sent Events. Sequence:\n\n```\ndata: {\"type\":\"supplier\",\"supplier\":\"skeeper\",\"count\":38,\"fares\":[...]}\n\ndata: {\"type\":\"supplier\",\"supplier\":\"airdata\",\"count\":154,...}\n\ndata: {\"type\":\"supplier\",\"supplier\":\"tripota\",\"count\":79,...}\n\ndata: {\"type\":\"envelope\",\"envelope\":{...full merged...}}\n\ndata: [DONE]\n\n```\nClient có thể render tab NCC trước khi NCC chậm nhất xong. Cache hit thì emit toàn bộ ngay.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"},"example":{"startPoint":"SGN","endPoint":"HAN","departDate":"2026-12-20","returnDate":"2026-12-25","adt":2,"chd":1,"inf":1,"airlines":["VN","VJ","QH","VU","BL"],"preferCabin":"Y","promoCode":""}}}},"responses":{"200":{"description":"SSE stream","content":{"text/event-stream":{}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/flights/min-fare":{"post":{"tags":["Pricing"],"summary":"Min-fare calendar by month or date range (v1: skeeper only)","description":"Returns the cheapest fare per day for a given month, or for a `fromDate`→`toDate` range (max 31 days — HPL limit; send `month` OR the range, not both). v1 supports skeeper (HPL) only. airdata is excluded by default (BGT no-spam rule). Response is a date-keyed map.\n\nReturns HTTP 501 when no supplier supports the capability (e.g. skeeper disabled via env).\n\n**Giá bán vé GDS:** lịch luôn là giá NCC — một ngày chỉ có hãng + số tiền, không có nguồn vé nên không biết vé rẻ nhất có phải vé GDS hay không. Khi selling price đang bật cho bất kỳ NCC nào (`shadow`/`on`), `meta.sellingPrice = { applied: false, reason: \"CALENDAR_NO_FARE_SOURCE\", mode, modeByPartner }`: ở `on`, giá search có thể thấp hơn giá lịch.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MinFareRequest"},"examples":{"month":{"value":{"startPoint":"SGN","endPoint":"HAN","month":"2026-06","adt":1,"chd":0,"inf":0}},"range":{"value":{"startPoint":"SGN","endPoint":"HAN","fromDate":"2026-06-15","toDate":"2026-07-15","adt":1}}}}}},"responses":{"200":{"description":"Date-keyed min-fare map","content":{"application/json":{"example":{"ok":true,"supplier":"aggregator","operation":"searchMinFareByMonth","data":{"2026-06-03":{"price":1690000,"currency":"VND","supplier":"skeeper","airline":"VJ"},"2026-06-04":{"price":1750000,"currency":"VND","supplier":"skeeper","airline":"VJ"}},"meta":{"suppliers":["skeeper"],"respondingSuppliers":["skeeper"],"domestic":true,"cached":false,"ttlSec":1800,"sellingPrice":{"applied":false,"reason":"CALENDAR_NO_FARE_SOURCE","mode":"shadow","modeByPartner":{"HNH":"shadow","BGT":"on","HPL":"shadow"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"501":{"description":"No supplier supports min-fare for this route/config","content":{"application/json":{"example":{"ok":false,"error":{"code":"NO_SUPPLIER","category":"capability","retryable":false,"message":"No supplier supports min-fare for this trip"}}}}}}}},"/flights/price-quote":{"post":{"tags":["Pricing"],"summary":"Reprice theo fareSelectionId (hoặc cả cặp khứ hồi)","x-roundTrip":"Gửi `fareSelectionIds: [đi, về]` thay cho `fareSelectionId` để báo giá KHỨ HỒI THEO CẶP (xem PairPriceQuoteResponse). Server xác định y hệt lúc book: cùng NCC + cùng hãng + cùng nguồn + chiều ngược nhau + NCC book chung được (HNH, BGT, HPL — HPL: 2 vé phải là chiều đi + chiều về của MỘT lần search khứ hồi) ⇒ 1 PNR ⇒ giá bán tính như MỘT vé khứ hồi gộp (một trần cả đơn, ngày của chiều đi, tiền cộng 2 chiều) rồi chia về từng chiều, giữ giá cho cả 2 vé; ngược lại 2 PNR ⇒ từng vé báo giá riêng. Dùng cho mọi khứ hồi trước khi thu tiền; book với cùng cặp sẽ so với giá cặp đã báo.","description":"Recalc giá trước khi book. NCC có thể trả giá mới (different_amount != 0 nếu tăng/giảm).\n\n**Giá bán vé GDS**: giá bán = giá NCC vừa verify − khoản giảm theo cấu hình hiện hành. `shadow`: thêm `sellingPrice`, `discountTotal`, `pricing` (`totalPrice` giữ giá NCC). `on`: `totalPrice` = giá bán, `netTotalPrice` = giá NCC, thêm `discountTotal`, `pricing`; field giá từng khách có trong data (`fareAdt`/`taxAdt`/`priceAdt`…) cũng đã trừ giảm, giá NCC ở `net*`. `off` / vé không phải GDS: không đổi.\n\n**Giữ giá:** khoản giảm đã báo được giữ tới `pricing.lockedUntil` (60 phút) cho cùng số khách. Trong thời hạn, báo giá lại và book giữ nguyên khoản giảm dù rule vừa hết hạn / bị tắt / chế độ về `off` (`pricing.locked = true`). Chỉ env `SELLING_PRICE_FORCE_OFF` huỷ giá đang giữ.","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/PriceQuoteRequest"},{"$ref":"#/components/schemas/PairPriceQuoteRequest"}]},"examples":{"single":{"summary":"Một vé","value":{"fareSelectionId":"fs_xxx","passengerCounts":{"adt":1,"chd":0,"inf":0}}},"roundTrip":{"summary":"Khứ hồi theo cặp (chiều đi, chiều về)","value":{"fareSelectionIds":["fs_out","fs_back"],"passengerCounts":{"adt":2,"chd":0,"inf":0}}}}}}},"responses":{"200":{"description":"Quote kết quả","content":{"application/json":{"examples":{"supplierPrice":{"summary":"Giá NCC (off / vé không phải GDS)","value":{"ok":true,"supplier":"tripota","operation":"priceQuote","data":{"totalPrice":3741000,"currency":"VND","fareAdt":2937000,"taxAdt":804000,"priceAdt":3741000,"status":true}}},"sellingPriceOn":{"summary":"Vé GDS, chế độ on","value":{"ok":true,"supplier":"airdata","operation":"priceQuote","data":{"totalPrice":16600000,"netTotalPrice":17000000,"discountTotal":400000,"fareAdt":3800000,"netFareAdt":4000000,"taxAdt":4500000,"currency":"VND","pricing":{"mode":"on","status":"APPLIED","cabin":"ECONOMY","ruleId":"gds-1g-vn-sgn-nrt","ruleVersion":3,"discountType":"PERCENT","discountValue":5,"discountBase":"BASE_FARE","perPax":{"ADT":{"base":4000000,"discount":200000,"count":2}},"lockedUntil":"2026-09-17T04:00:00.000Z"}}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"description":"fareSelectionId expired","content":{"application/json":{"example":{"ok":false,"error":{"code":"FARE_EXPIRED","message":"fareSelectionId fs_xxx not found or expired"}}}}},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/fare-rules":{"post":{"tags":["Pricing"],"summary":"Show fare rules (điều kiện vé)","description":"Raw fare rule text theo fareSelectionId. ATPCO GDS rules với airdata/tripota (text tiếng Anh); catalog tĩnh tiếng Việt với skeeper.\n\nĐể xem điều kiện **đã được chuẩn hoá** (pieces, weight, unit, refundable), hãy đọc trực tiếp field `fareConditions` trên mỗi fare trong response `/flights/search`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FareRuleRequest"},"example":{"fareSelectionId":"fs_xxx","isMiniRule":false}}}},"responses":{"200":{"description":"Fare rules raw","content":{"application/json":{"example":{"ok":true,"supplier":"airdata","operation":"fareRule","data":{"rules":"..."}}}}},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/fare-rules-catalog":{"get":{"tags":["Pricing"],"summary":"Catalog điều kiện theo group-class (seat/meal/change/refund…)","description":"Trả về catalog static (không cần fareSelectionId) từ BGT `/all-fare-rules` — enum FREE/FEE/NONE cho 9 dimensions (seat, meal, checkinPriority, loungeService, changeName, changeFlights, refund, cancel). Chỉ 6 hãng LCC: VJ/AK/TR/JQ/6E/5J. FE có thể merge với `fareConditions.groupClass` để hiển thị đầy đủ.","parameters":[{"name":"supplier","in":"query","required":false,"schema":{"type":"string","enum":["airdata","tripota","skeeper"]},"description":"Lọc 1 supplier. Mặc định fan-out tất cả (chỉ airdata thực sự có data)."}],"responses":{"200":{"description":"Catalog","content":{"application/json":{"example":{"ok":true,"traceId":"abc123","operation":"allFareRules","latencyMs":170,"data":{"sources":[{"supplier":"airdata","source":"VJ","configs":[{"groupClass":"Eco","cabinName":"Eco","seat":"FEE","meal":"FEE","checkinPriority":"NONE","loungeService":"NONE","changeName":"NONE","changeFlights":"FEE","refund":"FEE","cancel":"FREE"},{"groupClass":"Deluxe","cabinName":"Deluxe","seat":"FREE","meal":"FEE","checkinPriority":"NONE","loungeService":"NONE","changeName":"NONE","changeFlights":"FEE","refund":"FEE","cancel":"FREE"},{"groupClass":"SkyBoss","cabinName":"SkyBoss","seat":"FREE","meal":"FREE","checkinPriority":"FREE","loungeService":"FREE","changeName":"FEE","changeFlights":"FEE","refund":"FEE","cancel":"FREE"},{"groupClass":"Business","cabinName":"Business","seat":"FREE","meal":"FREE","checkinPriority":"FREE","loungeService":"FREE","changeName":"FEE","changeFlights":"FEE","refund":"FEE","cancel":"FREE"}]}],"totalSources":6,"totalConfigs":18},"suppliers":{"airdata":{"ok":true,"data":{"totalSources":6}},"tripota":{"ok":false,"error":{"code":"NOT_SUPPORTED_BY_OWNING_SUPPLIER"}},"skeeper":{"ok":false,"error":{"code":"NOT_SUPPORTED_BY_OWNING_SUPPLIER"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/flights/seat-map":{"post":{"tags":["PreBookAncillary"],"summary":"Sơ đồ ghế (trước book)","description":"Trả `data.addable[]` — danh sách ghế bán được đã phẳng hoá: mỗi item là `{ seatValue, passengerType, label, price, currency, route, cabinClass, available, addable }`. **`seatValue` là token mã hoá (lấy từ `prices[].value`), KHÔNG phải nhãn ghế (\"20A\").** Client POST nguyên item về `/seats` (kèm `passengerIndex` hoặc `passengerId`). `totalRows` đếm số hàng ghế trên tất cả khoang.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FareRefRequest"},"example":{"fareSelectionId":"fs_xxx"}}}},"responses":{"200":{"description":"Seat map","content":{"application/json":{"example":{"ok":true,"supplier":"tripota","operation":"seatMap","data":{"addable":[{"seatValue":"35c94bbd…|Ymkby8ax…","passengerType":"ADT","label":"20A","price":152000,"currency":"VND","route":"HANSGN","cabinClass":"Y","available":true,"addable":true}],"totalRows":30,"flightSeats":[{"aircraft":"321","flightNumber":"VN6002","cabins":[{"firstRow":"1","lastRow":"37","cabinClass":"ECONOMY","rows":[{"rowNumber":"20","seats":[{"text":"20A","available":true,"prices":[{"passengerType":"ADT","value":"35c94bbd…|Ymkby8ax…","price":152000}]}]}]}]}]}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/baggages":{"post":{"tags":["PreBookAncillary"],"summary":"List hành lý mua thêm","description":"Trả `data.items` (shape gốc của NCC) **và** `data.addable[]` — bản phẳng đã chuẩn hoá để POST thẳng lại. Mỗi phần tử `addable` = `{ passengerId, baggageValue (TOKEN), label, weightKg, price, currency, code, route, addable }`. **`weightKg`** = số kg đã parse sẵn từ tên gói để Web hiển thị \"15 kg\" mà KHÔNG tự parse free-text: tên GDS dán cả LB+KG (PG `\"UPTO33LB15KG\"` → **15**, đã ưu tiên KG bỏ LB); gói không mang kg trong nguồn (TG `XBAG \"BAGGAGE CHARGE\"`) → **`weightKg: null`** (phụ phí phẳng, hiển thị nhãn + giá, KHÔNG bịa số). Khi mua thêm: lấy `baggageValue` + `passengerId` từ `addable[]` đưa vào `POST .../baggage` — KHÔNG gửi nhãn \"15KG\". (skeeper: options theo từng option, `passengerId=null`, client tự gán pax.) Response luôn kèm hợp đồng canonical never-block: `baggage_status` (`available`|`unavailable`), `action_required` (`null`|`CONTINUE_WITHOUT_BAGGAGE`), `capability`, và `baggage[]` (mirror của `data.addable`). Pre-book GDS timeout/session chết → vẫn HTTP 200 `ok:true` + `baggage_status:\"unavailable\"` + `CONTINUE_WITHOUT_BAGGAGE` (không bao giờ treo/chặn luồng book).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FareRefRequest"},"example":{"fareSelectionId":"fs_xxx"}}}},"responses":{"200":{"description":"Baggage catalog","content":{"application/json":{"example":{"ok":true,"baggage_status":"available","action_required":null,"capability":{"supplier":"tripota","supported":true},"data":{"items":[{"code":"PBAG","name":"UPTO33LB15KG BAGGAGE","route":"BKKHKT","prices":[{"passengerId":"2","price":1096000,"value":"b80767b4|pLU…"}]},{"code":"XBAG","name":"BAGGAGE CHARGE","route":"SGNBKK","prices":[{"passengerId":"2","price":212000,"value":"23ab57db|pLU…"}]}],"addable":[{"passengerId":"2","baggageValue":"b80767b4|pLU…","label":"UPTO33LB15KG BAGGAGE","weightKg":15,"price":1096000,"currency":"VND","code":"PBAG","route":"BKKHKT","addable":true},{"passengerId":"2","baggageValue":"23ab57db|pLU…","label":"BAGGAGE CHARGE","weightKg":null,"price":212000,"currency":"VND","code":"XBAG","route":"SGNBKK","addable":true}]},"baggage":[{"passengerId":"2","baggageValue":"b80767b4|pLU…","label":"UPTO33LB15KG BAGGAGE","weightKg":15,"price":1096000,"currency":"VND","code":"PBAG","route":"BKKHKT","addable":true},{"passengerId":"2","baggageValue":"23ab57db|pLU…","label":"BAGGAGE CHARGE","weightKg":null,"price":212000,"currency":"VND","code":"XBAG","route":"SGNBKK","addable":true}]}}}}}}},"/flights/ancillaries":{"post":{"tags":["PreBookAncillary"],"summary":"List dịch vụ mua kèm","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FareRefRequest"},"example":{"fareSelectionId":"fs_xxx"}}}},"responses":{"200":{"description":"Ancillary catalog"}}}},"/flights/bookings":{"post":{"tags":["Booking"],"summary":"Đặt giữ chỗ (hold) hoặc Hold+Issue","description":"`mode=draft` → chỉ hold; `mode=confirm` → hold + issue ngay (chung 1 call).\n\n**Thẻ hội viên** (`passengers[].membership`): chỉ gửi NCC khi hãng của vé đã bật (HNH/HPL; BGT không có trường), không gửi cho em bé, HPL bỏ thẻ khác hãng vé. Thẻ không gửi được KHÔNG làm hỏng đơn; request có thẻ ⇒ response có `membership_status: [{ passenger_index, airline, sent, reason, on_pnr }]` (`reason`: NOT_ENABLED / SUPPLIER_NOT_SUPPORTED / INFANT_NOT_SENT / OTHER_AIRLINE). `sent:true` = đã gửi NCC; `on_pnr` = thẻ có trên PNR theo NCC (HNH: true/false — hãng từ chối số thẻ không tồn tại nhưng đơn vẫn giữ chỗ; HPL: null = NCC không cho biết). GET booking hiện `passengers[].membership` theo NCC trả về.\n\nServer trả `data.bookingRef` (prefix `bk_`) lưu 90 ngày; sau issue lưu 365 ngày.\n\n**Khứ hồi cùng hãng = 1 PNR** khi cùng NCC + cùng hãng + chiều ngược nhau và NCC đặt gộp được (HNH, BGT, HPL; HPL cần 2 vé là chiều đi + chiều về của MỘT lần search khứ hồi — có `returnDate`): server gửi MỘT lệnh giữ chỗ, trả `data.combined: true` + `data.bookings[]` 1 phần tử. Giá là giá NCC tính cho CẢ CẶP: với VN, mã giá đuôi \"S\" (A2AVNFS, EPXVNFS, LPXVNFS, J3AVNFS…) chỉ áp khi một chiều, nên cặp có mã S ĐẮT HƠN tổng 2 vé một chiều lúc search (vd VN246 A + VN6025 A: +72.000đ/khách) — đúng giá hãng; thu khách theo `price_breakdown.payable_total` của booking. Riêng HPL, khứ hồi gộp NHẬN ghế/hành lý/dịch vụ mua kèm: mỗi item PHẢI có `fareSelectionId` = vé (chiều) có danh sách seat-map/baggages mà item được lấy ra; `segmentIndex` vẫn là chuyến trong chính chiều đó. Hành lý/dịch vụ thiếu `fareSelectionId` thì server xếp theo `route` (vd \"HANSGN\"), token có ở cả 2 chiều mà không nói chiều nào ⇒ 400 BAGGAGE_LEG_AMBIGUOUS; ghế thiếu `fareSelectionId` ⇒ 400 SEAT_LEG_REQUIRED; `fareSelectionId` không thuộc đơn ⇒ 400 SERVICE_FARE_SELECTION_UNKNOWN. Khứ hồi ra 2 PNR vẫn từ chối dịch vụ (400 BOOK_SERVICES_MULTI_FARE_NOT_SUPPORTED).\n\n**Multi-fare (khứ hồi khác hãng)**: truyền `fareSelectionIds: [outboundId, inboundId]` — server book từng fare tuần tự, trả `data.bookings[]` thay vì `data.bookingRef`. Mỗi phần tử có `{bookingRef, supplierPnr, airline, supplier, state}`. Nếu fare thứ 2 thất bại, response lỗi kèm `data.bookedSoFar[]` để client biết PNR nào đã tạo (cần cancel thủ công).\n\n**Pax fields**: `type ∈ ADULT|CHILD|INFANT`. `contact.email` phải là email hợp lệ (zod). `contact.phone` dạng E.164 `+84918293909` (server nhận cả `0918293909`/`84918293909` và tự chuẩn hoá).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BookRequest"},"examples":{"single":{"summary":"Single fare (1 airline)","value":{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","mode":"draft","passengers":[{"type":"ADULT","title":"MR","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","gender":"M","nationality":"VN"}],"contact":{"email":"agent@example.com","phone":"+84918293909","name":"NGUYEN VAN A"}}},"withServices":{"summary":"Kèm ghế + hành lý mua thêm (tripota/HNH)","value":{"fareSelectionId":"fs_AqeDpYVEriJd36u5qM_19","mode":"draft","passengers":[{"type":"ADULT","title":"MR","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","gender":"M","nationality":"VN"}],"contact":{"email":"agent@example.com","phone":"+84918293909","name":"NGUYEN VAN A"},"seats":[{"passengerIndex":0,"seatValue":"35c94bbd…|Ymkby8ax…","seatCode":"16A","segmentIndex":0}],"baggages":[{"passengerIndex":0,"baggageValue":"b80767b4|pLU…","quantity":1}]}},"international":{"summary":"Quốc tế hãng APIS — passport + dateOfBirth BẮT BUỘC","value":{"fareSelectionId":"fs_QR_SGN_DOH_id","mode":"confirm","passengers":[{"type":"ADULT","title":"MR","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","gender":"M","nationality":"VN","document":{"type":"P","number":"B1234567","nationality":"VN","issueCountry":"VN","expireDate":"2030-12-31"}}],"contact":{"email":"agent@example.com","phone":"+84918293909","name":"NGUYEN VAN A"}}},"multi":{"summary":"Multi-fare (cross-airline RT — 2 PNRs)","value":{"fareSelectionId":"fs_VJ_outbound_id","fareSelectionIds":["fs_VJ_outbound_id","fs_QH_inbound_id"],"mode":"draft","passengers":[{"type":"ADULT","title":"MR","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","gender":"M","nationality":"VN"}],"contact":{"email":"agent@example.com","phone":"+84918293909","name":"NGUYEN VAN A"}}}}}}},"responses":{"200":{"description":"Hold thành công. `data.totalPrice` = giá NCC của PNR. Booking có giảm giá bán thêm `sellingPrice`, `discountTotal`; thu khách theo `price_breakdown.payable_total`.","content":{"application/json":{"examples":{"single":{"summary":"Single booking → data.bookingRef","value":{"ok":true,"traceId":"xyz789","supplier":"tripota","operation":"book","capability":{"supported":true,"notes":null},"latencyMs":5200,"data":{"supplier":"tripota","supplierPnr":"FJA99U","gdsCode":null,"airline":"VN","source":"VN","state":"draft","bookingStatus":"HOLD","timeHold":"2026-12-20T10:00:00Z","totalAmount":2499000,"currency":"VND","passengers":[{"paxId":"12190534","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","type":"ADULT"}],"itineraries":[{"airline":"VN","startPoint":"SGN","endPoint":"HAN","departTime":"2026-12-20T05:00:00Z","arriveTime":"2026-12-20T07:10:00Z","journeyIndex":0,"segmentIndex":0,"flightNumber":"VN6002","bookingClass":"B","status":"HK"}],"tickets":[],"bookingRef":"bk_XmwEWM5kTFAVS4yBb0uWK"}}},"multi":{"summary":"Multi booking → data.bookings[]","value":{"ok":true,"traceId":"xyz789","supplier":"airdata+tripota","operation":"book","data":{"bookings":[{"bookingRef":"bk_111","supplierPnr":"ABC123","airline":"VJ","supplier":"airdata","state":"draft"},{"bookingRef":"bk_222","supplierPnr":"DEF456","airline":"QH","supplier":"tripota","state":"draft"}]}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"description":"fareSelectionId expired","content":{"application/json":{"example":{"ok":false,"error":{"code":"FARE_EXPIRED","message":"..."}}}}},"409":{"description":"NCC từ chối hợp lệ, hoặc `SELLING_PRICE_CHANGED`: khoản giảm giá bán vé GDS nhỏ hơn lần báo gần nhất (price-quote, không có thì lúc search) và giá đã hết thời hạn giữ — chưa gọi book của NCC.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"supplierRejected":{"summary":"NCC từ chối","value":{"ok":false,"error":{"code":"SUPPLIER_REJECTED","message":"tripota rejected request: HTTP 400","supplierCode":"00038","supplierMessage":"System is not supported","category":"logical","retryable":false}}},"sellingPriceChanged":{"summary":"Giá bán đổi (rule hết hạn / bị tắt)","value":{"ok":false,"supplier":"airdata","operation":"book","error":{"code":"SELLING_PRICE_CHANGED","message":"Selling price changed since search: discount 400000 → 0 VND. Confirm the new price with the customer, then book again (new idempotency key).","category":"logical","retryable":false},"data":{"oldSellingPrice":16600000,"newSellingPrice":17000000,"oldDiscountTotal":400000,"newDiscountTotal":0,"currency":"VND"}}}}}}}}}},"/flights/bookings/{ref}":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":"bookingRef `bk_xxx` từ `POST /bookings`"}],"get":{"tags":["Booking"],"summary":"Mở PNR (retrieve) + itinerary + pax","responses":{"200":{"description":"Booking record — gồm `data.void_capability` (NCC có void được không) và `data.tickets[].ticket_status/coupon_status` cho preflight void","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BookEnvelope"},"example":{"ok":true,"traceId":"xyz789","supplier":"tripota","operation":"book","capability":{"supported":true,"notes":null},"latencyMs":5200,"data":{"supplier":"tripota","supplierPnr":"FJA99U","gdsCode":null,"airline":"VN","source":"VN","state":"issued","bookingStatus":"HOLD","timeHold":"2026-12-20T10:00:00Z","totalAmount":2499000,"currency":"VND","passengers":[{"paxId":"12190534","firstName":"NGUYEN","lastName":"VANA","dateOfBirth":"1990-01-01","type":"ADULT"}],"itineraries":[{"airline":"VN","startPoint":"SGN","endPoint":"HAN","departTime":"2026-12-20T05:00:00Z","arriveTime":"2026-12-20T07:10:00Z","journeyIndex":0,"segmentIndex":0,"flightNumber":"VN6002","bookingClass":"B","status":"HK"}],"tickets":["7382315673190"],"bookingRef":"bk_XmwEWM5kTFAVS4yBb0uWK","void_capability":{"supplier":"tripota","void_supported":true,"ticket_level_void_supported":true,"booking_level_void_supported":true,"void_requires_booking_ref":true,"void_requires_ticket_number":false,"void_idempotency_supported":true,"void_sandbox_available":false}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"tags":["Booking"],"summary":"Hủy PNR (cancelBooking)","responses":{"200":{"description":"Cancelled"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/issue":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Booking"],"summary":"Xuất vé (issue)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueRequest"},"example":{"sendEmail":true,"tourCode":""}}}},"responses":{"200":{"description":"Ticket issued","content":{"application/json":{"example":{"ok":true,"supplier":"tripota","operation":"issue","data":{"tickets":["7382315673190"],"bookingStatus":"ACTIVE","totalAmount":2499000}}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/refresh":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Booking"],"summary":"Cập nhật trạng thái đơn từ NCC (nút \"Cập nhật\")","description":"Mở lại PNR ở NCC, suy ra trạng thái đúng, **ghi vào đơn trên server** rồi trả về đúng shape của `GET /bookings/{ref}` (dựng từ đơn SAU cập nhật) + `data.refresh`. Body rỗng, không cần `X-Idempotency-Key`.\n\n**Luôn 200 khi `ref` tồn tại** — NCC lỗi, đang trong 30 giây chờ hoặc có lượt khác đang chạy đều trả dữ liệu đơn đã lưu, xem `refresh.status`:\n- `updated` NCC khác server, đã ghi · `unchanged` khớp · `needs_review` có mâu thuẫn, xem `review_reason`\n- `supplier_error` NCC lỗi/timeout (`refresh.error`), trạng thái KHÔNG đổi · `throttled` bấm lại trong 30 giây (`next_allowed_at`) · `no_pnr` chưa có PNR · `disabled` đang tắt\n\n**Luật**: không bao giờ lùi từ `issued`/`voided`/`refunded` về giữ chỗ; không tự huỷ đơn đã xuất (NCC báo huỷ mà vé còn mở ⇒ `needs_review` `SUPPLIER_CANCELLED_ISSUED`); mọi vé void/hoàn ở NCC ⇒ `voided`/`refunded` kèm `refresh.notices` `VOIDED_OUTSIDE_SYSTEM`/`REFUNDED_OUTSIDE_SYSTEM` cho kế toán; đơn `expired` mà NCC còn giữ và báo hạn mới ở tương lai ⇒ quay lại giữ chỗ.\n\n`review_reason`: `SUPPLIER_CANCELLED_ISSUED` · `ISSUED_AFTER_LOCAL_EXPIRY` · `SUPPLIER_LIVE_AFTER_LOCAL_CANCEL` · `PARTIAL_TICKETING` · `TICKETS_ON_HOLD` · `SUPPLIER_REFUND_STATUS` · `SUPPLIER_STATUS_UNKNOWN` · `SEGMENT_NOT_CONFIRMED` · `SCHEDULE_CHANGED` (nhiều lý do ⇒ `review_reasons[]`, `review_reason` là lý do nặng nhất).\n\n**Chỉ coi là đã xuất khi chính trạng thái của NCC nói đã xuất** (HNH `TICKETED`, BGT `TICKETED`/`DONE`/`PAID`+vé, HPL `ACTIVE`/`ACTIVATE`…). NCC trả dòng \"vé\" mà vẫn báo đang giữ (`HOLD`/`OK` — dạng sự cố 09/10) ⇒ đơn GIỮ NGUYÊN là giữ chỗ, `needs_review` `TICKETS_ON_HOLD`, các dòng đó nằm ở `data.ticketsOnHold` (không vào `ticket_numbers`).\n\nĐếm ngược giữ chỗ theo `expires_at`; `hold_deadline_source` = `supplier` (NCC báo) | `pnr_face` (dòng huỷ chỗ của hãng trên mặt PNR — đơn VN) | `null`. Mỗi `tickets[i]` có `ticket_status` (`open|used|voided|refunded|refund_pending|exchanged|unknown`) + `ticket_status_raw`. `ticket_numbers` liệt kê MỌI vé thật của PNR kể cả vé đã void/hoàn — trạng thái từng vé xem ở `tickets[i].ticket_status`.\n\n`needs_review` không gắn với một trạng thái cố định: nó đi kèm `booking_state` hiện có của đơn — kể cả `cancelled` (`SUPPLIER_LIVE_AFTER_LOCAL_CANCEL`), `expired` (`ISSUED_AFTER_LOCAL_EXPIRY` + `PARTIAL_TICKETING`, hoặc `TICKETS_ON_HOLD`), `release_pending`, `failed`. Hiển thị trạng thái theo `booking_state`, banner review hiện độc lập.\n\nChống spam NCC: 1 lần gọi NCC / đơn / 30 giây (`BOOKING_REFRESH_COOLDOWN_SEC`), dùng chung với `hold-status`. 404 `BOOKING_NOT_FOUND` ⇒ dùng `POST /bookings/retrieve`.","responses":{"200":{"description":"Đơn sau cập nhật + `data.refresh`","content":{"application/json":{"example":{"ok":true,"operation":"refreshBooking","supplier":"tripota","data":{"bookingRef":"bk_xxx","pnr":"ABC123","state":"issued","booking_state":"issued","ticket_state":"issued","ticket_numbers":["7382322845341"],"tickets":[{"ticketNumber":"7382322845341","ticket_status":"open","ticket_status_raw":"OPEN"}],"itineraries":[{"airline":"VN","flightNumber":"VN205","startPoint":"HAN","endPoint":"SGN","departTime":"2026-12-20T05:00:00Z","arriveTime":"2026-12-20T07:20:00Z","journeyIndex":0,"segmentIndex":0,"status":"HK"}],"expires_at":null,"hold_deadline_source":null,"can_issue":false,"can_cancel":false,"refresh":{"status":"updated","checked_at":"2026-10-09T08:00:00.000Z","data_source":"supplier","previous_state":"draft","new_state":"issued","changes":[{"field":"state","from":"draft","to":"issued"},{"field":"ticket_numbers","from":[],"to":["7382322845341"]}],"supplier_status":"TICKETED","review_reason":null,"review_reasons":[],"notices":[],"error":null,"next_allowed_at":"2026-10-09T08:00:30.000Z"}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/bookings/retrieve":{"post":{"tags":["Booking"],"summary":"Retrieve PNR theo supplier + mã PNR (booking tạo ngoài hệ thống)","description":"Mở 1 PNR khi chỉ biết `supplier + pnr` (vd. booking tạo ngoài Server Flight, hoặc cần void/issue mà không có `bookingRef`). Server tự mint/tái dùng `bookingRef` cho cặp supplier+pnr. Một số NCC bắt buộc thêm `airline` và/hoặc `lastName`.\n\nKhông gửi `source` ⇒ server thử lần lượt nơi PNR có thể nằm, dừng ở lần đầu thành công, **tối đa 3 lần gọi NCC**: HNH `[hãng, 1A, 1G]`; BGT hãng VN `[VN1A, VN1A_MT, 1G]`, hãng khác `[hãng, 1G]`; HPL `[hãng]` (9G ⇒ `_9G`). Đơn đã có trên server thì trạng thái đổi theo đúng luật của `POST /bookings/{ref}/refresh` (không ghi đè mù).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetrieveByPnrRequest"},"example":{"supplier":"tripota","pnr":"FJA99U","airline":"VN","lastName":"NGUYEN"}}}},"responses":{"200":{"description":"Booking record (giống GET /bookings/{ref})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BookEnvelope"}}}},"400":{"description":"UNKNOWN_SUPPLIER — supplier sai hoặc không hỗ trợ retrieve","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"502":{"$ref":"#/components/responses/BadGateway"}}}},"/flights/bookings/{ref}/hold-status":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["Booking"],"summary":"Trạng thái giữ chỗ (hold còn sống / TTL còn lại)","description":"Re-check fresh từ NCC khi có thể; fallback local store nếu NCC timeout (`supplierConfirmed=false`). Dùng trước issue để chắc PNR chưa hết hạn. Luôn 200.\n\n**Dùng chung 30 giây chờ với `POST /bookings/{ref}/refresh`** (2026-10-09): trong 30 giây sau một lần hỏi NCC THÀNH CÔNG (của hold-status hoặc refresh) trả lại kết quả lần đó thay vì gọi NCC lần nữa; NCC lỗi thì lần gọi sau hỏi lại ngay. hold-status chỉ ghi vào đơn **hạn giữ chỗ** (kể cả hạn VN đọc từ mặt PNR) và việc **hết hạn** — đã xuất / huỷ / void chỉ cập nhật qua refresh. NCC trả dòng \"vé\" mà vẫn báo đang giữ ⇒ vẫn là giữ chỗ (`stillHeld` theo hạn), không bao giờ là `issued`.\n\n**`stillHeld` là kết luận cuối cùng** — không trường nào khác mâu thuẫn với nó: khi `stillHeld=false` thì `ttlSeconds` là `0` (hoặc `null` nếu không biết hạn) và `can_issue=false`.\n\n**`notHeldReason`** (2026-10-09): `null` khi `stillHeld=true`; khi `false` cho biết vì sao — `expired` (quá hạn giữ chỗ; BGT `EXPIRED` cũng là `expired`) · `cancelled` · `issued` (đã xuất vé — đọc lại booking) · `release_pending` · `failed` · `supplier_unreachable` (không hỏi được NCC và không có hạn giữ chỗ còn hiệu lực — KHÔNG có nghĩa là hết hạn, nên thử lại) · `hold_unconfirmed` (NCC trả lời nhưng không xác nhận chỗ) · `unknown`. Chỉ báo khách \"hết hạn giữ chỗ\" khi `expired`.\n\n`ttlSeconds: null` với `stillHeld: true` = NCC xác nhận đang giữ nhưng không cho hạn (VN qua HPL) — không phải hết hạn.","responses":{"200":{"description":"Hold status","content":{"application/json":{"example":{"bookingRef":"bk_xxx","supplier":"tripota","stillHeld":true,"ttlSeconds":3600,"expiresAt":"2026-12-20T10:00:00Z","state":"booked","supplierConfirmed":true,"retrievedAt":"2026-12-20T09:00:00Z","booking_state":"held","ticket_state":"not_started","can_cancel":true,"can_issue":true,"notHeldReason":null}}}}}}},"/flights/bookings/{ref}/events":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50},"description":"Số event tối đa trả về"}],"get":{"tags":["Booking"],"summary":"Lịch sử audit event của booking","description":"Timeline state-transition (book/issue/void/refund/cancel…) để ops trace. Event có thể sống lâu hơn booking record.","responses":{"200":{"description":"Events","content":{"application/json":{"example":{"ok":true,"operation":"bookingEvents","data":{"bookingRef":"bk_xxx","events":[{"id":"ev_1","type":"BOOK_DRAFT_CREATED","previousState":null,"newState":"draft","source":"book","supplier":"tripota","createdAt":1734688800000,"payload":{}},{"id":"ev_2","type":"TICKET_ISSUED","previousState":"draft","newState":"issued","source":"issue","supplier":"tripota","createdAt":1734692400000,"payload":{}}]}}}}}}}},"/flights/bookings/parent/{parentRef}":{"parameters":[{"name":"parentRef","in":"path","required":true,"schema":{"type":"string"},"description":"Parent ref của booking khứ hồi 2-PNR (cross-airline)"}],"get":{"tags":["Booking"],"summary":"Mở booking khứ hồi 2-PNR theo parentRef","description":"Cross-airline RT tạo 2 PNR con (outbound + return) gắn 1 `parentRef`. Endpoint trả cả 2 leg + trạng thái tổng hợp (`overall_supplier_state`).","responses":{"200":{"description":"Legs + overall state","content":{"application/json":{"example":{"ok":true,"operation":"retrieveParent","data":{"parent_booking_ref":"par_xxx","legs":[{"leg":"outbound","booking_ref":"bk_111","supplier":"airdata","supplier_pnr":"ABC123","state":"issued","booking_state":"issued","ticket_state":"issued","expires_at":null},{"leg":"return","booking_ref":"bk_222","supplier":"tripota","supplier_pnr":"DEF456","state":"issued","booking_state":"issued","ticket_state":"issued","expires_at":null}],"overall_supplier_state":"issued"}}}}},"404":{"description":"PARENT_NOT_FOUND","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/flights/bookings/parent/{parentRef}/issue":{"parameters":[{"name":"parentRef","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Booking"],"summary":"Xuất vé cả booking khứ hồi 2-PNR (atomic-ish)","description":"Orchestrate issue cho RT 2-PNR: ticketing leg pay-now (rủi ro, không hold) TRƯỚC; chỉ khi xong mới issue leg đã hold. Nếu leg pay-now fail → dừng, giữ nguyên leg hold (`PAYNOW_LEG_FAILED`, 409). Forward `X-Idempotency-Key`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IssueRequest"},"example":{"sendEmail":true}}}},"responses":{"200":{"description":"Tất cả leg issued","content":{"application/json":{"example":{"ok":true,"operation":"issue","data":{"parent_booking_ref":"par_xxx","results":[{"bookingRef":"bk_111","legType":"outbound","supplier":"airdata","ok":true,"state":"issued"},{"bookingRef":"bk_222","legType":"return","supplier":"tripota","ok":true,"state":"issued"}],"overall_supplier_state":"issued"}}}}},"207":{"description":"Mixed — một số leg fail"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"PAYNOW_LEG_FAILED — leg pay-now lỗi, leg hold được giữ lại","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/flights/bookings/parent/{parentRef}/refresh":{"parameters":[{"name":"parentRef","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Booking"],"summary":"Cập nhật cả booking khứ hồi 2-PNR từ NCC","description":"Refresh lần lượt từng leg (mỗi leg chịu 30 giây chờ riêng), cùng luật với `POST /bookings/{ref}/refresh`. Mỗi `legs[i]` mang đủ chi tiết như response của refresh 1 PNR (`itineraries[]`, `tickets[]` kèm `ticket_status`, `passengers[]`, `ticket_numbers`, `ticketsOnHold` khi có) — không cần gọi thêm refresh từng leg. `expires_at` của cả đơn = hạn sớm nhất trong các leg còn giữ chỗ. Luôn 200 khi parent tồn tại.","responses":{"200":{"description":"Legs sau cập nhật","content":{"application/json":{"example":{"ok":true,"operation":"refreshParent","data":{"parent_booking_ref":"rt_xxx","legs":[{"leg":"outbound","booking_ref":"bk_111","supplier":"tripota","pnr":"ABC123","source":"VN","state":"issued","booking_state":"issued","ticket_state":"issued","ticket_numbers":["7382322845341"],"tickets":[{"ticketNumber":"7382322845341","paxId":"1","ticket_status":"open","ticket_status_raw":"OPEN"}],"passengers":[{"paxId":"1","firstName":"VAN A","lastName":"NGUYEN","type":"ADULT"}],"itineraries":[{"airline":"VN","flightNumber":"VN213","startPoint":"SGN","endPoint":"HAN","departTime":"2026-11-20T06:00:00","arriveTime":"2026-11-20T08:10:00","journeyIndex":0,"segmentIndex":0,"status":"HK"}],"can_issue":false,"expires_at":null,"hold_deadline_source":null,"refresh":{"status":"updated"}},{"leg":"return","booking_ref":"bk_222","supplier":"skeeper","pnr":"DEF456","source":"VN","state":"booked","booking_state":"held","ticket_state":"not_started","ticket_numbers":[],"tickets":[],"passengers":[{"paxId":"2","firstName":"VAN A","lastName":"NGUYEN","type":"ADULT"}],"itineraries":[{"airline":"VN","flightNumber":"VN264","startPoint":"HAN","endPoint":"SGN","departTime":"2026-11-25T19:00:00Z","arriveTime":"2026-11-25T21:10:00Z","journeyIndex":0,"segmentIndex":0,"status":"HK"}],"can_issue":true,"expires_at":"2026-10-09T20:00:00.000Z","hold_deadline_source":"supplier","refresh":{"status":"unchanged"}}],"overall_supplier_state":"partially_issued","expires_at":"2026-10-09T20:00:00.000Z"}}}}},"404":{"description":"PARENT_NOT_FOUND","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/flights/bookings/{ref}/baggage":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["BookingAncillary"],"summary":"List baggage mua thêm cho PNR (post-issue)","description":"Giống `/flights/baggages` nhưng cho PNR đã có: trả `data.items` + `data.addable[]` (kèm **`weightKg`** đã parse — xem `/flights/baggages` về cách đọc kg cho GDS & XBAG=null). Dùng `addable[].baggageValue` (TOKEN) + `passengerId` cho `POST .../baggage`.","responses":{"200":{"description":"Items + addable[]","content":{"application/json":{"example":{"ok":true,"operation":"baggageList","data":{"items":[{"code":"XWBG","name":"20Kg","route":"SGNDAD","prices":[{"passengerId":"2","price":260000,"value":"b8…|TVEG…"}]}],"addable":[{"passengerId":"2","baggageValue":"b8…|TVEG…","label":"20Kg","weightKg":20,"price":260000,"currency":"VND","code":"XWBG","route":"SGNDAD","addable":true}]}}}}}}},"post":{"tags":["BookingAncillary"],"summary":"Mua thêm hành lý","description":"Gửi `baggageValue` = TOKEN lấy từ `addable[].baggageValue` của GET `.../baggage` (KHÔNG phải nhãn \"15KG\" — nhãn literal gây HNH 21001 \"Index outside bounds\"). `passengerId`/`passengerIndex` chỉ định pax (skeeper bắt buộc client tự gán vì list không kèm passengerId).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddBaggageRequest"},"example":{"baggages":[{"passengerId":"2","baggageValue":"b8…|TVEG…","quantity":1}]}}}},"responses":{"200":{"description":"OK"},"409":{"$ref":"#/components/responses/Conflict"}}},"delete":{"tags":["BookingAncillary"],"summary":"Xoá baggage đã thêm","requestBody":{"content":{"application/json":{"example":{"baggages":[{"baggageValue":"15KG_APBG"}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/seats":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["BookingAncillary"],"summary":"Seat map cho PNR","responses":{"200":{"description":"Map"}}},"post":{"tags":["BookingAncillary"],"summary":"Mua thêm chỗ ngồi","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddSeatRequest"},"example":{"seats":[{"passengerIndex":0,"seatValue":"12A"}]}}}},"responses":{"200":{"description":"OK"}}},"delete":{"tags":["BookingAncillary"],"summary":"Xoá seat","responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/ancillary":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["BookingAncillary"],"summary":"List services mua thêm","responses":{"200":{"description":"Items"}}},"post":{"tags":["BookingAncillary"],"summary":"Mua thêm dịch vụ","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddAncillaryRequest"},"example":{"services":[{"passengerIndex":0,"ancillaryValue":"UPGD_FROM-B_TO-W","quantity":1}]}}}},"responses":{"200":{"description":"OK"}}},"delete":{"tags":["BookingAncillary"],"summary":"Xoá service","responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/segments":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Modify"],"summary":"Thêm hành trình (modifyAddFlights)","requestBody":{"required":true,"content":{"application/json":{"example":{"flightAddNews":["<flight_value_opaque_key>"]}}}},"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Modify"],"summary":"Hủy hành trình (cancelAll hoặc từng segment)","requestBody":{"required":true,"content":{"application/json":{"example":{"cancelAll":true}}}},"responses":{"200":{"description":"OK"}}},"patch":{"tags":["Modify"],"summary":"Đổi hành trình atomic (cancel cũ + add mới)","requestBody":{"required":true,"content":{"application/json":{"example":{"flightCancels":["<fv1>"],"flightAddNews":["<fv2>"]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/passengers":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"patch":{"tags":["Modify"],"summary":"Sửa thông tin pax / đổi tên (name-change)","requestBody":{"required":true,"content":{"application/json":{"example":{"passengers":[{"passengerId":"12190534","firstName":"NEW_NAME","lastName":"SURNAME","dateOfBirth":"1990-01-01","type":"ADULT"}]}}}},"responses":{"200":{"description":"OK"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/infant":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Modify"],"summary":"Thêm em bé (INF)","requestBody":{"required":true,"content":{"application/json":{"example":{"infants":[{"givenName":"BABY","surname":"USER","dateOfBirth":"2025-06-01","parentId":"12190534"}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/split":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Modify"],"summary":"Tách hành khách ra PNR riêng","requestBody":{"required":true,"content":{"application/json":{"example":{"splitPassengers":[{"type":"ADT","givenName":"TEST","surName":"USER","passengerId":"12190534"}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/remarks":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["PNROps"],"summary":"Add remarks (note nội bộ)","requestBody":{"required":true,"content":{"application/json":{"example":{"remarks":[{"remark":"TEST REMARK","public":false}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/osi":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["PNROps"],"summary":"Add OSI (airline info)","requestBody":{"required":true,"content":{"application/json":{"example":{"items":[{"osi":"VU PSGR HAS PEANUT ALLERGY","passengerId":"12190534"}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/sk":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["PNROps"],"summary":"Add SK (special keyword)","requestBody":{"required":true,"content":{"application/json":{"example":{"items":[{"sk":"TEST SK","type":"info","passengerId":"12190534"}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/documents":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["PNROps"],"summary":"Add Passport / Visa","requestBody":{"required":true,"content":{"application/json":{"example":{"passengers":[{"passengerId":"12190534","documents":[{"type":"P","number":"B12345678","issueCountry":"VN","national":"VN","expiryDate":"2030-12-31","gender":"M","dateOfBirth":"1990-01-01","surName":"USER","givenName":"NGUYEN"}]}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/fftv":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["PNROps"],"summary":"Add Membership (FFTV Lotus Miles)","description":"Chỉ HNH (tripota), và chỉ khi hãng của đơn đã bật — chưa bật ⇒ 400 MEMBERSHIP_NOT_ENABLED. HPL/BGT ⇒ NOT_SUPPORTED_BY_OWNING_SUPPLIER (HPL chỉ nhận thẻ lúc đặt chỗ). `passengerId` = paxId của booking, sai ⇒ 400 PASSENGER_UNRESOLVED.","requestBody":{"required":true,"content":{"application/json":{"example":{"passengers":[{"passengerId":"12190534","memberships":[{"airline":"VN","membershipId":"VN1234567"}]}]}}}},"responses":{"200":{"description":"OK"}}},"delete":{"tags":["PNROps"],"summary":"Delete Membership","description":"Xoá thẻ khỏi PNR (chỉ HNH, cùng cờ bật theo hãng như POST). Body giống POST.","requestBody":{"required":true,"content":{"application/json":{"example":{"passengers":[{"passengerId":"12190534","memberships":[{"airline":"VN","membershipId":"VN1234567"}]}]}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/void":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""},{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Khóa idempotency `void:{bookingRef}:{ticketNumber}` — retry cùng key sẽ replay, không gọi lại NCC."}],"post":{"tags":["Tickets"],"summary":"Void PNR (trước deadline void)","requestBody":{"content":{"application/json":{"example":{"voidAll":true}}}},"responses":{"200":{"description":"OK — `data.void` chứa quyết định chuẩn hóa","content":{"application/json":{"example":{"ok":true,"data":{"void":{"ok":true,"decision":"success","ticket_number":"7382315673190","booking_ref":"bk_xxx","supplier":"tripota","airline":"VN","void_ref":null,"error_code":null,"error_message":null,"trace_id":"t","raw_ref":"raw:t","idempotency_key":"void:bk_xxx:7382315673190"}}}}}},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/refund":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Tickets"],"summary":"Hoàn vé theo PNR (legacy passthrough)","description":"Passthrough trực tiếp tới adapter.refund (KHÔNG eligibility-gate, KHÔNG idempotency). Production nên dùng module chuẩn `POST /flights/refunds/submit`.","requestBody":{"content":{"application/json":{"example":{"refundAll":true,"mode":"full","reason":"customer"}}}},"responses":{"200":{"description":"OK"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/exchange":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Tickets"],"summary":"Đổi vé theo PNR (legacy passthrough)","description":"Passthrough trực tiếp tới adapter.exchange. Production nên dùng module chuẩn `/flights/exchanges/*` (eligibility → quote → execute → retrieve).","requestBody":{"required":true,"content":{"application/json":{"example":{"mode":"search"}}}},"responses":{"200":{"description":"OK"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/tickets/{ticketNo}/void":{"parameters":[{"name":"ticketNo","in":"path","required":true,"schema":{"type":"string"},"description":"Ticket number VD `7382315673190`"},{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Khóa idempotency `void:{bookingRef}:{ticketNumber}` — retry cùng key sẽ replay, không gọi lại NCC."}],"post":{"tags":["Tickets"],"summary":"Void theo ticket number","responses":{"200":{"description":"OK — `data.void.decision` ∈ success|already_voided|rejected|failed|timeout|unknown"},"404":{"description":"Ticket not registered"},"501":{"description":"NCC không hỗ trợ void (data.void.decision=rejected)"}}}},"/flights/tickets/{ticketNo}/refund":{"parameters":[{"name":"ticketNo","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Tickets"],"summary":"Hoàn theo ticket number","responses":{"200":{"description":"OK"}}}},"/flights/tickets/{ticketNo}/exchange":{"parameters":[{"name":"ticketNo","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Tickets"],"summary":"Đổi theo ticket number","requestBody":{"required":true,"content":{"application/json":{"example":{"mode":"search"}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/email":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Comms"],"summary":"Gửi email xác nhận / e-ticket","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendEmailRequest"},"example":{"email":"pax@example.com","language":"vi"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"ok":true,"data":{"raw":{"trackingId":"abc","status":true}}}}}}}}},"/flights/bookings/{ref}/queue":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"post":{"tags":["Comms"],"summary":"Queue place (đẩy PNR vào queue OPS)","requestBody":{"content":{"application/json":{"example":{"queueNumber":50,"validatingCarrier":"VN"}}}},"responses":{"200":{"description":"OK"}}}},"/flights/bookings/{ref}/face":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["Comms"],"summary":"Face PNR (plain text)","responses":{"200":{"description":"Plain text PNR","content":{"application/json":{"example":{"ok":true,"data":{"raw":{"system":"VU","plainText":"WXEUM6\n1. USER/TEST MRS (ADT 01JAN90)\n2. VU 672 A 20SEP SGNDAD HK1 0800 0925"}}}}}}}}},"/flights/bookings/{ref}/print":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"get":{"tags":["Comms"],"summary":"In vé (sau xuất)","responses":{"200":{"description":"Ticket image / PDF ref"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/flights/bookings/{ref}/contact":{"parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"},"description":""}],"patch":{"tags":["Comms"],"summary":"Update email / phone / fullName","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateContactRequest"},"example":{"email":"new@example.com","phone":"+84918293909","fullName":"NGUYEN VAN A"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"ok":true,"operation":"updateContact","data":{"raw":{"status":true,"trackingId":"xyz"}}}}}},"501":{"$ref":"#/components/responses/NotSupported"}}}},"/flights/flight-status":{"post":{"tags":["FlightInfo"],"summary":"Tình trạng chuyến bay (flight status)","description":"Hỗ trợ 2 mode:\n- `{bookingRef}` → tra status cho mọi segment trong booking.\n- `{system, flightValue}` hoặc `{system, flightValues[]}` → stateless ad-hoc lookup (cần opaque key từ prior search).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlightStatusRequest"},"examples":{"byBookingRef":{"value":{"bookingRef":"bk_xxx"}},"byFlightValue":{"value":{"system":"VN","flightValue":"0VN6002BSGNHAN20261220"}}}}}},"responses":{"200":{"description":"Flight info"},"404":{"$ref":"#/components/responses/NotFound"},"501":{"$ref":"#/components/responses/NotSupported"}}}},"/flights/refunds/retrieve":{"post":{"tags":["Refund"],"summary":"Đọc trạng thái NCC + eligibility hoàn vé (read-only)","description":"Bước 1 luồng hoàn vé chuẩn. Retrieve-before: đọc state NCC, không mutate. Trả `data.refund_retrieve` + `data.capability`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"pnr":{"type":"string"},"supplier":{"type":"string"},"airline":{"type":"string"},"tickets":{"type":"array","items":{"type":"string"}}}},"example":{"bookingRef":"bk_xxx"}}}},"responses":{"200":{"description":"Refund state + eligibility","content":{"application/json":{"example":{"ok":true,"operation":"refundRetrieve","supplier":"tripota","data":{"refund_retrieve":{"ok":true,"booking_ref":"bk_xxx","supplier":"tripota","airline":"VN","pnr":"FJA99U","booking_state":"issued","ticket_state":"issued","coupon_status":"open","refund_state":null,"eligible":true,"eligibility_reason":null,"next_action":"refund","retrieve_ok":true,"error_code":null},"capability":{"refund_supported":true,"quote_supported":false,"full_booking_supported":true,"ticket_refund_supported":true,"status_check_supported":true}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/refunds/quote":{"post":{"tags":["Refund"],"summary":"Báo phí + ước tính tiền hoàn (nếu NCC hỗ trợ; else manual_required)","description":"Bước 2. Hiện không NCC nào có quote API → `quote_supported=false, manual_required=true` (vẫn submit được, NV tính phí tay). Có thể trả `eligible=false` + `eligibility_reason` (TICKET_VOIDED/ALREADY_REFUNDED/…).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"refundType":{"type":"string","enum":["full_booking","ticket","passenger","segment"],"default":"ticket"},"tickets":{"type":"array","items":{"type":"string"}},"passengers":{"type":"array","items":{"type":"string"}},"segments":{"type":"array","items":{"type":"string"}},"reasonCode":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","refundType":"ticket","tickets":["7382315673190"],"reasonCode":"SCHEDULE_CHANGE"}}}},"responses":{"200":{"description":"Quote hoặc manual_required","content":{"application/json":{"example":{"ok":true,"operation":"refundQuote","data":{"refund_quote":{"booking_ref":"bk_xxx","supplier":"tripota","refund_type":"ticket","ticket_numbers":["7382315673190"],"eligible":true,"quote_supported":false,"fee":null,"estimated_refund_amount":null,"currency":null,"manual_required":true}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/refunds/submit":{"post":{"tags":["Refund"],"summary":"Gửi yêu cầu hoàn (idempotent, eligibility-gated)","description":"Bước 3. Eligibility gate TRƯỚC khi gọi NCC (voided/refunded/pending KHÔNG gọi NCC). Idempotent qua `idempotencyKey`/`X-Idempotency-Key`. Timeout/5xx → `refund_state=unknown` (KHÔNG auto-retry; tra qua /status). airdata/skeeper → `manual_required` (chưa hỗ trợ refund API).","parameters":[{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef","reasonCode"],"properties":{"bookingRef":{"type":"string"},"refundReference":{"type":"string","description":"DLV ref; server sinh rf_<id> nếu bỏ trống"},"idempotencyKey":{"type":"string"},"refundType":{"type":"string","enum":["full_booking","ticket","passenger","segment"],"default":"ticket"},"tickets":{"type":"array","items":{"type":"string"}},"passengers":{"type":"array","items":{"type":"string"}},"segments":{"type":"array","items":{"type":"string"}},"reasonCode":{"type":"string"},"reasonNote":{"type":"string"},"isEMD":{"type":"boolean"}}},"example":{"bookingRef":"bk_xxx","refundType":"ticket","tickets":["7382315673190"],"reasonCode":"SCHEDULE_CHANGE"}}}},"responses":{"200":{"description":"Refund result (refund_state ∈ submitted|pending|approved|refunded|rejected|failed|unknown|manual_required)","content":{"application/json":{"example":{"ok":true,"operation":"refundSubmit","data":{"refund":{"ok":true,"refund_state":"refunded","refund_reference":"rf_xxx","supplier_refund_ref":"RF9","refund_type":"ticket","ticket_numbers":["7382315673190"],"booking_ref":"bk_xxx","supplier":"tripota","manual_required":false,"idempotency_key":"idem-xxx"}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/refunds/status":{"post":{"tags":["Refund"],"summary":"Tra trạng thái hoàn đã submit","description":"Resolve `supplier_refund_state` (refunded/pending/rejected/… hoặc `not_received` khi NCC chưa có record). Cần ≥1 trong `refundReference`/`supplierRefundRef`/`idempotencyKey`/`bookingRef`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bookingRef":{"type":"string"},"refundReference":{"type":"string"},"supplierRefundRef":{"type":"string"},"idempotencyKey":{"type":"string"}}},"example":{"refundReference":"rf_xxx"}}}},"responses":{"200":{"description":"Refund status","content":{"application/json":{"example":{"ok":true,"operation":"refundStatus","data":{"refund_status":{"ok":true,"supplier_refund_state":"refunded","refund_reference":"rf_xxx","supplier_refund_ref":"RF9","booking_ref":"bk_xxx","supplier":"tripota"}}}}}}}}},"/flights/exchanges/eligibility":{"post":{"tags":["Exchange"],"summary":"Kiểm tra điều kiện đổi vé (read-only, retrieve-before)","description":"Bước 1. Gate `FLIGHT_EXCHANGE_ENABLED` (mặc định off). Đọc state NCC, không mutate. `reasonCode` set khi ineligible (ALREADY_EXCHANGED/EXCHANGE_NOT_SUPPORTED/…).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"pnr":{"type":"string"},"supplier":{"type":"string"},"airline":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"}}},"example":{"bookingRef":"bk_xxx","scope":{"type":"ticket","ticketNumbers":["7382315673190"]}}}}},"responses":{"200":{"description":"Eligibility","content":{"application/json":{"example":{"ok":true,"operation":"exchangeEligibility","data":{"exchange_eligibility":{"eligible":true,"bookingState":"issued","ticketState":"issued","scope_type":"ticket","reasonCode":null,"warnings":[],"booking_ref":"bk_xxx","supplier":"tripota","retrieve_ok":true}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/exchanges/search-options":{"post":{"tags":["Exchange"],"summary":"Reshop — tìm hành trình đổi (read-only)","description":"Bước 2. Trả `options[]` từ NCC. `manual_required=true` nếu flag off (EXCHANGE_DISABLED) hoặc NCC không có reshop API (EXCHANGE_NOT_SUPPORTED).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"},"newItineraryRequest":{"$ref":"#/components/schemas/NewItineraryRequest"}}},"example":{"bookingRef":"bk_xxx","newItineraryRequest":{"origin":"SGN","destination":"HAN","departureDate":"2026-12-28"}}}}},"responses":{"200":{"description":"Options","content":{"application/json":{"example":{"ok":true,"operation":"exchangeSearchOptions","data":{"exchange_search":{"booking_ref":"bk_xxx","supplier":"tripota","scope_type":"ticket","options":[],"search_supported":true,"manual_required":false,"reasonCode":null}}}}}}}}},"/flights/exchanges/quote":{"post":{"tags":["Exchange"],"summary":"Reprice — phí đổi + chênh lệch giá (read-only)","description":"Bước 3. Lưu quote + token NCC để execute. `validUntil` mặc định `FLIGHT_EXCHANGE_QUOTE_TTL_MINUTES` (15). Không bao giờ tự tính phí.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"},"newItineraryRequest":{"$ref":"#/components/schemas/NewItineraryRequest"},"flightCancels":{"type":"array","items":{},"description":"Opaque token NCC"},"flightExchanges":{"type":"array","items":{},"description":"Opaque token NCC"}}},"example":{"bookingRef":"bk_xxx","flightExchanges":["<opaque-token>"]}}}},"responses":{"200":{"description":"Quote","content":{"application/json":{"example":{"ok":true,"operation":"exchangeQuote","data":{"exchange_quote":{"quoteRef":"xq_xxx","bookingRef":"bk_xxx","supplier":"tripota","currency":"VND","priceBreakdown":{"airlineChangeFee":600000,"fareDifference":200000,"taxDifference":50000,"supplierFee":0,"totalDueToSupplier":850000},"quote_supported":true,"manual_required":false,"eligible":true,"validUntil":"2026-12-20T09:15:00Z"}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/exchanges/execute":{"post":{"tags":["Exchange"],"summary":"Xác nhận đổi vé (idempotent, gated, reprice-before-confirm)","description":"Bước 4. CHỈ live khi `FLIGHT_EXCHANGE_ENABLED` + `FLIGHT_EXCHANGE_LIVE_EXECUTE_ENABLED` + supplier ∈ `FLIGHT_EXCHANGE_SUPPORTED_SUPPLIERS` (deny-default → `rejected` + `manual_required`). Cần `quoteRef` còn hạn (execute KHÔNG tự quote). Reprice lại trước confirm (mặc định on). Timeout → `unknown`.","parameters":[{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef","quoteRef"],"properties":{"bookingRef":{"type":"string"},"quoteRef":{"type":"string"},"exchangeReference":{"type":"string","description":"server sinh xc_<id> nếu bỏ trống"},"newFareSelectionId":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"},"idempotencyKey":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","quoteRef":"xq_xxx"}}}},"responses":{"200":{"description":"Exchange result (exchange_state ∈ exchanged|rejected|already_exchanged|price_changed|quote_expired|no_seat|failed|unknown)","content":{"application/json":{"example":{"ok":true,"operation":"exchangeExecute","data":{"exchange":{"exchange_state":"exchanged","reason_code":null,"manual_required":false,"supplier_exchange_ref":"XC123"}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/exchanges/{exchangeRef}/retrieve":{"parameters":[{"name":"exchangeRef","in":"path","required":true,"schema":{"type":"string"},"description":""},{"name":"bookingRef","in":"query","required":false,"schema":{"type":"string"}}],"get":{"tags":["Exchange"],"summary":"Đối soát sau đổi vé (resolve unknown)","description":"Sau execute=unknown: xác nhận `exchanged` / `not_exchanged` (`can_retry=true` CHỈ khi NCC xác nhận chưa đổi) / `unknown`. Luôn 200.","responses":{"200":{"description":"Retrieve-after","content":{"application/json":{"example":{"ok":true,"operation":"exchangeRetrieve","data":{"exchange_retrieve":{"exchange_state":"exchanged","can_retry":false,"booking_ref":"bk_xxx","supplier":"tripota"}}}}}}}}},"/flights/upgrades/capability":{"get":{"tags":["Upgrade"],"summary":"Capability nâng hạng của 1 NCC","parameters":[{"name":"supplier","in":"query","required":true,"schema":{"type":"string","enum":["airdata","tripota","skeeper"]}},{"name":"airline","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Capability","content":{"application/json":{"example":{"ok":true,"operation":"upgradeCapability","data":{"supported":false,"mode":"manual_only","supports_quote":false,"supports_idempotency":false,"reason":"Upgrade chưa bật cho NCC này"}}}}},"400":{"description":"SUPPLIER_REQUIRED"}}}},"/flights/upgrades/retrieve":{"post":{"tags":["Upgrade"],"summary":"Đọc state vé trước khi nâng hạng","description":"Cần ≥1 trong `bookingRef`/`booking_id`/`pnr`/`ticket_numbers`. Gate `FLIGHT_UPGRADE_ENABLED`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bookingRef":{"type":"string"},"booking_id":{"type":"string"},"pnr":{"type":"string"},"supplier":{"type":"string"},"airline":{"type":"string"},"ticket_numbers":{"type":"array","items":{"type":"string"}}}},"example":{"bookingRef":"bk_xxx"}}}},"responses":{"200":{"description":"State","content":{"application/json":{"example":{"ok":true,"operation":"upgradeRetrieve","data":{"upgrade_retrieve":{"status":"OK","state":"ISSUED","pnr":"FJA99U","tickets":[{"ticket_number":"7382315673190","state":"ISSUED","cabin":"Y","booking_class":"B","coupon_status":"OPEN"}],"segments":[{"segment_id":"s1","from":"SGN","to":"HAN","flown":false}]}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/upgrades/options":{"post":{"tags":["Upgrade"],"summary":"Tìm + báo giá option nâng hạng","description":"Trả `quote_id` (UPQ_*) + `options[]`. `status` ∈ HAS_OPTIONS|MANUAL_ONLY|NO_OPTION. TTL theo `FLIGHT_UPGRADE_QUOTE_TTL_MINUTES` (15).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"},"desired_cabin":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","desired_cabin":"C"}}}},"responses":{"200":{"description":"Options","content":{"application/json":{"example":{"ok":true,"operation":"upgradeOptions","data":{"upgrade_options":{"status":"HAS_OPTIONS","quote_id":"UPQ_xxx","expires_at":"2026-12-20T09:15:00Z","options":[{"option_id":"opt_1","operation_type":"DIRECT_UPGRADE","from_cabin":"Y","to_cabin":"C","fare_diff":1500000,"supplier_fee":0,"total_supplier_collect":1500000,"currency":"VND","rules":{"refundable":false,"changeable":true}}]}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/upgrades/reprice":{"post":{"tags":["Upgrade"],"summary":"Re-validate giá option (read-only)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["quote_id","option_id"],"properties":{"bookingRef":{"type":"string"},"quote_id":{"type":"string"},"option_id":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","quote_id":"UPQ_xxx","option_id":"opt_1"}}}},"responses":{"200":{"description":"Reprice — status ∈ PRICE_STILL_VALID|PRICE_CHANGED|NO_SEAT|REPRICE_FAILED|QUOTE_EXPIRED","content":{"application/json":{"example":{"ok":true,"operation":"upgradeReprice","data":{"upgrade_reprice":{"status":"PRICE_STILL_VALID","quote_id":"UPQ_xxx","option_id":"opt_1","total_supplier_collect":1500000,"currency":"VND","expires_at":"2026-12-20T09:20:00Z"}}}}}}}}},"/flights/upgrades/confirm":{"post":{"tags":["Upgrade"],"summary":"Xác nhận nâng hạng (idempotent, gated)","description":"CHỈ live khi `FLIGHT_UPGRADE_ENABLED` + `FLIGHT_UPGRADE_LIVE_EXECUTE_ENABLED` + supplier ∈ `FLIGHT_UPGRADE_SUPPORTED_SUPPLIERS` (deny-default). Timeout → `unknown` → dùng /retrieve-after. Bắt buộc `idempotency_key`.","parameters":[{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef","quote_id","option_id","idempotency_key"],"properties":{"bookingRef":{"type":"string"},"quote_id":{"type":"string"},"option_id":{"type":"string"},"scope":{"$ref":"#/components/schemas/ChangeScope"},"upgradeReference":{"type":"string"},"idempotency_key":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","quote_id":"UPQ_xxx","option_id":"opt_1","idempotency_key":"up-1"}}}},"responses":{"200":{"description":"Upgrade result (status ∈ success|already_upgraded|manual_required|live_disabled|quote_expired|price_changed|no_seat|reissued|failed|unknown)","content":{"application/json":{"example":{"ok":true,"operation":"upgradeConfirm","data":{"upgrade":{"ok":true,"status":"success","upgrade_state":"success","pnr":"FJA99U","new_tickets":["7382315673999"],"new_cabin":"C","new_booking_class":"D","amount_charged":1500000,"supplier_upgrade_ref":"UP1","can_retry":false,"recovered":false}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/upgrades/{upgradeRef}/retrieve-after":{"parameters":[{"name":"upgradeRef","in":"path","required":true,"schema":{"type":"string"},"description":""},{"name":"bookingRef","in":"query","required":false,"schema":{"type":"string"}}],"get":{"tags":["Upgrade"],"summary":"Đối soát sau confirm (resolve unknown)","responses":{"200":{"description":"Retrieve-after — status ∈ success|not_upgraded|unknown|manual_processing|not_found","content":{"application/json":{"example":{"ok":true,"operation":"upgradeRetrieveAfter","data":{"upgrade_retrieve_after":{"status":"success","upgrade_state":"success","pnr":"FJA99U","new_tickets":["7382315673999"],"new_cabin":"C","can_retry":false,"recovered":true}}}}}}}}},"/flights/splits/eligibility":{"post":{"tags":["Split"],"summary":"Kiểm tra điều kiện tách PNR (read-only)","description":"Gate `FLIGHT_SPLIT_ENABLED`. Trả `splitStage` (pre_issue/post_issue) + `warnings`. Bị chặn nếu có op nguy hiểm đang pending (issue/refund/exchange/baggage/upgrade).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef"],"properties":{"bookingRef":{"type":"string"},"pnr":{"type":"string"},"supplier":{"type":"string"},"airline":{"type":"string"},"selectedPassengers":{"$ref":"#/components/schemas/SelectedPassengers"}}},"example":{"bookingRef":"bk_xxx","selectedPassengers":[{"passengerId":"12190534"}]}}}},"responses":{"200":{"description":"Eligibility","content":{"application/json":{"example":{"ok":true,"operation":"splitEligibility","data":{"split_eligibility":{"eligible":true,"bookingState":"issued","splitStage":"post_issue","pnr":"FJA99U","passengerCount":3,"warnings":[],"reasonCode":null,"booking_ref":"bk_xxx","supplier":"tripota","retrieve_ok":true}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}}},"/flights/splits":{"post":{"tags":["Split"],"summary":"Tách hành khách ra PNR mới (idempotent, gated, locked)","description":"CHỈ live khi `FLIGHT_SPLIT_ENABLED` + `FLIGHT_SPLIT_LIVE_EXECUTE_ENABLED` + supplier ∈ `FLIGHT_SPLIT_SUPPORTED_SUPPLIERS` (deny-default). Lock per-booking (409 `SPLIT_IN_PROGRESS`). Timeout → `unknown` → dùng /retrieve.","parameters":[{"name":"X-Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bookingRef","selectedPassengers"],"properties":{"bookingRef":{"type":"string"},"selectedPassengers":{"$ref":"#/components/schemas/SelectedPassengers"},"splitReference":{"type":"string"},"reason":{"type":"string"},"note":{"type":"string"},"idempotencyKey":{"type":"string"}}},"example":{"bookingRef":"bk_xxx","selectedPassengers":[{"passengerId":"12190534"}],"reason":"customer request"}}}},"responses":{"200":{"description":"Split result (status ∈ success|already_split|rejected|failed|manual_processing|unknown)","content":{"application/json":{"example":{"ok":true,"operation":"splitExecute","data":{"split":{"ok":true,"status":"success","splitReference":"sp_xxx","splitStage":"post_issue","newPnr":"XYZ789","newBookingRef":"bk_new","selectedPassengers":[{"passengerId":"12190534"}],"can_retry":false,"recovered":false}}}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"SPLIT_IN_PROGRESS — đang có split khác chạy trên booking này","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/flights/splits/{splitRef}/retrieve":{"parameters":[{"name":"splitRef","in":"path","required":true,"schema":{"type":"string"},"description":""},{"name":"bookingRef","in":"query","required":false,"schema":{"type":"string"}}],"get":{"tags":["Split"],"summary":"Đối soát sau tách (resolve unknown)","responses":{"200":{"description":"Retrieve-after — status ∈ success|not_split|unknown|not_found","content":{"application/json":{"example":{"ok":true,"operation":"splitRetrieve","data":{"split_retrieve":{"status":"success","splitReference":"sp_xxx","newPnr":"XYZ789","newBookingRef":"bk_new","can_retry":false,"recovered":false}}}}}}}}},"/flights/check-credit":{"get":{"tags":["Ops"],"summary":"Kiểm tra credit balance đại lý","description":"Chỉ `airdata` hỗ trợ. `amount` optional để check đủ tiền (`sufficientCredit`). NCC khác → 501.","parameters":[{"name":"supplier","in":"query","required":true,"schema":{"type":"string","enum":["airdata","tripota","skeeper"]}},{"name":"amount","in":"query","required":false,"schema":{"type":"number"}}],"responses":{"200":{"description":"Credit","content":{"application/json":{"example":{"ok":true,"operation":"checkCredit","supplier":"airdata","data":{"creditBalance":50000000,"currency":"VND","sufficientCredit":true}}}}},"400":{"description":"MISSING_SUPPLIER"},"501":{"$ref":"#/components/responses/NotSupported"}}}},"/flights/available-distributor":{"get":{"tags":["Ops"],"summary":"Danh sách distributor/source khả dụng","description":"Chỉ `airdata` hỗ trợ. Shape `raw` tuỳ NCC — đọc defensive. NCC khác → 501.","parameters":[{"name":"supplier","in":"query","required":true,"schema":{"type":"string","enum":["airdata","tripota","skeeper"]}}],"responses":{"200":{"description":"Distributors","content":{"application/json":{"example":{"ok":true,"operation":"availableDistributors","supplier":"airdata","data":{"items":[{"id":"VN1A","name":"Vietnam Airlines 1A","source":"VN1A","status":"active"}]}}}}},"400":{"description":"MISSING_SUPPLIER"},"501":{"$ref":"#/components/responses/NotSupported"}}}},"/flights/display-policy":{"get":{"tags":["Search"],"summary":"Chính sách hiển thị áp cho CHÍNH key đang gọi","description":"Profile của kênh mà key này thuộc (key không thuộc kênh nào → `DEFAULT`). Dùng để lấy nhãn / ưu tiên NCC (sắp xếp, phá hoà), cấu hình gốc cho rule riêng của đại lý, và `version` để xoá cache khi cấu hình đổi. Không lộ profile của kênh khác. `stale: true` = server tạm mất Redis, đang áp bản gần nhất.","responses":{"200":{"description":"Profile hiệu lực","content":{"application/json":{"schema":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"$ref":"#/components/schemas/DisplayRuntimeView","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"nullable":true,"oneOf":[{"$ref":"#/components/schemas/ErrorObj"},{"type":"null"}],"description":"null khi `ok=true`. Object khi `ok=false`."},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}},"example":{"ok":true,"data":{"version":12,"channel":"AG","mode":"all","suppliers":{"tripota":{"shown":false,"priority":1,"label":"HNH"},"airdata":{"shown":true,"priority":2,"label":"BGT"},"skeeper":{"shown":true,"priority":3,"label":"HPL"}},"supplierAirlines":{},"markets":{"domestic":{"unlisted":"SHOW","airlines":{"VJ":false}},"international":{"unlisted":"SHOW","airlines":{}}},"enforceOnBooking":true,"stale":false,"source":"runtime"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/admin/display/meta":{"get":{"tags":["DisplayPolicyAdmin"],"summary":"Danh mục + cấu hình + bảng hãng × NCC cho trang quản trị","security":[{"AdminKeyAuth":[]}],"description":"Nguồn duy nhất để CMS dựng trang — không hardcode gì: `catalog` (NCC + nhãn mặc định, thị trường, `modes`, `unlistedModes`, trạng thái ô `cells`, `availableCells`, trạng thái dòng `rows`, `blockedReasons`), `limits`, `matching` (luật khớp), `current` (toàn bộ cấu hình + version), `request` (kênh / thị trường / cửa sổ đã dùng; `profileExists=false` = kênh chưa có profile, đang xem theo DEFAULT) và `coverage.airlines[]`: mỗi hãng một dòng `{ code, ticked, declared, availability, effectiveShown, observedFares, lastSeenAt, sources[] }`, mỗi `sources[]` là một ô NCC `{ supplier, label, cell, configured, tokens, routed, shown, observed }`. Dòng `NO_ACTIVE_SUPPLIER` → làm mờ, khoá checkbox, VẪN hiện `ticked` đang lưu. Server chỉ trả mã hãng; tên / logo do CMS ghép.","parameters":[{"name":"channel","in":"query","required":false,"schema":{"type":"string","default":"DEFAULT","example":"AG"}},{"name":"market","in":"query","required":false,"schema":{"type":"string","enum":["domestic","international"],"default":"domestic"}},{"name":"windowDays","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":30},"description":"Cửa sổ \"đã thấy vé\". Mặc định 7 (nội địa) / 30 (quốc tế)."}],"responses":{"200":{"description":"Meta","content":{"application/json":{"schema":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"$ref":"#/components/schemas/DisplayPolicyMeta","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"nullable":true,"oneOf":[{"$ref":"#/components/schemas/ErrorObj"},{"type":"null"}],"description":"null khi `ok=true`. Object khi `ok=false`."},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"description":"`POLICY_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/display/policy":{"get":{"tags":["DisplayPolicyAdmin"],"summary":"Toàn bộ cấu hình (mọi kênh)","security":[{"AdminKeyAuth":[]}],"responses":{"200":{"description":"Cấu hình","content":{"application/json":{"schema":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"$ref":"#/components/schemas/DisplayPolicyView","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"nullable":true,"oneOf":[{"$ref":"#/components/schemas/ErrorObj"},{"type":"null"}],"description":"null khi `ok=true`. Object khi `ok=false`."},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"description":"`POLICY_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}},"put":{"tags":["DisplayPolicyAdmin"],"summary":"Sửa cấu hình (gộp vào bản đang lưu)","security":[{"AdminKeyAuth":[]}],"description":"`channels` gửi lên là THAY CẢ BẢNG. `profiles.<KÊNH>` là bản vá GỘP vào profile đang lưu; kênh chưa có profile thì bắt đầu từ bản sao của DEFAULT; `profiles.<KÊNH>: null` xoá profile (kênh về DEFAULT), `profiles.DEFAULT: null` về mặc định. Trong `markets.*.airlines` và `supplierAirlines`, giá trị `null` = bỏ khai báo. Ghi đè theo hãng phải khai ĐỦ 3 NCC. `reason` bắt buộc (kèm user CMS). Không đổi gì → `changed: false`, version giữ nguyên. Có hiệu lực trên mọi pod ~1s (pub/sub, đối chiếu mỗi 30s), không cần search lại.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DisplayPolicyUpdate"},"example":{"profiles":{"DEFAULT":{"markets":{"domestic":{"airlines":{"VJ":{"shown":true,"suppliers":{"tripota":false,"airdata":false,"skeeper":true}},"QH":false}},"international":{"airlines":{"VJ":{"shown":true,"suppliers":{"tripota":false,"airdata":true,"skeeper":false}},"MH":null}}},"supplierAirlines":{"VJ":null}}},"reason":"nguyenvana: VJ nội địa chỉ HPL, quốc tế chỉ BGT","expectedVersion":11}}}},"responses":{"200":{"description":"`{ changed, version, updatedAt, channels, profiles, warnings[] }`. Cảnh báo không chặn: `AIRLINE_NO_ACTIVE_SUPPLIER`, `AIRLINE_NEVER_OBSERVED`, `CHANNEL_HAS_NO_AGENCY`, `AIRLINE_SUPPLIER_NO_DATA`, `AIRLINE_SUPPLIER_NOT_RUNNING` và `AIRLINE_SUPPLIER_OPS_HIDDEN` (ba mã cuối kèm `supplier`, cho NCC bật tường minh `true`: chưa có kết nối / vé của hãng; NCC không chạy ở thị trường đó; bị công tắc ops ẩn)."},"400":{"description":"`VALIDATION`, `AGENCY_IN_TWO_CHANNELS`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`VERSION_CONFLICT` (details.currentVersion); `WOULD_HIDE_EVERYTHING` (details.findings[] `{ channel, market, reason: ALL_SUPPLIERS_HIDDEN | ALL_AIRLINES_HIDDEN }` — gửi lại với `acknowledgeWarnings: true` nếu đúng ý); `CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"503":{"description":"`POLICY_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/display/reset":{"post":{"tags":["DisplayPolicyAdmin"],"summary":"Khẩn cấp: hiện lại tất cả","security":[{"AdminKeyAuth":[]}],"description":"Không `channel` → cả cấu hình về mặc định (xoá cả bảng kênh). `channel: DEFAULT` → profile DEFAULT về mặc định. `channel: <KÊNH>` → xoá profile kênh đó. Gọi lặp lại vẫn an toàn.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["reason"],"additionalProperties":false,"properties":{"reason":{"type":"string","minLength":5,"maxLength":500},"channel":{"type":"string","example":"AG"}}},"example":{"reason":"nguyenvana: mở lại toàn bộ để kiểm tra","channel":"AG"}}}},"responses":{"200":{"description":"`{ changed, version, channels, profiles }`"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`CONFIG_BUSY`"},"503":{"description":"`POLICY_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/display/history":{"get":{"tags":["DisplayPolicyAdmin"],"summary":"Nhật ký thay đổi","security":[{"AdminKeyAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":500,"default":50}},{"name":"channel","in":"query","required":false,"schema":{"type":"string","example":"AG"},"description":"Chỉ các lần sửa đụng tới profile này."}],"responses":{"200":{"description":"`data.entries[]` mới nhất trước: `{ at, version, action, actor, reason, channels[], before, after }`"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/admin/selling-price/meta":{"get":{"tags":["SellingPriceAdmin"],"summary":"Danh mục + cấu hình hiện tại cho trang quản trị","security":[{"AdminKeyAuth":[]}],"description":"Nguồn duy nhất để trang quản trị (CMS DLV) dựng form rule — không hardcode danh mục nào: `modes`, `systems`, `partners`, `partnerSystems` (hệ thống GDS THẬT của từng NCC, suy từ env fan-out), `cabins`, `paxTypes`, `tripTypes`, `daysOfWeek`, `discountTypes`, `discountBases`, `roundingModes`, `ruleStatuses` / `writableRuleStatuses`, `limits` (`bulkMaxRules`, `ruleIdPattern`, `reservedRuleIds`, `percentMax`, `fareBasisWildcard`, biên `priceLockMinutes`, `advanceDaysMax`, giới hạn `channels`, `tagsMax`, `saleTimePattern`, `reasonMinLength`), `matching` (khớp mọi chặng chiều đi, nguồn hạng vé, kiểu làm tròn đang dùng, khung giờ nửa mở, cách tính mua-trước, cách đo giá vé, cách hạ trần theo đơn, ngân sách mềm, **thứ tự quyết định chế độ**, múi giờ, không cộng dồn, thứ tự ưu tiên) và `current` (chế độ, ghi đè theo NCC, `channels`, `channelModes`, `effectiveByChannel`, `priceLockMinutes`, `defaultPaxTypes`, `rounding`, version, người sửa).","responses":{"200":{"description":"Meta","content":{"application/json":{"example":{"ok":true,"data":{"modes":["off","shadow","on"],"systems":["GALILEO","AMADEUS","SABRE","ANY_GDS"],"partners":["HNH","BGT","HPL"],"partnerSystems":{"HNH":["AMADEUS"],"BGT":["GALILEO","SABRE"],"HPL":["GALILEO"]},"cabins":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST"],"paxTypes":["ADT","CHD","INF"],"discountTypes":["PERCENT","FIXED_AMOUNT"],"discountBases":["BASE_FARE","TOTAL_FARE"],"writableRuleStatuses":["DRAFT","ACTIVE","INACTIVE"],"limits":{"bulkMaxRules":1000,"ruleIdPattern":"^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$","reservedRuleIds":["bulk","preview"],"percentMax":100,"fareBasisWildcard":"*","priceLockMinutes":{"min":15,"max":240,"default":60},"reasonMinLength":3},"matching":{"classCodes":"ALL_OUTBOUND_SEGMENTS","fareFamilySource":"FARE_OWN_DECODED_CODE","rounding":"FLOOR_TO_UNIT","stacking":"NONE","dates":"VIETNAM_CALENDAR_DAYS_INCLUSIVE","tieBreak":["priority","specificity","updated_at","rule_id"]},"current":{"mode":"off","partners":{},"effective":{"HNH":"off","BGT":"off","HPL":"off"},"version":0,"priceLockMinutes":60,"defaultPaxTypes":["ADT","CHD"]}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"description":"`SETTINGS_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/settings":{"get":{"tags":["SellingPriceAdmin"],"summary":"Chế độ giá bán hiện tại","security":[{"AdminKeyAuth":[]}],"description":"Chế độ chung, ghi đè theo NCC, chế độ thực tế từng NCC (`effective`), version, người sửa.","responses":{"200":{"description":"Settings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellingPriceSettingsView"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"description":"`SETTINGS_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}},"put":{"tags":["SellingPriceAdmin"],"summary":"Đổi chế độ (off / shadow / on, ghi đè theo NCC)","security":[{"AdminKeyAuth":[]}],"description":"Có hiệu lực ngay trên mọi pod (pub/sub ~1s, đối chiếu mỗi 30s); kết quả search trong cache tự tính lại ở lượt đọc kế tiếp, không gọi NCC. Bắt buộc `reason`. Gửi `expectedVersion` để hai người không sửa đè nhau.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellingPriceSettingsUpdate"},"example":{"mode":"shadow","partners":{"BGT":"on"},"reason":"Bật chính thức cho BGT, HNH và HPL chạy đối soát","expectedVersion":42}}}},"responses":{"200":{"description":"Settings sau khi đổi","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellingPriceSettingsView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`VERSION_CONFLICT` (expectedVersion lệch), `FORCED_OFF` (env `SELLING_PRICE_FORCE_OFF=true` chặn bật), `CONFIG_BUSY` (lệnh sửa khác đang chạy — thử lại)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"versionConflict":{"value":{"ok":false,"error":{"code":"VERSION_CONFLICT","message":"Cấu hình đã được sửa (version 43)","category":"logical","retryable":false}}},"forcedOff":{"value":{"ok":false,"error":{"code":"FORCED_OFF","message":"SELLING_PRICE_FORCE_OFF=true đang ép tắt; không bật được qua API","category":"logical","retryable":false}}}}}}},"503":{"description":"`SETTINGS_STORE_UNAVAILABLE` — không ghi được, cài đặt cũ giữ nguyên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/off":{"post":{"tags":["SellingPriceAdmin"],"summary":"Tắt khẩn cấp","security":[{"AdminKeyAuth":[]}],"description":"Về `off`, xoá mọi ghi đè theo NCC. Chỉ cần `reason`. Gọi lặp lại vẫn an toàn. Booking đang dở với vé đã giảm giá sẽ nhận `SELLING_PRICE_CHANGED` (không trừ tiền sai).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["reason"],"additionalProperties":false,"properties":{"reason":{"type":"string","minLength":3,"maxLength":500}}},"example":{"reason":"Sai giá SGN-NRT, tắt để kiểm tra"}}}},"responses":{"200":{"description":"Settings sau khi tắt","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellingPriceSettingsView"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"503":{"description":"`SETTINGS_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/settings/history":{"get":{"tags":["SellingPriceAdmin"],"summary":"Lịch sử bật / tắt","security":[{"AdminKeyAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":500,"default":50}}],"responses":{"200":{"description":"`data.entries[]` mới nhất trước: `{ at, configVersion, action, actor, reason, before, after }`"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/admin/selling-price/rules":{"get":{"tags":["SellingPriceAdmin"],"summary":"Danh sách rule","security":[{"AdminKeyAuth":[]}],"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["DRAFT","ACTIVE","INACTIVE","DELETED"]}},{"name":"system","in":"query","required":false,"schema":{"type":"string","enum":["GALILEO","AMADEUS","SABRE","ANY_GDS"]}},{"name":"airline","in":"query","required":false,"schema":{"type":"string","example":"VN"}},{"name":"partner","in":"query","required":false,"schema":{"type":"string","enum":["HNH","BGT","HPL"]}},{"name":"tag","in":"query","required":false,"schema":{"type":"string","example":"q4-2026"},"description":"Một nhãn của rule"},{"name":"q","in":"query","required":false,"schema":{"type":"string","maxLength":100},"description":"Tìm trong `rule_id`, `name`, `description`, `owner`, `tags`"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":1000,"default":200}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"`data.rules[]` (rule có ngân sách kèm `budget_spent`) + `total`, `limit`, `offset`","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"rules":{"type":"array","items":{"$ref":"#/components/schemas/PricingRule"}},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"post":{"tags":["SellingPriceAdmin"],"summary":"Tạo rule (mặc định DRAFT)","security":[{"AdminKeyAuth":[]}],"description":"Body = các field của rule + `reason?`, `acknowledgeWarnings?`. Kích hoạt rule chết (NCC không có hệ thống đó theo fan-out THẬT của adapter, hãng bị chặn bán qua GDS, khu vực chưa khai) → 409 `RULE_WILL_NOT_MATCH` kèm lý do; gửi lại với `acknowledgeWarnings: true` để vẫn kích hoạt. `data.warnings` có thể chứa `SAME_SCOPE_SAME_PRIORITY` (trùng khít phạm vi) và `SAME_PRIORITY_MAY_OVERLAP` (cùng priority, có thể cùng khớp một vé — đặt priority khác nhau nếu muốn chắc rule nào thắng).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingRule"},"example":{"rule_id":"gds-1g-sq-sgn-sin","name":"SQ Galileo SGN-SIN 5%","status":"DRAFT","priority":100,"product_type":"FLIGHT","system":"GALILEO","partner":"BGT","trip_scope":"INTERNATIONAL","airline_codes":["SQ"],"origin":["SGN"],"destination":["SIN"],"travel_from":"2026-10-01","travel_to":"2026-12-31","cabins":["ECONOMY"],"discount_type":"PERCENT","discount_value":5,"discount_base":"BASE_FARE","max_discount":500000,"currency":"VND","reason":"Chương trình Q4"}}}},"responses":{"201":{"description":"`data.rule`, `data.warnings[]`"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`RULE_EXISTS` (kể cả id đã xoá mềm), `RULE_WILL_NOT_MATCH`, `CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/rules/bulk":{"put":{"tags":["SellingPriceAdmin"],"summary":"Đồng bộ cả bộ rule trong một lệnh","security":[{"AdminKeyAuth":[]}],"description":"Thay **toàn bộ** rule bằng `rules[]` (tối đa 1000). **Tất cả hoặc không gì cả**: mọi rule được kiểm tra hợp lệ và kiểm tra rule chết TRƯỚC khi ghi; một rule sai → không ghi rule nào.\n\nTheo `rule_id`: chưa có → tạo; có, nội dung khác → sửa (version + 1); đã xoá mềm → khôi phục; nội dung giống → giữ nguyên; **có trong hệ thống nhưng không gửi → xoá mềm**. Không được gửi `status: DELETED` (bỏ rule ra khỏi `rules[]`).\n\nVersion cấu hình tăng **tối đa 1 lần**, và chỉ khi chạm rule `ACTIVE`. `expectedVersion` so với version cấu hình chung. Gửi lại đúng bộ đang lưu → `changed: false`, không tăng version.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["rules"],"additionalProperties":false,"properties":{"rules":{"type":"array","maxItems":1000,"items":{"$ref":"#/components/schemas/PricingRule"}},"reason":{"type":"string","minLength":3,"maxLength":500},"expectedVersion":{"type":"integer","minimum":0},"acknowledgeWarnings":{"type":"boolean","description":"Vẫn kích hoạt rule chết (NCC không có hệ thống đó / hãng bị chặn qua GDS)"}}},"example":{"reason":"Đồng bộ từ trang quản trị DLV","expectedVersion":42,"rules":[{"rule_id":"gds-1g-sq-sgn-sin","name":"SQ Galileo SGN-SIN 5%","status":"ACTIVE","priority":100,"product_type":"FLIGHT","system":"GALILEO","airline_codes":["SQ"],"origin":["SGN"],"destination":["SIN"],"discount_type":"PERCENT","discount_value":5,"discount_base":"BASE_FARE","currency":"VND"}]}}}},"responses":{"200":{"description":"Kết quả","content":{"application/json":{"example":{"ok":true,"data":{"changed":true,"version":43,"created":["gds-1g-sq-sgn-sin"],"updated":[],"restored":[],"unchanged":[],"deleted":["old-rule"],"deadRules":[],"conflicts":[],"ruleCount":1}},"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"changed":{"type":"boolean"},"version":{"type":"integer"},"created":{"type":"array","items":{"type":"string"}},"updated":{"type":"array","items":{"type":"string"}},"restored":{"type":"array","items":{"type":"string"}},"unchanged":{"type":"array","items":{"type":"string"}},"deleted":{"type":"array","items":{"type":"string"}},"deadRules":{"type":"array","description":"Mọi rule ACTIVE có lý do không khớp (`acknowledged: true` nếu vừa được kích hoạt nhờ acknowledgeWarnings)","items":{"type":"object","properties":{"rule_id":{"type":"string"},"reasons":{"type":"array","items":{"type":"object"}},"acknowledged":{"type":"boolean"}}}},"conflicts":{"type":"array","description":"Nhóm rule ACTIVE trùng phạm vi và priority (cảnh báo, không chặn)","items":{"type":"object","properties":{"code":{"type":"string","enum":["SAME_SCOPE_SAME_PRIORITY"]},"priority":{"type":"integer"},"ruleIds":{"type":"array","items":{"type":"string"}},"message":{"type":"string"}}}},"overlaps":{"type":"array","description":"Cặp rule ACTIVE cùng priority, phạm vi KHÁC nhau nhưng có thể cùng khớp một vé (khi đó rule nhiều điều kiện hơn rồi rule sửa gần nhất thắng). Cảnh báo, không chặn; tối đa 200 cặp.","items":{"type":"object","properties":{"priority":{"type":"integer"},"ruleIds":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":2}}}},"ruleCount":{"type":"integer"}}}}}}}},"400":{"description":"`VALIDATION` — `error.details[].path` dạng `rules.<index>.<field>`; không ghi gì","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`RULE_WILL_NOT_MATCH` (`error.details.rules[]` = mọi rule chết chưa acknowledge; không ghi gì), `VERSION_CONFLICT`, `CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"503":{"description":"`SETTINGS_STORE_UNAVAILABLE`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/metrics":{"get":{"tags":["SellingPriceAdmin"],"summary":"Hiệu quả rule (bộ đếm của pod từ lúc khởi động)","security":[{"AdminKeyAuth":[]}],"description":"Bộ đếm trong RAM của pod trả lời (reset khi restart). `fares`: vé GDS được tính giá lúc tạo (không đếm lần đọc cache). `bookings`: booking đã lưu có rule áp, kèm tổng `discount_total` (`on` = tiền đã giảm thật, `shadow` = số sẽ giảm). `blocked_selling_price_changed`: số lần book bị chặn `SELLING_PRICE_CHANGED`.\n\n`budgets`: ngân sách từng rule (`total`, `spent`, `remaining`, `exhausted`) — số này BỀN và dùng chung mọi pod, không reset khi restart.","responses":{"200":{"description":"Counters","content":{"application/json":{"example":{"ok":true,"data":{"since":"2026-09-17T08:00:00.000Z","fares":{"total":120,"by_mode":{"shadow":120,"on":0},"by_status":{"APPLIED":80,"NO_RULE":40}},"bookings":{"total":3,"by_mode":{"shadow":3,"on":0},"discount_total":{"shadow":519750,"on":0}},"blocked_selling_price_changed":0,"by_rule":{"gds-1g-sq-sgn-sin":{"fares":{"shadow":80,"on":0},"bookings":{"shadow":3,"on":0},"discount_total":{"shadow":519750,"on":0}}},"budgets":{"gds-1g-sq-sgn-sin":{"total":50000000,"spent":519750,"remaining":49480250,"exhausted":false,"status":"ACTIVE"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/admin/selling-price/simulate":{"post":{"tags":["SellingPriceAdmin"],"summary":"Mô phỏng giá bán cho một vé gõ tay","security":[{"AdminKeyAuth":[]}],"description":"Vé gõ tay đi qua ĐÚNG hàm tính giá của search (pricingInputOf / priceFare) — khoang và hạng vé tự suy như search nếu không gõ. **Không cần cache, không search, không gọi NCC** (khác `/rules/preview`). Mặc định chỉ xét rule `ACTIVE`; `includeDrafts: true` để thử nháp; `rule` = rule chưa lưu để thử. `agency` / `at` = xem như kênh nào, vào lúc nào. `warnings`: `PARTNER_NOT_GIVEN`, `PARTNER_SYSTEM_UNAVAILABLE`, `NOT_LIVE` (chế độ đang chạy khác `on` ⇒ khách không thấy giá này), `BLOCKED_BY_DLV_SOURCE_POLICY`, `TAX_NOT_GIVEN` (thuế không nhập được tính là 0), `AIRPORT_COUNTRY_UNKNOWN` (rule theo nước/khu vực sẽ không khớp). `input.supplierSource` là token NCC đó thật sự dùng (HPL + GALILEO → GALILEO_NDC).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["system","airline","legs","fare"],"additionalProperties":false,"properties":{"system":{"type":"string","enum":["GALILEO","AMADEUS","SABRE"]},"partner":{"type":"string","enum":["HNH","BGT","HPL"],"description":"NCC. Bỏ trống thì rule có điều kiện NCC không được xét."},"airline":{"type":"string","example":"SQ"},"legs":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"object","required":["from","to","departDate"],"additionalProperties":false,"properties":{"from":{"type":"string","example":"SGN"},"to":{"type":"string","example":"SIN"},"departDate":{"type":"string","format":"date"},"arriveDate":{"type":"string","format":"date"},"airline":{"type":"string"},"flightNumber":{"type":"string","example":"SQ177"},"bookingClass":{"type":"string","example":"N"},"fareBasis":{"type":"string","example":"N16VNO"}}}},"returnDate":{"type":"string","format":"date","description":"Có = khách tìm khứ hồi (trip_types ROUND_TRIP)."},"cabin":{"type":"string","enum":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST"]},"fareFamily":{"type":"string"},"currency":{"type":"string","default":"VND"},"fare":{"type":"object","required":["ADT"],"properties":{"ADT":{"type":"number"},"CHD":{"type":"number"},"INF":{"type":"number"}},"description":"Giá gốc (base fare) mỗi khách. CHD/INF bắt buộc khi có khách loại đó."},"tax":{"type":"object","properties":{"ADT":{"type":"number"},"CHD":{"type":"number"},"INF":{"type":"number"}}},"pax":{"type":"object","properties":{"adt":{"type":"integer","default":1},"chd":{"type":"integer","default":0},"inf":{"type":"integer","default":0}}},"agency":{"type":"string"},"at":{"type":"string","format":"date-time"},"rule":{"$ref":"#/components/schemas/PricingRule"},"includeDrafts":{"type":"boolean","default":false}}},"example":{"system":"GALILEO","partner":"BGT","airline":"SQ","legs":[{"from":"SGN","to":"SIN","departDate":"2026-11-18","arriveDate":"2026-11-18","flightNumber":"SQ177","bookingClass":"N","fareBasis":"N16VNO"}],"fare":{"ADT":3465000},"tax":{"ADT":582000}}}}},"responses":{"200":{"description":"`data`: `result` (status, ruleId, discountTotal, perPax, netTotalPrice, sellingPrice…), `winner{rule_id,name,status}`, `trace[]` ({ruleId,name,status,priority,matched,currencyMatches,unknownRegions?,budgetExhausted?} theo thứ tự thắng), `input` (giá trị engine đọc được từ vé gõ tay), `as{agency,channel,at,rounding,partner,mode}`, `candidate{rule_id,deadReasons}`, `warnings[]`, `configVersion`","content":{"application/json":{"example":{"ok":true,"data":{"result":{"status":"APPLIED","ruleId":"sq-10","discountTotal":346500,"netTotalPrice":4047000,"sellingPrice":3700500},"winner":{"rule_id":"sq-10","name":"SQ 10%","status":"ACTIVE"},"trace":[{"ruleId":"sq-10","matched":true,"currencyMatches":true}],"warnings":[{"code":"NOT_LIVE","mode":"off"}]}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/admin/selling-price/rules/preview":{"post":{"tags":["SellingPriceAdmin"],"summary":"Xem trước rule trên kết quả search đang có trong cache","security":[{"AdminKeyAuth":[]}],"description":"Chạy rule `ACTIVE` + `DRAFT` đã lưu, cộng rule `rule` chưa lưu (nếu gửi), trên kết quả search **đang có trong cache** cho `search`. **Không gọi NCC** — cache chưa có → 404 `CACHE_MISS`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["search"],"additionalProperties":false,"properties":{"search":{"$ref":"#/components/schemas/SearchRequest"},"rule":{"$ref":"#/components/schemas/PricingRule"},"limit":{"type":"integer","minimum":1,"maximum":200,"default":50},"agency":{"type":"string","example":"acme","description":"Xem như kênh/đại lý nào đang mua (rule `channels` / `agencies`)."},"at":{"type":"string","format":"date-time","example":"2026-10-20T12:30:00+07:00","description":"Xem vào lúc nào — thử flash sale (`sale_time_*`) và mua-trước-N-ngày trước khi bật."}}},"example":{"search":{"startPoint":"SGN","endPoint":"SIN","departDate":"2026-10-20","adt":1},"limit":20,"agency":"acme","at":"2026-10-20T12:30:00+07:00"}}}},"responses":{"200":{"description":"`data`: `cache`, `configVersion`, `rules{evaluated,skipped}`, `candidate{rule_id,deadReasons}`, `totals{fares,gdsFares,matched,byStatus}`, `observed{systems,airlines,cabins,bookingClasses,fareBases,fareFamilies,tripTypes}` (giá trị CÓ THẬT trong kết quả search đã cache, kèm số vé — để CMS dựng dropdown), `as{agency,channel,at,rounding}` (preview đã giả định gì), `rules.budgetExhausted[]`, `byRule{ruleId:{fares,discountTotal}}`, `fares[]` mẫu (giá trước / sau, kèm `bookingClasses`, `fareBases`, `fareFamily`, `tripType`)"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`CACHE_MISS`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/rules/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"rule_id"}],"get":{"tags":["SellingPriceAdmin"],"summary":"Chi tiết rule + lịch sử sửa","security":[{"AdminKeyAuth":[]}],"responses":{"200":{"description":"`data.rule`, `data.history[]`"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`RULE_NOT_FOUND`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}},"put":{"tags":["SellingPriceAdmin"],"summary":"Sửa rule (tăng version của rule)","security":[{"AdminKeyAuth":[]}],"description":"Body = toàn bộ field của rule + `reason?`, `expectedVersion?` (so với `version` của rule đó), `acknowledgeWarnings?`. Chỉ thay đổi chạm tới rule `ACTIVE` mới tăng version cấu hình.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingRule"}}}},"responses":{"200":{"description":"`data.rule`, `data.warnings[]`"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`RULE_NOT_FOUND`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"409":{"description":"`VERSION_CONFLICT`, `RULE_DELETED`, `RULE_WILL_NOT_MATCH`, `CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}},"delete":{"tags":["SellingPriceAdmin"],"summary":"Xoá mềm rule","security":[{"AdminKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"reason":{"type":"string","minLength":3,"maxLength":500}}}}}},"responses":{"200":{"description":"`data.rule` (status `DELETED`). Gọi lặp lại vẫn an toàn"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`RULE_NOT_FOUND`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/rules/{id}/status":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"rule_id"}],"patch":{"tags":["SellingPriceAdmin"],"summary":"Bật / tắt một rule","security":[{"AdminKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"additionalProperties":false,"properties":{"status":{"type":"string","enum":["DRAFT","ACTIVE","INACTIVE"]},"reason":{"type":"string","minLength":3,"maxLength":500},"expectedVersion":{"type":"integer","minimum":1},"acknowledgeWarnings":{"type":"boolean"}}},"example":{"status":"ACTIVE","reason":"Mở chương trình","expectedVersion":2}}}},"responses":{"200":{"description":"`data.rule`, `data.warnings[]`"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`RULE_NOT_FOUND`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"409":{"description":"`VERSION_CONFLICT`, `RULE_DELETED`, `RULE_WILL_NOT_MATCH`, `CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/admin/selling-price/rules/{id}/budget/reset":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"rule_id"}],"post":{"tags":["SellingPriceAdmin"],"summary":"Bắt đầu kỳ ngân sách mới cho một rule","security":[{"AdminKeyAuth":[]}],"description":"Xoá bộ đếm `budget_total` của rule (ghi lịch sử `BUDGET_RESET`). **Không** tăng version cấu hình: các pod đọc lại bộ đếm ở nhịp poll kế tiếp (≤30s), và kết quả search đã cache tự tính lại khi danh sách rule hết ngân sách đổi.","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"reason":{"type":"string","minLength":3,"maxLength":500}}}}}},"responses":{"200":{"description":"`data`: `rule_id`, `budgetTotal`, `budgetSpent` (= 0), `previousSpent`","content":{"application/json":{"example":{"ok":true,"data":{"rule_id":"gds-1g-sq-sgn-sin","budgetTotal":50000000,"budgetSpent":0,"previousSpent":49900000,"version":43,"changed":true}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`RULE_NOT_FOUND`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"409":{"description":"`CONFIG_BUSY`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key được cấp cho mỗi đại lý (env `API_KEY_DEFAULT` hoặc `AGENCY_KEY_<name>`). Liên hệ DLV Tech."},"AdminKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Key admin riêng (env `ADMIN_KEY_<TÊN>`) — chỉ cho `/admin/selling-price/*`. Key đại lý bị từ chối (403). Tên key được ghi làm người sửa (`updatedBy`). Có thể giới hạn IP bằng `ADMIN_ALLOWED_IPS`."}},"responses":{"BadRequest":{"description":"Validation lỗi — thiếu/sai field. Response có `error.details[]`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"example":{"ok":false,"error":{"code":"VALIDATION","message":"Invalid request body","category":"validation","retryable":false,"details":[{"path":"passengers.0.type","message":"Invalid option: expected ADULT|CHILD|INFANT","code":"invalid_value"}]}}}}},"Unauthorized":{"description":"Thiếu API key. Gắn `X-API-Key: <key>`.","content":{"application/json":{"example":{"error":"Missing API key. Use X-API-Key header."}}}},"Forbidden":{"description":"API key sai hoặc bị revoke.","content":{"application/json":{"example":{"error":"Invalid API key."}}}},"NotFound":{"description":"Booking/ticket không tồn tại hoặc đã expire (TTL 90d booked, 365d issued).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"example":{"ok":false,"error":{"code":"BOOKING_NOT_FOUND","message":"Booking \"bk_xxx\" not found or expired","category":"logical","retryable":false}}}}},"Conflict":{"description":"Supplier từ chối hợp lệ (vd. System is not supported, wrong state, quota).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"example":{"ok":false,"error":{"code":"SUPPLIER_REJECTED","message":"tripota rejected request: HTTP 400","supplierCode":"00038","supplierMessage":"System is not supported","category":"logical","retryable":false}}}}},"BadGateway":{"description":"Aggregator unreachable.","content":{"application/json":{"example":{"error":"Aggregator unavailable","details":"AbortError: signal timed out"}}}},"NotSupported":{"description":"Supplier không implement operation này.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"example":{"ok":false,"error":{"code":"NOT_SUPPORTED_BY_OWNING_SUPPLIER","message":"Operation \"exchange\" not supported by supplier \"skeeper\"","category":"capability","retryable":false}}}}}},"schemas":{"IataCode":{"type":"string","minLength":3,"maxLength":3,"pattern":"^[A-Z]{3}$","example":"SGN","description":"Mã sân bay IATA 3 ký tự"},"IsoDate":{"type":"string","format":"date","example":"2026-12-20","description":"Ngày YYYY-MM-DD"},"PaxType":{"type":"string","enum":["ADULT","CHILD","INFANT","ADT","CHD","INF"]},"Currency":{"type":"string","example":"VND"},"SearchRequest":{"type":"object","required":["startPoint","endPoint","departDate"],"description":"Một chiều (OW), khứ hồi (thêm `returnDate`), đa chặng (dùng `flights[]` thay `startPoint/endPoint/departDate`).","properties":{"type":{"type":"string","enum":["OW","RT","MC"],"description":"Optional hint. Server tự infer từ returnDate/flights[]"},"startPoint":{"$ref":"#/components/schemas/IataCode"},"endPoint":{"$ref":"#/components/schemas/IataCode"},"departDate":{"$ref":"#/components/schemas/IsoDate"},"returnDate":{"allOf":[{"$ref":"#/components/schemas/IsoDate"}],"nullable":true,"description":"Nếu có → round-trip"},"flights":{"type":"array","description":"Multi-city: mỗi item là 1 chặng. Nếu dùng thì `startPoint/endPoint/departDate` top-level bỏ qua. Item hỗ trợ thêm `returnDate?` và `leg?` (int ≥ 0).","items":{"type":"object","required":["startPoint","endPoint","departDate"],"properties":{"startPoint":{"$ref":"#/components/schemas/IataCode"},"endPoint":{"$ref":"#/components/schemas/IataCode"},"departDate":{"$ref":"#/components/schemas/IsoDate"},"returnDate":{"$ref":"#/components/schemas/IsoDate"},"leg":{"type":"integer","minimum":0}}}},"adt":{"type":"integer","minimum":1,"maximum":9,"default":1},"chd":{"type":"integer","minimum":0,"maximum":9,"default":0,"description":"2-12 tuổi"},"inf":{"type":"integer","minimum":0,"maximum":9,"default":0,"description":"< 2 tuổi"},"airlines":{"type":"array","items":{"type":"string"},"example":["VN","VJ","QH","VU","BL"],"description":"Filter post-aggregation. BL match cả operating-carrier codeshare."},"airline":{"type":"string","example":"VN","description":"DEPRECATED-on-arrival alias of airlines[0]. Kept for DLV PHP compatibility. Prefer airlines:[...] for new integrations. If both are sent, airlines wins."},"preferCabin":{"type":"string","enum":["Y","F","C","W","M"],"description":"Y=Economy, C=Business, F=First, W=Premium Economy, M=Mixed"},"promoCode":{"type":"string","description":"Mã chung, gửi cho MỌI hãng ở HNH/HPL (BGT search không nhận). Muốn mã của một hãng thì dùng `promoCodes`."},"promoCodes":{"type":"array","maxItems":10,"description":"Mã khuyến mãi THEO HÃNG (vd. cấu hình ở CMS DLV). Server chỉ gửi mã vào request của đúng hãng đó: HPL `promo_code` ở lượt airline = hãng; HNH `promoCode` ở system = hãng. BGT chưa nhận. Mỗi hãng một mã; mã riêng thắng `promoCode`. Kết quả cache riêng theo mã của đúng hãng đó. Giá khuyến mãi đi theo phiên search ⇒ không cần gửi lại mã ở /book.","items":{"type":"object","required":["airline","code"],"properties":{"airline":{"type":"string","example":"VJ","description":"Mã hãng 2 ký tự"},"code":{"type":"string","example":"VIETJET1010","description":"2–32 ký tự A-Z a-z 0-9 _ -"}}},"example":[{"airline":"VJ","code":"VIETJET1010"}]},"requiredCapabilities":{"type":"array","items":{"type":"string"},"description":"Skip NCC không có capability này. VD `[\"book\",\"issue\"]`"}}},"MinFareRequest":{"type":"object","required":["startPoint","endPoint"],"description":"Send `month` OR `fromDate`+`toDate` (not both). One-way only in v1.","properties":{"startPoint":{"$ref":"#/components/schemas/IataCode"},"endPoint":{"$ref":"#/components/schemas/IataCode"},"month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$","example":"2026-06","description":"Whole month, YYYY-MM. Required unless fromDate+toDate are sent."},"fromDate":{"type":"string","format":"date","example":"2026-06-15","description":"Range start (YYYY-MM-DD). Use with toDate instead of month."},"toDate":{"type":"string","format":"date","example":"2026-07-15","description":"Range end (YYYY-MM-DD), inclusive; on/after fromDate, range at most 31 days."},"adt":{"type":"integer","minimum":1,"default":1,"description":"Adult count"},"chd":{"type":"integer","minimum":0,"default":0,"description":"Child count"},"inf":{"type":"integer","minimum":0,"default":0,"description":"Infant count"},"airline":{"type":"string","example":"VN","description":"DEPRECATED-on-arrival alias of airlines[0]. Kept for DLV PHP compatibility. Prefer airlines:[...] for new integrations. If both are sent, airlines wins."},"airlines":{"type":"array","items":{"type":"string"},"example":["VN"],"description":"Carrier filter. If omitted, returns cheapest across all carriers."}}},"FareRefRequest":{"type":"object","description":"Dùng `fareSelectionId` (trước book) hoặc `bookingRef` (sau hold).","properties":{"fareSelectionId":{"type":"string"},"bookingRef":{"type":"string"}}},"PriceQuoteRequest":{"type":"object","required":["fareSelectionId"],"properties":{"fareSelectionId":{"type":"string"},"passengerCounts":{"type":"object","properties":{"adt":{"type":"integer"},"chd":{"type":"integer"},"inf":{"type":"integer"}}}}},"FareRuleRequest":{"type":"object","required":["fareSelectionId"],"properties":{"fareSelectionId":{"type":"string"},"bookingRef":{"type":"string"},"isMiniRule":{"type":"boolean"}}},"RetrieveByPnrRequest":{"type":"object","required":["supplier","pnr"],"description":"Mở PNR theo định danh NCC (cho booking tạo ngoài hệ thống).","properties":{"supplier":{"type":"string","description":"Internal (tripota/airdata/skeeper) hoặc mã NCC (HNH/BGT/HPL)"},"pnr":{"type":"string","example":"FJA99U"},"airline":{"type":"string","example":"VN","description":"Bắt buộc với một số NCC"},"lastName":{"type":"string","description":"Họ pax — bắt buộc với một số NCC"},"source":{"type":"string","description":"Mã hệ thống GDS; default = airline nếu bỏ trống"}}},"ChangeScope":{"type":"object","description":"Phạm vi áp dụng cho refund/exchange/upgrade: cả booking, theo vé, hoặc theo pax+segment.","properties":{"type":{"type":"string","enum":["booking","ticket","passenger_segment"],"default":"ticket"},"ticketNumbers":{"type":"array","items":{"type":"string"}},"passengers":{"type":"array","items":{"type":"string"}},"segments":{"type":"array","items":{"type":"string"}}}},"NewItineraryRequest":{"type":"object","description":"Hành trình mới mong muốn cho reshop/quote đổi vé. Hoặc truyền `newFlights[]` là opaque token NCC.","properties":{"origin":{"$ref":"#/components/schemas/IataCode"},"destination":{"$ref":"#/components/schemas/IataCode"},"departureDate":{"$ref":"#/components/schemas/IsoDate"},"returnDate":{"$ref":"#/components/schemas/IsoDate"},"flightNumber":{"type":"string"},"cabinClass":{"type":"string"},"newFlights":{"type":"array","items":{}}}},"SelectedPassengers":{"type":"array","minItems":1,"description":"Pax cần tách. Mỗi item cần ≥1 trong `passengerId`/`paxRef`/`paxId`/`id`.","items":{"type":"object","properties":{"passengerId":{"type":"string"},"paxRef":{"type":"string"},"paxId":{"type":"string"},"id":{"type":"string"},"type":{"type":"string"}}}},"Passenger":{"type":"object","required":["type","firstName","lastName"],"properties":{"paxId":{"type":"string","description":"Canonical ID server trả sau book; pass lại cho update/split/infant"},"passengerId":{"type":"string","description":"Alias of `paxId` — cả hai đều được chấp nhận"},"type":{"$ref":"#/components/schemas/PaxType"},"title":{"type":"string","example":"MR","enum":["MR","MRS","MS","MSTR","MISS"]},"firstName":{"type":"string","example":"NGUYEN","description":"Chỉ chữ + space, không số/dấu gạch ngang (HPL/VNA reject)"},"lastName":{"type":"string","example":"VAN A"},"dateOfBirth":{"type":"string","format":"date","example":"1990-01-01","description":"YYYY-MM-DD. **BẮT BUỘC cho chuyến quốc tế hãng APIS** — server ghép DOB vào DOCS gửi GDS; thiếu sẽ bị từ chối xuất vé \"require passport\"."},"gender":{"type":"string","example":"M","enum":["M","F"]},"nationality":{"type":"string","example":"VN","description":"Quốc tịch alpha-2 (VN). **Bắt buộc cho chuyến quốc tế** — vào DOCS APIS (server đổi alpha-3 cho GDS)."},"parentPaxId":{"type":"string","description":"Với INF: paxId của người lớn đi kèm"},"phone":{"type":"string"},"email":{"type":"string","format":"email"},"wheelchair":{"type":"boolean","default":false,"description":"Bắt buộc = false nếu truyền qua HPL (zod default)"},"vegetarian":{"type":"boolean","default":false},"membership":{"description":"String (VD \"VN1234567\") hoặc object `{ airline, number }`","oneOf":[{"type":"string","example":"VN1234567"},{"type":"object","required":["airline","number"],"properties":{"airline":{"type":"string","example":"VN"},"number":{"type":"string","example":"VN1234567"}}}]},"memberFly":{"type":"object","required":["airline","number"],"properties":{"airline":{"type":"string"},"number":{"type":"string"}},"description":"Legacy name for `membership` (object form)"},"document":{"type":"object","nullable":true,"properties":{"type":{"type":"string","example":"P","enum":["P","PP","PASSPORT","ID","NI"],"description":"P/PP=hộ chiếu, ID/NI=CCCD. Mặc định coi là hộ chiếu nếu bỏ trống."},"number":{"type":"string","example":"B12345678"},"issueCountry":{"type":"string","example":"VN","description":"Nước cấp (alpha-2). Server tự đổi sang alpha-3 cho GDS."},"issueDate":{"type":"string","format":"date"},"expireDate":{"type":"string","format":"date","description":"Ngày hết hạn giấy tờ — BẮT BUỘC cho hãng quốc tế APIS **và cho mọi chuyến VN/BL/0V (nội địa + quốc tế)** từ 2026-07-30. Alias được chấp nhận: `expiryDate`, `expiry`, `expirationDate`. Với CCCD gắn chip là mục \"Có giá trị đến\". Gửi `number` mà thiếu field này → 409 `INVALID_DOCUMENT` (server KHÔNG còn âm thầm bỏ giấy tờ)."},"nationality":{"type":"string","example":"VN","description":"Quốc tịch (alpha-2). Server đổi alpha-3 cho GDS DOCS."}},"description":"**[2026-07-30] BẮT BUỘC cho MỌI chuyến Vietnam Airlines (VN) + Pacific (BL) + VASCO (0V), cả nội địa lẫn quốc tế**: VN đổi chính sách, phải có giấy tờ mới HOLD được PNR. Mỗi **ADULT** phải có `document.number` + `document.expireDate`; thiếu → **409 `INVALID_DOCUMENT`** ngay trước khi gọi NCC (`error.details.violations[] = [{index, type, reason: \"missing_document\"|\"missing_expiry\"}]`). CHILD/INFANT **không** bắt buộc (dưới 14 tuổi không có CCCD) — nhưng nếu đã gửi `number` thì phải kèm `expireDate`. Trước đây server âm thầm XOÁ giấy tờ VN thiếu `expireDate`; nay báo lỗi rõ.\n\nHộ chiếu/giấy tờ. **BẮT BUỘC cho chuyến quốc tế hãng APIS** (QR, CZ, AA, SQ, EK, CX, LX, WY, TG, MH, …): phải gửi đủ `type` + `number` + `nationality` + `issueCountry` + `expireDate`, VÀ pax phải có `dateOfBirth` (server ghép DOB vào DOCS gửi GDS). Thiếu bất kỳ field nào (đặc biệt **dateOfBirth**) → hãng từ chối XUẤT VÉ với \"require all passengers to enter a passport\" dù book thành công. Có thể add sau qua `POST /bookings/:ref/documents`."}}},"Contact":{"type":"object","required":["email","phone","name"],"properties":{"email":{"type":"string","format":"email","example":"agent@example.com"},"phone":{"type":"string","example":"+84918293909","description":"E.164 — mã nước + 9 số. Server chuẩn hoá mọi dạng gửi lên (`+84918293909` / `84918293909` / `0918293909` / `918293909`, có khoảng trắng/gạch/chấm đều được) về `+84918293909` rồi mới đổi sang định dạng của từng NCC: lệnh AP `+84918293909`, lệnh SR CTCM `84918293909`. Số VN phải là +84 + 9 số đầu 3-9 — sai thì 400 VALIDATION tại `contact.phone`, KHÔNG gọi NCC. Số nước ngoài bắt buộc có dấu `+` (`+12025551234`) và được giữ nguyên."},"name":{"type":"string","example":"NGUYEN VAN A"},"address":{"type":"string"},"city":{"type":"string"},"country":{"type":"string"},"gender":{"type":"string","enum":["M","F"]},"language":{"type":"string","enum":["vi","en"],"default":"vi"}}},"BookRequest":{"type":"object","required":["fareSelectionId","passengers","contact"],"properties":{"fareSelectionId":{"type":"string","description":"Từ `data.fares[].fareSelectionId` của search response. TTL 60 phút."},"fareSelectionIds":{"type":"array","items":{"type":"string"},"minItems":2,"description":"Multi-fare: book 2 hãng khác nhau cho khứ hồi. Truyền [outboundId, inboundId] — server book tuần tự, trả `data.bookings[]` thay vì `data.bookingRef`. `fareSelectionId` phải = phần tử đầu tiên."},"mode":{"type":"string","enum":["draft","confirm"],"default":"confirm","description":"`draft` = hold (PayLater); `confirm` = book+issue (PayNow). LCC không hỗ trợ hold."},"passengers":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/Passenger"}},"contact":{"$ref":"#/components/schemas/Contact"},"promoCode":{"type":"string"},"tourCode":{"type":"string"},"accountCode":{"type":"string"},"remark":{"type":"string","description":"Internal note (HPL dùng khi gửi tới upstream)"},"ipRequest":{"type":"string","description":"IP của end-user (HPL audit); default \"127.0.0.1\" nếu omit"},"seats":{"type":"array","description":"Ghế mua kèm lúc book. Mỗi item = `{ passengerIndex, seatValue, segmentIndex?, seatCode? }`. `seatValue` = TOKEN mã hoá từ `data.addable[].seatValue` của `POST /flights/seat-map` (KHÔNG phải nhãn \"16A\").","items":{"type":"object","required":["passengerIndex","seatValue"],"properties":{"passengerIndex":{"type":"integer"},"seatValue":{"type":"string","description":"Token từ seat-map addable[].seatValue"},"segmentIndex":{"type":"integer"},"seatCode":{"type":"string","description":"Nhãn hiển thị (audit) — không phải token"},"price":{"type":"number"},"currency":{"type":"string"},"fareSelectionId":{"type":"string","description":"Khứ hồi 1 PNR (HPL): vé (chiều) mà item thuộc về — id của vé có danh sách pre-book chứa item"}}}},"selectedSeats":{"type":"array","description":"Alias UI của `seats[]` (server canonicalize về `seats`). Gửi MỘT trong hai; cả hai khác nội dung → 400 BOOK_SEATS_ALIAS_CONFLICT.","items":{"type":"object","required":["passengerIndex","seatValue"],"properties":{"passengerIndex":{"type":"integer"},"seatValue":{"type":"string"},"segmentIndex":{"type":"integer"},"seatCode":{"type":"string"},"fareSelectionId":{"type":"string","description":"Khứ hồi 1 PNR (HPL): vé (chiều) mà item thuộc về — id của vé có danh sách pre-book chứa item"}}}},"baggages":{"type":"array","description":"Hành lý mua kèm lúc book. Mỗi item = `{ passengerIndex, baggageValue, quantity? }`. `baggageValue` = TOKEN từ `data.addable[].baggageValue` của `POST /flights/baggages` (KHÔNG phải nhãn \"20kg\"). 1 token = 1 đơn vị; quantity>1 bị từ chối — dùng post-book add cho nhiều.","items":{"type":"object","required":["baggageValue"],"properties":{"passengerIndex":{"type":"integer"},"paxRef":{"type":"string","description":"Alias passengerIndex (vd \"ADT_1\")"},"baggageValue":{"type":"string"},"value":{"type":"string","description":"Alias baggageValue"},"segmentIndex":{"type":"integer"},"quantity":{"type":"integer","default":1},"code":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"route":{"type":"string","description":"Chặng của option (vd \"HANSGN\") — khứ hồi 1 PNR dùng để xếp chiều khi thiếu fareSelectionId"},"fareSelectionId":{"type":"string","description":"Khứ hồi 1 PNR (HPL): vé (chiều) mà item thuộc về — id của vé có danh sách pre-book chứa item"}}}},"ancillaries":{"type":"array","description":"Dịch vụ mua kèm lúc book. Mỗi item = `{ passengerIndex, ancillaryValue, quantity? }`. `ancillaryValue` = TOKEN từ `POST /flights/ancillaries`. (Post-book endpoint tương ứng dùng field `services[]` — nhưng tại /book field canonical là `ancillaries[]`.)","items":{"type":"object","required":["passengerIndex","ancillaryValue"],"properties":{"passengerIndex":{"type":"integer"},"ancillaryValue":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"quantity":{"type":"integer","default":1},"price":{"type":"number"},"currency":{"type":"string"},"route":{"type":"string"},"fareSelectionId":{"type":"string","description":"Khứ hồi 1 PNR (HPL): vé (chiều) mà item thuộc về — id của vé có danh sách pre-book chứa item"}}}}}},"IssueRequest":{"type":"object","description":"Tuỳ supplier mà trường nào được dùng. Aggregator strip field không khớp schema — nên ok nếu client pass cả nhóm.","properties":{"comAmount":{"type":"number","description":"Tripota: hoa hồng đại lý"},"paymentPassword":{"type":"string","description":"Airdata: payment password (default lấy từ env AIRDATA_PAYMENT_PASSWORD)"},"totalAmount":{"type":"number","description":"Skeeper: tổng tiền đã verify. Nếu bỏ trống adapter tự retrieve từ PNR."},"tourCode":{"type":"string","description":"Skeeper/Tripota: tour code"},"sendEmail":{"type":"boolean","default":false,"description":"Skeeper: auto gửi email e-ticket sau issue"}}},"SendEmailRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"},"language":{"type":"string","enum":["vi","en"],"default":"vi"},"paymentDisplayType":{"type":"string","enum":["S","D","F"],"default":"D"}}},"UpdateContactRequest":{"type":"object","description":"Ít nhất 1 field required","properties":{"fullName":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string","example":"+84918293909","description":"Chuẩn hoá E.164 giống `contact.phone` của /bookings."}}},"FlightStatusRequest":{"type":"object","description":"Ít nhất 1 trong `bookingRef` / `flightValue` / `flightValues[]`","properties":{"bookingRef":{"type":"string"},"system":{"type":"string"},"flightValue":{"type":"string"},"flightValues":{"type":"array","items":{"type":"string"}}}},"AddBaggageRequest":{"type":"object","required":["baggages"],"properties":{"baggages":{"type":"array","minItems":1,"items":{"type":"object","required":["baggageValue"],"properties":{"passengerIndex":{"type":"integer"},"passengerId":{"type":"string"},"baggageValue":{"type":"string","description":"Từ /baggages list response"},"quantity":{"type":"integer","default":1}}}}}},"AddSeatRequest":{"type":"object","required":["seats"],"properties":{"seats":{"type":"array","minItems":1,"items":{"type":"object","required":["seatValue"],"properties":{"passengerIndex":{"type":"integer"},"seatValue":{"type":"string","example":"12A"},"segmentId":{"type":"string"}}}}}},"AddAncillaryRequest":{"type":"object","required":["services"],"properties":{"airline":{"type":"string"},"services":{"type":"array","minItems":1,"items":{"type":"object","required":["ancillaryValue"],"properties":{"passengerIndex":{"type":"integer"},"ancillaryValue":{"type":"string"},"quantity":{"type":"integer","default":1},"type":{"type":"string"}}}}}},"FlightLeg":{"type":"object","properties":{"airline":{"type":"string","example":"VN"},"operatingCarrier":{"type":"string","nullable":true,"example":"BL","description":"Nếu khác marketing carrier (codeshare)"},"flightNumber":{"type":"string","example":"VN6002"},"startPoint":{"$ref":"#/components/schemas/IataCode"},"endPoint":{"$ref":"#/components/schemas/IataCode"},"departTime":{"type":"string","example":"05:00","description":"HH:mm giờ VN"},"arriveTime":{"type":"string","example":"07:10"},"duration":{"type":"integer","description":"Phút"},"aircraft":{"type":"string","example":"321"},"cabin":{"type":"string","example":"ECONOMY FLEX"},"fareBasis":{"type":"string","example":"BVNF"},"bookingClass":{"type":"string","example":"B"},"seatsAvailable":{"type":"integer","nullable":true},"baggage":{"type":"string","example":"1 PCs x 23kg"},"carryOn":{"type":"string","example":"1piece x 8kg","description":"Xách tay của riêng chặng này (HPL); `fareConditions.baggage.carryOn` chỉ là của chặng đầu"}}},"Fare":{"type":"object","properties":{"fareSelectionId":{"type":"string","example":"fs_AqeDpYVEriJd36u5qM_19"},"promo":{"type":"object","nullable":true,"description":"Có khi request gửi mã cho hãng này (`promoCodes`/`promoCode`) VÀ NCC đánh dấu vé là giá khuyến mãi. Giá của vé (`fareAdt`/`fareChd`/`fareInf`, `totalPrice`) đã là giá SAU giảm.","properties":{"airline":{"type":"string","example":"VJ"},"code":{"type":"string","example":"VIETJET1010"},"discount":{"type":"object","description":"Mức giảm MỘT khách mỗi loại (chỉ để tham khảo; giá đã trừ sẵn).","properties":{"adt":{"type":"number","example":24000},"chd":{"type":"number"},"inf":{"type":"number"}}}}},"equivalentFares":{"type":"array","description":"CHỈ CÓ khi fare này đã hấp thụ các bản y hệt từ NCC khác (gộp cross-NCC). Cùng hãng/chiều/khoang/tiền và mọi chặng khớp số hiệu + fare basis. Dùng làm ĐƯỜNG DỰ PHÒNG: nếu /price-quote hoặc /book với token chính lỗi phía NCC, thử lần lượt các `fareSelectionId` ở đây trước khi báo hết vé. Khi có chính sách hiển thị: chỉ chứa NCC mà kênh của bạn đang bật, và fare chính luôn là một NCC đang bật.","items":{"$ref":"#/components/schemas/EquivalentFare"}},"supplier":{"type":"string","enum":["airdata","tripota","skeeper"]},"supplierSource":{"type":"string","example":"VN1A","description":"System code upstream. HPL gọi Sun PhuQuoc là `_9G` (CÓ gạch dưới) — `airline` vẫn là `9G`."},"airline":{"type":"string"},"currency":{"$ref":"#/components/schemas/Currency"},"totalPrice":{"type":"number","description":"UNIFIED: tính theo `(fareAdt+taxAdt)*adt + (fareChd+taxChd)*chd + (fareInf+taxInf)*inf`"},"totalPriceSupplier":{"type":"number","description":"Raw từ NCC, có thể khác convention (airdata=chỉ ADT, skeeper thiếu pax trong 1 số case)"},"fareAdt":{"type":"number","description":"Giá vé mỗi người lớn. Ở chế độ `on` (vé GDS có giảm) đã trừ `pricing.perPax.ADT.discount` — trừ vào giá vé trước, thừa mới trừ `taxAdt`; giá NCC ở `netFareAdt`."},"taxAdt":{"type":"number"},"fareChd":{"type":"number"},"taxChd":{"type":"number"},"fareInf":{"type":"number"},"taxInf":{"type":"number"},"legs":{"type":"array","items":{"$ref":"#/components/schemas/FlightLeg"}},"fareConditions":{"$ref":"#/components/schemas/FareConditions"},"mixedCabin":{"type":"boolean","description":"Chỉ có khi `true`: các chặng khác hạng ghế, `cabinCanonical` là của chặng đầu; xem `legs[].cabin`"},"cabinCanonical":{"$ref":"#/components/schemas/CabinCanonical"},"cabinDisplay":{"type":"string","nullable":true,"example":"Phổ thông","description":"Tên hiển thị tiếng Việt của cabinCanonical (Phổ thông / Phổ thông đặc biệt / Thương gia / Hạng nhất)"},"supportedOps":{"type":"array","items":{"type":"string"},"description":"Ops mà supplier này hỗ trợ cho fare này"},"unsupportedOps":{"type":"array","items":{"type":"string"}},"netTotalPrice":{"type":"number","description":"Giá NCC — CHỈ có ở chế độ `on` (khi đó `totalPrice` là giá bán). Vé GDS."},"netFareAdt":{"type":"number","description":"Chỉ ở `on` khi `fareAdt` đã bị trừ giảm: giá vé NCC mỗi người lớn. Tương tự `netTaxAdt`, `netPriceAdt`, `netFareChd`, `netTaxChd`, `netPriceChd`, `netFareInf`, `netTaxInf`, `netPriceInf`."},"sellingPrice":{"type":"number","description":"Giá bán — CHỈ có ở chế độ `shadow` (`totalPrice` vẫn là giá NCC). Vé GDS."},"discountTotal":{"type":"number","description":"Tổng tiền giảm cho mọi hành khách (`shadow` / `on`). 0 khi không có rule khớp."},"pricing":{"$ref":"#/components/schemas/FarePricing"}}},"FarePricing":{"type":"object","description":"Giá bán vé GDS. Chỉ có trên vé GDS khi chế độ của NCC là `shadow` hoặc `on`; vé không phải GDS không có object này.","properties":{"mode":{"type":"string","enum":["shadow","on"],"description":"Chế độ áp cho vé này: `on` → `totalPrice` là giá bán; `shadow` → `totalPrice` là giá NCC"},"status":{"type":"string","enum":["APPLIED","NO_RULE","NO_BASE_FARE","CURRENCY_MISMATCH","ERROR"],"description":"Chỉ `APPLIED` mới có giảm giá; trạng thái khác → giá bán = giá NCC"},"cabin":{"type":"string","nullable":true,"enum":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST",null]},"ruleId":{"type":"string","description":"Rule đã áp (khi `APPLIED`)","example":"gds-1g-vn-sgn-nrt"},"ruleVersion":{"type":"integer","example":3},"discountType":{"type":"string","enum":["PERCENT","FIXED_AMOUNT"]},"discountValue":{"type":"number","example":5},"discountBase":{"type":"string","enum":["BASE_FARE","TOTAL_FARE"]},"perPax":{"type":"object","description":"Theo loại khách (`ADT`/`CHD`/`INF`): `base` (giá tính giảm / khách), `discount` (giảm / khách), `count`","additionalProperties":{"type":"object","properties":{"base":{"type":"number"},"discount":{"type":"number"},"count":{"type":"integer"}}},"example":{"ADT":{"base":4000000,"discount":200000,"count":2}}},"lockedUntil":{"type":"string","format":"date-time","description":"Chỉ ở price-quote có giảm: khoản giảm này được giữ tới thời điểm này cho cùng số khách — book trước hạn giữ nguyên giá dù rule vừa đổi."},"locked":{"type":"boolean","description":"Chỉ ở price-quote: `true` khi đang dùng khoản giảm đã báo trước đó (rule hiện hành giảm ít hơn hoặc đã tắt)."}}},"SearchPricingStamp":{"type":"object","description":"Cấu hình giá bán đã dùng cho response. Chỉ có khi selling price đã từng được cấu hình hoặc có NCC khác `off`.","properties":{"version":{"type":"integer","example":42,"description":"Version cấu hình (rule + chế độ)"},"mode":{"type":"string","enum":["off","shadow","on"],"description":"Chế độ chung"},"modeByPartner":{"type":"object","example":{"HNH":"shadow","BGT":"on","HPL":"shadow"},"additionalProperties":{"type":"string","enum":["off","shadow","on"]}},"validUntil":{"type":"integer","nullable":true,"description":"Epoch ms — mốc rule kế tiếp bắt đầu / hết hạn"}}},"SellingPriceChangedData":{"type":"object","description":"`data` của lỗi `SELLING_PRICE_CHANGED`. Tổng trên mọi vé của lệnh book.","properties":{"oldSellingPrice":{"type":"number","nullable":true,"example":16600000},"newSellingPrice":{"type":"number","nullable":true,"example":17000000},"oldDiscountTotal":{"type":"number","example":400000},"newDiscountTotal":{"type":"number","example":0},"currency":{"$ref":"#/components/schemas/Currency"},"legs":{"type":"array","description":"Chỉ khi book nhiều vé (`fareSelectionIds`)","items":{"type":"object","properties":{"fareSelectionId":{"type":"string"},"changed":{"type":"boolean"},"oldSellingPrice":{"type":"number","nullable":true},"newSellingPrice":{"type":"number","nullable":true},"oldDiscountTotal":{"type":"number"},"newDiscountTotal":{"type":"number"}}}}}},"CabinCanonical":{"type":"string","nullable":true,"enum":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST",null],"description":"Hạng ghế chuẩn hoá. Server tự dịch từ HNH single-letter (Y/M/W/C/F), HPL text (STARTER/ECONOMY/BUSINESS), BGT text (ECONOMY/PREMIUM_ECONOMY/BUSINESS/FIRST), và branded fare names (SkyBoss/Deluxe/...). null = không xác định được."},"CabinOption":{"type":"object","description":"Một mức hạng cho một chuyến bay đã group. Gộp tất cả fare cùng hạng từ mọi NCC.","properties":{"cabinCanonical":{"$ref":"#/components/schemas/CabinCanonical"},"cabinDisplay":{"type":"string","nullable":true,"example":"Phổ thông"},"minPrice":{"type":"number","description":"Giá thấp nhất trong nhóm này (đã unified theo pax counts)"},"maxPrice":{"type":"number"},"suppliers":{"type":"array","items":{"type":"string"},"description":"Danh sách NCC đang bán hạng này cho chuyến này"},"fareCount":{"type":"integer","description":"Số fare trong nhóm — có thể >suppliers nếu cùng NCC bán nhiều fareBasis"},"fareSelectionIds":{"type":"array","items":{"type":"string"},"description":"IDs để FE pass thẳng vào /price-quote hoặc /book sau khi user chọn"}}},"GroupedFlight":{"type":"object","description":"Một chuyến bay vật lý sau khi gộp các fare từ mọi NCC × mọi hạng. FE dùng `groupedFlights` thay cho `fares` để hiển thị 1 row/chuyến (như Mytour/Traveloka).","properties":{"flightKey":{"type":"string","example":"VN|VN6002|2026-12-20|SGN|HAN","description":"Composite key dùng để dedupe — không hiển thị cho user"},"airline":{"type":"string","example":"VN"},"legs":{"type":"array","items":{"type":"object","properties":{"airline":{"type":"string"},"operatingCarrier":{"type":"string"},"flightNumber":{"type":"string"},"startPoint":{"type":"string"},"endPoint":{"type":"string"},"departTime":{"type":"string"},"arriveTime":{"type":"string"},"duration":{"type":"integer"},"aircraft":{"type":"string"}}}},"startPoint":{"type":"string"},"endPoint":{"type":"string"},"departTime":{"type":"string"},"arriveTime":{"type":"string"},"tripDirection":{"type":"string","enum":["oneway","roundtrip","outbound","inbound","unknown"]},"totalDurationMinutes":{"type":"integer","description":"Tổng thời gian bay + nối của một chiều (phút). Không có khi thiếu dữ liệu hoặc vé khứ hồi gộp"},"minPrice":{"type":"number"},"maxPrice":{"type":"number"},"currency":{"$ref":"#/components/schemas/Currency"},"supplierCount":{"type":"integer"},"suppliers":{"type":"array","items":{"type":"string"}},"fareCount":{"type":"integer"},"cabinOptions":{"type":"array","items":{"$ref":"#/components/schemas/CabinOption"}},"fares":{"type":"array","items":{"$ref":"#/components/schemas/Fare"},"description":"Fares trong group. Có thể duplicate với top-level `fares[]` — dùng nếu cần raw access."}}},"Combo":{"type":"object","description":"GDS-bundled round-trip fare promoted to a combo object. ONLY fares with tripDirection=roundtrip (pre-bundled by GDS) appear here — NO Cartesian pairing of separate outbound+inbound legs. Controlled by ROUNDTRIP_COMBO_ENABLED env flag (default true).","required":["fareSelectionId","airline","supplier","totalPrice","currency","legs","bundled"],"properties":{"fareSelectionId":{"type":"string","example":"fs_AqeDpYVEriJd36u5qM_19","description":"Same as source fare — pass to /book directly"},"airline":{"type":"string","example":"VN"},"supplier":{"type":"string","enum":["airdata","tripota","skeeper"]},"totalPrice":{"type":"number","description":"Unified total price (same convention as Fare.totalPrice)"},"currency":{"$ref":"#/components/schemas/Currency"},"legs":{"type":"array","items":{"$ref":"#/components/schemas/FlightLeg"},"description":"All legs for this round-trip (both outbound and inbound)"},"cabinCanonical":{"allOf":[{"$ref":"#/components/schemas/CabinCanonical"}],"nullable":true},"cabinDisplay":{"type":"string","nullable":true,"example":"Phổ thông"},"bundled":{"type":"boolean","enum":[true],"description":"Always true — marks this as a GDS-bundled round-trip combo"},"netTotalPrice":{"type":"number","description":"Như `Fare.netTotalPrice`"},"sellingPrice":{"type":"number","description":"Như `Fare.sellingPrice`"},"discountTotal":{"type":"number","description":"Như `Fare.discountTotal`"},"pricing":{"$ref":"#/components/schemas/FarePricing"}}},"BaggageInfo":{"type":"object","nullable":true,"description":"Hành lý ký gửi đã parse. null = supplier không trả data. included=false = không bao gồm.","properties":{"included":{"type":"boolean"},"pieces":{"type":"integer","nullable":true},"weight":{"type":"number","nullable":true,"description":"Kg — chỉ có ở checked baggage, không có ở carryOn"},"unit":{"type":"string","nullable":true,"enum":["KG","LB",null]},"text":{"type":"string","description":"Raw text gốc từ supplier"}}},"CarryOnInfo":{"type":"object","nullable":true,"description":"Hành lý xách tay. Chỉ lưu số kiện (pieces), không lưu kg — carry-on policy là số kiện, không phải trọng lượng.","properties":{"included":{"type":"boolean"},"pieces":{"type":"integer","nullable":true,"description":"1 hoặc 2 kiện. null nếu không xác định"},"text":{"type":"string","description":"Raw text gốc từ supplier"}}},"FareConditions":{"type":"object","nullable":true,"description":"Điều kiện hạng vé, normalized từ BGT fareOption / HNH segment / HPL segment. BGT là nguồn có fidelity cao nhất (weight+unit+pieces đầy đủ). Với AK/TR/5J có thêm field `penalties` (schema present từ BGT nhưng empty trong staging).","properties":{"cabinName":{"type":"string","example":"ECONOMY FLEX","description":"Tên hạng hiển thị. HPL thường đẹp nhất (\"ECONOMY LITE\", \"BUSINESS CLASSIC\"). BGT=cabin/groupClass, HNH=cabinCode."},"fareBasis":{"type":"string","example":"BVNF","description":"Lấy phần đầu nếu multi-leg pipe-delimited (\"K02H01 | Z01H00\" → \"K02H01\")"},"bookingClass":{"type":"string","example":"B"},"groupClass":{"type":"string","example":"EF","description":"Brand code (Eco/Deluxe/SkyBoss/EL/EC…). Stripped của pipe-notation"},"refundable":{"type":"boolean","nullable":true,"description":"true=hoàn được; false=không hoàn; null=supplier không trả"},"baggage":{"type":"object","properties":{"checked":{"$ref":"#/components/schemas/BaggageInfo"},"carryOn":{"$ref":"#/components/schemas/CarryOnInfo"}}},"penalties":{"type":"object","nullable":true,"description":"null = supplier không có penalty schema (VN/VJ/QH/VU). Object với values null = schema hiện diện nhưng chưa có data (AK/TR/5J trong staging). Object với values array = có data phí cụ thể.","properties":{"refund":{"nullable":true,"description":"Phí hoàn vé. null = schema có nhưng chưa populate"},"change":{"nullable":true,"description":"Phí đổi chuyến"},"cancel":{"nullable":true,"description":"Phí hủy vé"},"noShow":{"nullable":true,"description":"Phí no-show"}}}}},"FareRuleCatalogItem":{"type":"object","description":"Per group-class policy từ BGT /all-fare-rules (chỉ 6 LCC: VJ/AK/TR/JQ/6E/5J)","properties":{"supplier":{"type":"string","example":"airdata"},"source":{"type":"string","example":"VJ"},"configs":{"type":"array","items":{"type":"object","properties":{"groupClass":{"type":"string","example":"Eco"},"cabinName":{"type":"string","example":"Eco"},"seat":{"type":"string","enum":["FREE","FEE","NONE"]},"meal":{"type":"string","enum":["FREE","FEE","NONE"]},"checkinPriority":{"type":"string","enum":["FREE","FEE","NONE"]},"loungeService":{"type":"string","enum":["FREE","FEE","NONE"]},"changeName":{"type":"string","enum":["FREE","FEE","NONE"]},"changeFlights":{"type":"string","enum":["FREE","FEE","NONE"]},"refund":{"type":"string","enum":["FREE","FEE","NONE"]},"cancel":{"type":"string","enum":["FREE","FEE","NONE"]}}}}}},"SupplierResult":{"type":"object","properties":{"supplier":{"type":"string"},"name":{"type":"string"},"count":{"type":"integer","description":"Số fares sau filter"},"error":{"type":"object","nullable":true,"description":"Chi tiết lỗi nếu NCC fail"},"traceId":{"type":"string"},"latencyMs":{"type":"integer"},"fromCache":{"type":"string","nullable":true,"enum":["fresh","stale","carrier-fresh","carrier-stale","carrier-partial","aggregate",null],"description":"`carrier-partial` = lát cache theo hãng + gọi bù đúng hãng còn thiếu; `aggregate` = lấy lại nguyên kết quả của NCC này từ entry cache tổng khi dựng lại entry thiếu (chỉ NCC khác bị gọi lại)."},"partialFailure":{"type":"boolean","description":"true khi một kênh con của NCC lỗi/quá giờ ở lượt gọi thật này ⇒ kết quả của NCC thiếu một phần."},"partialErrors":{"type":"array","items":{"type":"string"},"description":"Thông báo lỗi của các kênh con."},"failedSources":{"type":"array","items":{"type":"string"},"example":["VN"],"description":"Kênh con lỗi/quá giờ: hãng (skeeper), hệ thống (tripota), nguồn (airdata). Chỉ có khi `partialFailure`."},"status":{"type":"string","enum":["pending"],"description":"`pending` = NCC chưa trả xong khi response được gửi (hết soft deadline)."},"fares":{"type":"array","items":{"$ref":"#/components/schemas/Fare"},"description":"Per-NCC fare list (duplicate of top-level sorted merged list)"},"hidden":{"type":"boolean","description":"CHỈ CÓ khi NCC này đang bị ẩn với người gọi: `count` = 0, `fares` rỗng. NCC vẫn được gọi và cache vẫn đủ."},"hiddenReason":{"type":"string","enum":["ops","policy"],"description":"`ops` = công tắc khẩn cấp của vận hành server (mọi kênh); `policy` = chính sách hiển thị của kênh đang gọi."}}},"EquivalentFare":{"type":"object","description":"Một bản Y HỆT của fare này từ NCC khác, đã bị gộp khỏi `fares[]`.","properties":{"supplier":{"type":"string","enum":["airdata","tripota","skeeper"]},"supplierSource":{"type":"string","example":"_9G","nullable":true},"totalPrice":{"type":"number","nullable":true},"fareSelectionId":{"type":"string","example":"fs_pnV2WxSCIRVGUzLLRH67g","description":"Token đặt vé THẬT, còn hiệu lực — dùng cho /price-quote, /book y như token của fare chính."}}},"SearchTotals":{"type":"object","properties":{"totalFares":{"type":"integer","description":"Tổng số fare flat. Vẫn gồm duplicate cùng chuyến từ các NCC khác nhau, TRỪ các hãng bật gộp cross-NCC (xem `crossNccCollapsed`)."},"crossNccCollapsed":{"type":"integer","description":"Số fare TRÙNG SẢN PHẨM giữa các NCC đã bị gộp khỏi `fares[]` trong lần search này (0 = không có gì trùng). Bản bị gộp nằm ở `fares[].equivalentFares[]`."},"totalFlights":{"type":"integer","description":"Số chuyến bay vật lý sau khi gộp — thường nhỏ hơn `totalFares` 3-4 lần"},"totalSuppliers":{"type":"integer"},"skippedSuppliers":{"type":"array","items":{"type":"string"}},"degraded":{"type":"boolean","description":"true khi flights=[] và có NCC lỗi"},"cached":{"oneOf":[{"type":"boolean"},{"type":"string","enum":["fresh","stale","miss","coalesced"]}],"description":"Cache state. Entry cache tổng còn thiếu NCC được hiện chỉ được phát `fresh`/`stale` trong `CACHE_INCOMPLETE_FRESH_S` giây đầu (mặc định 15); sau đó server dựng lại (gọi lại đúng NCC thiếu) ⇒ `miss` + `rebuilt`."},"suppliersPartial":{"type":"array","items":{"type":"string"},"description":"NCC có kênh con lỗi/quá giờ (`suppliers[x].partialFailure`). Từ 2026-10-08 gồm cả kênh VN nội địa của skeeper quá trần."},"pendingSuppliers":{"type":"array","items":{"type":"string"},"description":"NCC chưa trả xong khi response được gửi."},"complete":{"type":"boolean","description":"true khi MỌI NCC được hiện cho người gọi (bỏ NCC `hidden`) đã trả lời đủ: không pending, không lỗi/timeout, không `partialFailure`. Tính theo người gọi, có ở mọi đường trả (JSON, `collect=1`, event `envelope` của stream, kể cả khi trúng cache)."},"emptyConfirmed":{"type":"boolean","description":"`complete` và không có vé nào được hiện ⇒ tuyến/ngày thật sự không có chuyến. 0 vé mà `emptyConfirmed: false` ⇒ có NCC chưa trả đủ, nên tìm lại."},"incompleteSuppliers":{"type":"array","items":{"type":"string"},"description":"NCC được hiện còn thiếu (rỗng khi `complete`)."},"rebuilt":{"type":"object","description":"Có khi response là bản dựng lại một entry cache tổng còn thiếu.","properties":{"rerun":{"type":"array","items":{"type":"string"},"description":"NCC được gọi lại"},"reused":{"type":"array","items":{"type":"string"},"description":"NCC lấy lại từ entry, không gọi NCC"}}},"combosBuilt":{"type":"integer","description":"Number of GDS-bundled round-trip combos in data.combos[]. 0 for OW searches or when feature disabled."},"promoCodes":{"type":"array","items":{"type":"object","properties":{"airline":{"type":"string"},"code":{"type":"string"}}},"description":"Các mã theo hãng đã gửi xuống NCC ở lượt này (chỉ có khi request có `promoCodes`)."},"hiddenSuppliers":{"type":"array","items":{"type":"string"},"description":"CHỈ CÓ khi công tắc khẩn cấp của vận hành đang ẩn NCC (mọi kênh)."},"display":{"$ref":"#/components/schemas/SearchDisplayTotals"}}},"SearchDisplayTotals":{"type":"object","description":"CHỈ CÓ khi chính sách hiển thị của kênh đang gọi có hiệu lực (ẩn gì đó hoặc `mode: priority`).","properties":{"version":{"type":"integer","description":"Version cấu hình đã áp."},"channel":{"type":"string","example":"AG","description":"Profile đã áp (`DEFAULT` hoặc tên kênh)."},"market":{"type":"string","enum":["domestic","international"]},"mode":{"type":"string","enum":["all","priority"]},"hiddenAirlines":{"type":"array","items":{"type":"string"},"example":["VJ"],"description":"Hãng thực sự bị loại khỏi kết quả này."},"hiddenFares":{"type":"integer","description":"Số vé bị chính sách loại."},"hiddenBySupplierAirline":{"type":"integer","description":"Phần của hiddenFares bị ẩn CHỈ vì NCC không được chọn cho một hãng của vé ở thị trường này (NCC vẫn bật toàn cục)."},"promoted":{"type":"integer","description":"Số thẻ gộp đã đổi sang NCC khác (NCC cũ bị tắt, hoặc ưu tiên)."}}},"SearchData":{"type":"object","properties":{"fares":{"type":"array","items":{"$ref":"#/components/schemas/Fare"},"description":"Flat list — sort theo totalPrice ASC. Backward-compatible."},"combos":{"type":"array","items":{"$ref":"#/components/schemas/Combo"},"description":"GDS-bundled round-trip combos sorted cheapest-first. Present only for RT searches when ROUNDTRIP_COMBO_ENABLED=true. Cap=200 by default (ROUNDTRIP_COMBO_CAP env). Anti-Cartesian: only GDS-pre-bundled fares (tripDirection=roundtrip) appear here."},"groupedFlights":{"type":"array","items":{"$ref":"#/components/schemas/GroupedFlight"},"description":"Đã gộp theo chuyến bay vật lý + tách theo hạng. FE nên dùng view này để hiển thị 1 row/chuyến."},"suppliers":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/SupplierResult"}},"totals":{"$ref":"#/components/schemas/SearchTotals"},"pricing":{"$ref":"#/components/schemas/SearchPricingStamp"}}},"SearchEnvelope":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"$ref":"#/components/schemas/SearchData","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"nullable":true,"oneOf":[{"$ref":"#/components/schemas/ErrorObj"},{"type":"null"}],"description":"null khi `ok=true`. Object khi `ok=false`."},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}},"BookingRecord":{"type":"object","description":"Booking state returned by `/bookings` (has `bookingRef`) và `/bookings/:ref` (no `bookingRef`, dùng path param).","properties":{"supplier":{"type":"string","enum":["airdata","tripota","skeeper"]},"supplierPnr":{"type":"string","example":"FJA99U","description":"PNR từ NCC/airline backend"},"gdsCode":{"type":"string","nullable":true,"description":"GDS confirmation code (1G) nếu có"},"airline":{"type":"string","example":"VN"},"source":{"type":"string","example":"VN","description":"System code NCC dùng (VN1A / VN / 1G / JQ...)"},"state":{"type":"string","enum":["draft","booked","issued","cancelled","voided","refunded"],"description":"Aggregator-normalized state"},"bookingStatus":{"type":"string","example":"ACTIVE","description":"Upstream raw state (HOLD/ACTIVE/CANCEL/TICKETED)"},"bookingDate":{"type":"string","format":"date-time","nullable":true,"description":"Khi booking được create upstream"},"issueDate":{"type":"string","format":"date-time","nullable":true,"description":"Khi issue ticket"},"expiryDate":{"type":"string","format":"date-time","nullable":true,"description":"Hạn phải issue ticket hoặc PNR sẽ cancel tự động"},"timeHold":{"type":"string","nullable":true,"description":"Alias cũ của expiryDate (một số supplier dùng)"},"totalAmount":{"type":"number"},"totalPrice":{"type":"number","description":"Giá NCC của PNR — ở MỌI chế độ giá bán (kể cả `on`)"},"sellingPrice":{"type":"number","nullable":true,"description":"Giá bán (= giá NCC của PNR − `discountTotal`). Chỉ có khi booking có giảm giá bán vé GDS"},"discountTotal":{"type":"number","description":"Tiền giảm giá bán. Chỉ có khi > 0"},"pricingLocked":{"type":"boolean","description":"Có khi khoản giảm lấy từ giá đã báo đang được giữ (price-quote), không phải rule hiện hành"},"price_breakdown":{"type":"object","description":"`flight_total` = giá NCC; `discount_total` = tiền giảm; `grand_total` = `payable_total` = flight_total + ancillary_total + dlv_service_fee − discount_total. **Số tiền thu khách = `payable_total`.**","properties":{"currency":{"type":"string"},"flight_total":{"type":"number"},"ancillary_total":{"type":"number"},"discount_total":{"type":"number"},"dlv_service_fee":{"type":"number"},"supplier_total":{"type":"number"},"grand_total":{"type":"number"},"payable_total":{"type":"number"}}},"currency":{"$ref":"#/components/schemas/Currency"},"passengers":{"type":"array","items":{"type":"object","properties":{"paxId":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"type":{"type":"string"},"dateOfBirth":{"type":"string"}}}},"itineraries":{"type":"array","items":{"type":"object","properties":{"airline":{"type":"string"},"flightNumber":{"type":"string"},"startPoint":{"type":"string"},"endPoint":{"type":"string"},"departTime":{"type":"string","description":"ISO datetime hoặc HH:mm tuỳ supplier"},"arriveTime":{"type":"string"},"journeyIndex":{"type":"integer","nullable":true,"example":0,"description":"Chiều bay: 0 = chiều đi, 1 = chiều về (2… cho nhiều chặng). Khứ hồi 1 PNR có cả hai chiều trong cùng mảng. `null` khi chỉ có dữ liệu lưu lúc book."},"segmentIndex":{"type":"integer","example":0,"description":"Thứ tự chặng trong chiều bay (nối chuyến: 0, 1…)"},"bookingClass":{"type":"string"},"status":{"type":"string","example":"HK"}}}},"tickets":{"type":"array","items":{"type":"string"},"example":["7382315673190"]},"bookingRef":{"type":"string","example":"bk_xxx","description":"Server-generated, 90d TTL booked / 365d issued. CHỈ trả về ở response của `POST /bookings` (response của `GET /bookings/:ref` không lặp lại vì path đã có)."},"bookingImage":{"type":"string","nullable":true,"description":"Base64 PDF/e-ticket nếu supplier trả"},"raw":{"type":"object","nullable":true,"description":"Raw upstream response — dùng debug khi cần field không được normalize."}}},"BookEnvelope":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"$ref":"#/components/schemas/BookingRecord","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"nullable":true,"oneOf":[{"$ref":"#/components/schemas/ErrorObj"},{"type":"null"}],"description":"null khi `ok=true`. Object khi `ok=false`."},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}},"SellingPriceSettingsView":{"type":"object","properties":{"mode":{"type":"string","enum":["off","shadow","on"],"description":"Chế độ chung"},"partners":{"type":"object","description":"Ghi đè theo NCC. NCC không có ở đây dùng chế độ chung","additionalProperties":{"type":"string","enum":["off","shadow","on"]},"example":{"BGT":"on"}},"effective":{"type":"object","description":"Chế độ thực tế đang áp cho từng NCC","additionalProperties":{"type":"string","enum":["off","shadow","on"]},"example":{"HNH":"shadow","BGT":"on","HPL":"shadow"}},"forcedOff":{"type":"boolean","description":"`true` khi env `SELLING_PRICE_FORCE_OFF` đang ép tắt"},"source":{"type":"string","enum":["runtime","env"]},"version":{"type":"integer","example":43,"description":"Version cấu hình, tăng mỗi lần sửa rule ACTIVE hoặc chế độ"},"updatedAt":{"type":"string","format":"date-time","nullable":true},"updatedBy":{"type":"string","nullable":true,"example":"dlv-admin","description":"Tên key admin"},"reason":{"type":"string","nullable":true},"priceLockMinutes":{"type":"integer","example":60,"description":"Giữ giá đã báo ở price-quote trong bao nhiêu phút (15–240). Cấu hình được, không cố định trong code."},"defaultPaxTypes":{"type":"array","items":{"type":"string","enum":["ADT","CHD","INF"]},"example":["ADT","CHD"],"description":"Loại khách được giảm cho rule không ghi `pax_types`."},"rounding":{"type":"string","enum":["FLOOR_1","FLOOR_100","ROUND_100","FLOOR_1000","ROUND_1000"],"example":"FLOOR_1","description":"Làm tròn mức giảm mỗi khách. `ROUND_*` có thể làm tròn lên nhưng luôn bị kẹp theo `max_discount` và theo giá vé."},"channels":{"type":"object","description":"Kênh bán: tên kênh → danh sách tên key API ở gateway.","additionalProperties":{"type":"array","items":{"type":"string"}},"example":{"WEB":["dlv_web"],"B2B":["acme"]}},"channelModes":{"type":"object","description":"Ghi đè chế độ theo kênh (thắng ghi đè theo NCC, trừ khi NCC bị tắt).","additionalProperties":{"type":"string","enum":["off","shadow","on"]},"example":{"WEB":"on"}},"effectiveByChannel":{"type":"object","description":"Chế độ thực tế của từng NCC trong từng kênh.","additionalProperties":{"type":"object","additionalProperties":{"type":"string","enum":["off","shadow","on"]}},"example":{"WEB":{"HNH":"on","BGT":"on","HPL":"off"}}},"regions":{"type":"object","description":"Khu vực đang khai: tên → mã nước.","additionalProperties":{"type":"array","items":{"type":"string"}},"example":{"CHAU_AU":["DE","FR","GB"]}}}},"SellingPriceSettingsUpdate":{"type":"object","required":["mode","reason"],"additionalProperties":false,"properties":{"mode":{"type":"string","enum":["off","shadow","on"]},"partners":{"type":"object","description":"Key `HNH` / `BGT` / `HPL`; giá trị `null` = theo chế độ chung","additionalProperties":{"type":"string","nullable":true,"enum":["off","shadow","on",null]}},"reason":{"type":"string","minLength":3,"maxLength":500},"expectedVersion":{"type":"integer","minimum":0,"description":"Version cấu hình người gọi đang thấy; lệch → 409 `VERSION_CONFLICT`"},"priceLockMinutes":{"type":"integer","minimum":15,"maximum":240,"description":"Bỏ trống = giữ giá trị đang lưu (env `SELLING_PRICE_LOCK_MINUTES` / 60 khi chưa từng đặt)."},"defaultPaxTypes":{"type":"array","minItems":1,"items":{"type":"string","enum":["ADT","CHD","INF"]},"description":"Bỏ trống = giữ giá trị đang lưu. Áp cho rule không ghi `pax_types`."},"rounding":{"type":"string","enum":["FLOOR_1","FLOOR_100","ROUND_100","FLOOR_1000","ROUND_1000"],"description":"Bỏ trống = giữ giá trị đang lưu (env `SELLING_PRICE_ROUNDING` / `FLOOR_1`)."},"channels":{"type":"object","description":"THAY CẢ BẢNG kênh bán: tên kênh (IN HOA, ≤24 ký tự) → tên key API ở gateway (`AGENCY_KEY_<TÊN>` viết thường). Tối đa 20 kênh, 200 key mỗi kênh.","additionalProperties":{"type":"array","minItems":1,"items":{"type":"string"}},"example":{"WEB":["dlv_web"],"B2B":["acme","beta"]}},"channelModes":{"type":"object","description":"GỘP vào cái đang lưu. `null` cho một kênh = kênh đó theo chế độ NCC/chung. Chỉ nhận kênh đã có trong `channels`.","additionalProperties":{"type":"string","nullable":true,"enum":["off","shadow","on",null]},"example":{"WEB":"on"}},"regions":{"type":"object","description":"THAY CẢ BẢNG khu vực: tên (IN HOA, ≤32 ký tự) → mã nước ISO. `{}` = xoá hết. Tối đa 100 khu vực, 250 nước mỗi khu vực. Xoá khu vực rule còn dùng ⇒ 409 `REGIONS_IN_USE` (details.regions = { TÊN: [rule_id] }).","additionalProperties":{"type":"array","minItems":1,"items":{"type":"string"}},"example":{"CHAU_AU":["DE","FR","GB"]}},"acknowledgeWarnings":{"type":"boolean","description":"Vẫn xoá khu vực đang được rule dùng (các rule đó sẽ ngừng khớp)."}}},"DateRange":{"type":"object","required":["from","to"],"description":"Khoảng ngày lịch Việt Nam, GỒM cả hai đầu.","properties":{"from":{"type":"string","format":"date","example":"2027-02-10"},"to":{"type":"string","format":"date","example":"2027-02-20"}}},"PairPriceQuoteRequest":{"type":"object","required":["fareSelectionIds"],"properties":{"fareSelectionIds":{"type":"array","minItems":2,"maxItems":2,"items":{"type":"string"},"description":"Hai vé KHÁC nhau của một khứ hồi (thứ tự nào cũng được; server tự xác định chiều đi theo giờ bay)."},"passengerCounts":{"type":"object","properties":{"adt":{"type":"integer","minimum":1,"default":1},"chd":{"type":"integer","minimum":0,"default":0},"inf":{"type":"integer","minimum":0,"default":0}}}}},"PairPriceQuoteResponse":{"type":"object","description":"Báo giá khứ hồi theo cặp. Mode off: `legs` là dữ liệu NCC nguyên văn, không có field giá bán.","properties":{"pnrGroups":{"type":"array","items":{"type":"array","items":{"type":"string"}},"description":"[[đi, về]] = 1 PNR (giá hành trình); [[đi],[về]] = 2 PNR (giá từng vé).","example":[["fs_out","fs_back"]]},"legs":{"type":"array","description":"Theo thứ tự đã gửi: `fareSelectionId` + dữ liệu báo giá của vé đó (mode on: `totalPrice`, `fareAdt`, `taxAdt`… đã trừ phần giảm của CHIỀU đó, fare + tax = totalPrice; `pricing.journey` = khoản giảm của cả hành trình).","items":{"type":"object"}},"totalPrice":{"type":"number","description":"Tổng hai vé (mode on: giá bán)"},"netTotalPrice":{"type":"number","description":"Tổng giá NCC (chỉ khi có giá bán)"},"discountTotal":{"type":"number"},"currency":{"type":"string"},"journey":{"type":"object","description":"Chỉ khi 1 PNR và mode khác off","properties":{"fareSelectionIds":{"type":"array","items":{"type":"string"}},"mode":{"type":"string"},"netTotalPrice":{"type":"number"},"discountTotal":{"type":"number"},"sellingPrice":{"type":"number"},"lockedUntil":{"type":"string","format":"date-time"},"locked":{"type":"boolean"}}},"failedFareSelectionId":{"type":"string","description":"(Chỉ khi lỗi) vé NCC từ chối báo giá"}}},"PricingRule":{"type":"object","required":["rule_id","name","status","priority","product_type","system","discount_type","discount_value","discount_base","currency"],"description":"Điều kiện bỏ trống / `null` = mọi giá trị; danh sách rỗng bị từ chối. Cấp hạng: `cabins` (khoang) → `fare_families` → `fare_basis` → `booking_classes` (RBD); rule có nhiều điều kiện hơn thắng khi cùng priority. Ngày là ngày lịch giờ Việt Nam, tính cả hai đầu. `effective_*` = ngày bán, `travel_*` = ngày bay chặng đầu. Rule khớp nhiều → `priority` cao hơn, rồi cụ thể hơn, rồi sửa gần nhất. Mỗi điều kiện danh sách có một ô `*_exclude` đi kèm: ô chọn bỏ trống = TẤT CẢ, ô ngoại trừ bỏ trống = không trừ ai; một giá trị nằm ở cả hai ô (hoặc một khoảng loại trừ phủ kín khung ngày) bị từ chối khi lưu. CHỐT AN TOÀN: vé không đọc được giá trị của mục đang bị loại trừ thì rule KHÔNG áp.","properties":{"rule_id":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$","description":"Không được là `bulk` / `preview`"},"name":{"type":"string","maxLength":200},"status":{"type":"string","enum":["DRAFT","ACTIVE","INACTIVE","DELETED"]},"priority":{"type":"integer"},"product_type":{"type":"string","enum":["FLIGHT"]},"system":{"type":"string","enum":["GALILEO","AMADEUS","SABRE","ANY_GDS"]},"partner":{"type":"string","nullable":true,"enum":["HNH","BGT","HPL",null]},"trip_scope":{"type":"string","nullable":true,"enum":["DOMESTIC","INTERNATIONAL",null]},"airline_codes":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"VN"},"description":"Chọn NHIỀU hãng trong một rule; bỏ trống = MỌI hãng (hợp với BSP, không phải liệt kê hết)."},"airline_codes_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"VJ"},"description":"Trừ các hãng này ra. Cặp \"bỏ trống hãng (= tất cả) + ngoại trừ vài hãng\" là cách cấu hình chính cho BSP. Một hãng nằm ở CẢ hai ô ⇒ 400 tại `airline_codes_exclude`."},"origin_country":{"type":"string","nullable":true,"example":"VN","description":"MỘT nước (dạng cũ). Không gửi kèm `origin_countries`."},"destination_country":{"type":"string","nullable":true,"example":"JP","description":"MỘT nước (dạng cũ). Không gửi kèm `destination_countries`."},"origin_countries":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"VN"},"description":"Nhiều nước phía đi (ISO 3166-1 alpha-2)."},"destination_countries":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"SG"}},"origin_countries_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string"},"description":"Ngoại trừ nước phía đi. Đi CÙNG PHÍA với ô chọn: `bidirectional` đảo chiều thì ô này đảo theo. Sân bay không rõ nước ⇒ rule không áp."},"destination_countries_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"GB"}},"origin_regions":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"CHAU_AU"},"description":"Khu vực khai ở `/settings.regions`, nở thành nước lúc compile. Khu vực CHƯA KHAI ⇒ rule không khớp vé nào (ACTIVE bị từ chối với `REGION_NOT_DEFINED` trừ khi acknowledgeWarnings)."},"destination_regions":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"CHAU_AU"}},"origin_regions_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string"}},"destination_regions_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string"},"description":"Khu vực chưa khai trong ô loại trừ cũng làm rule không khớp (không bao giờ nới rộng rule)."},"origin":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"SGN"},"description":"Mã sân bay hoặc mã thành phố"},"destination":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"NRT"}},"origin_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"PQC"},"description":"Ngoại trừ điểm đi. Đọc trên CHIỀU THẬT của vé nên `bidirectional` không lách được."},"destination_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"PQC"}},"routes_exclude":{"type":"array","nullable":true,"minItems":1,"description":"Ngoại trừ ĐÚNG MỘT đường bay (cặp {from,to}) — loại SGN→NRT mà vẫn giữ SGN→HND. Rule `bidirectional` loại luôn chiều ngược.","items":{"type":"object","required":["from","to"],"properties":{"from":{"type":"string","example":"SGN"},"to":{"type":"string","example":"NRT"}}}},"bidirectional":{"type":"boolean","default":false},"travel_from":{"type":"string","format":"date","nullable":true},"travel_to":{"type":"string","format":"date","nullable":true},"travel_blackouts":{"type":"array","nullable":true,"minItems":1,"maxItems":50,"description":"Các khoảng NGÀY BAY bị loại khỏi khung trên (Tết, lễ…), gồm cả hai đầu. Một khoảng phủ kín `travel_from..travel_to` ⇒ 400.","items":{"$ref":"#/components/schemas/DateRange"}},"travel_days_of_week":{"type":"array","nullable":true,"minItems":1,"maxItems":7,"items":{"type":"integer","minimum":1,"maximum":7},"example":[5,6,7],"description":"Thứ của NGÀY BAY chặng đầu (1 = thứ Hai … 7 = CN). Khác `sale_days_of_week` (thứ của ngày bán)."},"arrive_from":{"type":"string","format":"date","nullable":true,"description":"Ngày HẠ CÁNH của chặng cuối chiều đi (ngày địa phương nơi đến), gồm cả hai đầu. Vé không có ngày hạ cánh ⇒ rule không áp."},"arrive_to":{"type":"string","format":"date","nullable":true},"arrive_blackouts":{"type":"array","nullable":true,"minItems":1,"maxItems":50,"description":"Các khoảng NGÀY HẠ CÁNH bị loại.","items":{"$ref":"#/components/schemas/DateRange"}},"cabins":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","enum":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST"]}},"cabins_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","enum":["ECONOMY","PREMIUM_ECONOMY","BUSINESS","FIRST"]},"description":"Ngoại trừ khoang."},"booking_classes":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z]$","example":"N"},"description":"Hạng đặt chỗ (RBD). MỌI chặng chiều đi phải thuộc danh sách. Mã theo từng hãng — nên kèm `airline_codes`."},"fare_basis":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9]{1,15}\\*?$","example":"N16*"},"description":"Fare basis đúng mã, hoặc tiền tố kết thúc bằng `*`. Mọi chặng chiều đi phải khớp một mục."},"fare_families":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9_]{1,40}$","example":"FB_16VNO"},"description":"Hạng vé theo `fareFamilyCode` do chính vé giải ra. Vé GDS quốc tế thường chỉ có mã `FB_<stem>` sinh từ fare basis — dùng `fare_basis` sẽ rõ hơn."},"booking_classes_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z]$","example":"Q"},"description":"Ngoại trừ RBD. CHỈ CẦN MỘT chặng chiều đi dính là loại cả vé (ngược với ô chọn, vốn đòi mọi chặng khớp)."},"fare_basis_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9]{1,15}\\*?$","example":"Q16*"},"description":"Ngoại trừ fare basis; dùng được tiền tố `*`. Một chặng dính là loại cả vé."},"fare_families_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9_]{1,40}$","example":"FB_16VNO"}},"flight_numbers":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9]{2}[0-9]{1,4}[A-Z]?$","example":"VN123"},"description":"Số hiệu chuyến kèm mã hãng. MỌI chặng chiều đi phải nằm trong danh sách."},"flight_numbers_exclude":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","pattern":"^[A-Z0-9]{2}[0-9]{1,4}[A-Z]?$","example":"SQ177"},"description":"Ngoại trừ chuyến bay; một chặng dính là loại cả vé. LƯU Ý: vé không đọc được số hiệu chuyến cũng KHÔNG được áp rule (chốt an toàn)."},"trip_types":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","enum":["ONE_WAY","ROUND_TRIP"]},"description":"Loại hành trình CỦA LẦN BÁN: search có `returnDate` → mọi vé của lần đó là `ROUND_TRIP`."},"advance_days_min":{"type":"integer","nullable":true,"minimum":0,"maximum":999,"description":"Mua trước tối thiểu N ngày (ngày bán → ngày bay chặng đầu, lịch Việt Nam)."},"advance_days_max":{"type":"integer","nullable":true,"minimum":0,"maximum":999},"fare_amount_min":{"type":"number","nullable":true,"minimum":0,"description":"Khoảng giá vé, đo trên MỘT người lớn theo đúng `discount_base` của rule."},"fare_amount_max":{"type":"number","nullable":true,"minimum":0},"sale_blackouts":{"type":"array","nullable":true,"minItems":1,"maxItems":50,"description":"Các khoảng NGÀY BÁN bị loại (ngừng bán dịp nào đó). Mốc mở/đóng là biên tính lại giá của cache.","items":{"$ref":"#/components/schemas/DateRange"}},"channels":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"B2B"},"description":"Kênh bán (khai ở `/settings.channels`). Không biết người gọi ⇒ rule không khớp."},"agencies":{"type":"array","nullable":true,"minItems":1,"items":{"type":"string","example":"acme"},"description":"Đích danh tên key đại lý ở gateway."},"sale_time_from":{"type":"string","nullable":true,"pattern":"^([01]\\d|2[0-3]):([0-5]\\d)$","example":"12:00","description":"Flash sale: giờ bắt đầu trong ngày (giờ VN). Phải gửi cùng `sale_time_to`."},"sale_time_to":{"type":"string","nullable":true,"pattern":"^([01]\\d|2[0-3]):([0-5]\\d)$","example":"14:00","description":"Giờ kết thúc, KHÔNG bao gồm (`12:00`→`14:00` dừng đúng 14:00). `from > to` = khung vắt qua nửa đêm."},"sale_days_of_week":{"type":"array","nullable":true,"minItems":1,"maxItems":7,"items":{"type":"integer","minimum":1,"maximum":7},"example":[5,6],"description":"Thứ của NGÀY BÁN: 1 = thứ Hai … 7 = Chủ nhật (giờ VN)."},"pax_types":{"type":"array","minItems":1,"default":["ADT","CHD"],"items":{"type":"string","enum":["ADT","CHD","INF"]}},"discount_type":{"type":"string","enum":["PERCENT","FIXED_AMOUNT"]},"discount_value":{"type":"number","exclusiveMinimum":true,"minimum":0,"description":"`PERCENT` trong (0, 100]; `FIXED_AMOUNT` = số tiền / khách"},"discount_base":{"type":"string","enum":["BASE_FARE","TOTAL_FARE"]},"max_discount":{"type":"number","nullable":true,"minimum":0,"description":"Trần / khách"},"min_discount":{"type":"number","nullable":true,"minimum":0,"description":"Sàn / khách"},"max_discount_per_booking":{"type":"number","nullable":true,"exclusiveMinimum":true,"minimum":0,"description":"Trần cho CẢ ĐƠN. Chạm trần → mức giảm từng khách hạ theo cùng tỉ lệ rồi làm tròn xuống."},"rounding":{"type":"string","nullable":true,"enum":["FLOOR_1","FLOOR_100","ROUND_100","FLOOR_1000","ROUND_1000",null],"description":"Làm tròn riêng cho rule này; bỏ trống = theo cài đặt chung."},"budget_total":{"type":"number","nullable":true,"exclusiveMinimum":true,"minimum":0,"description":"Tổng tiền giảm tối đa rule được chi. Đếm trên booking, dùng chung mọi pod, làm mới ≤30s ⇒ TRẦN MỀM. Hết ngân sách → rule ngừng áp; reset bằng `POST /rules/{id}/budget/reset`."},"budget_spent":{"type":"number","readOnly":true,"description":"Đã chi bao nhiêu (chỉ có trong danh sách / chi tiết rule)."},"description":{"type":"string","nullable":true,"maxLength":1000,"description":"Ghi chú — không ảnh hưởng giá."},"tags":{"type":"array","nullable":true,"minItems":1,"maxItems":20,"items":{"type":"string","example":"q4-2026"},"description":"Nhãn chiến dịch, dùng để lọc danh sách."},"owner":{"type":"string","nullable":true,"maxLength":100,"description":"Người phụ trách."},"currency":{"type":"string","example":"VND"},"effective_from":{"type":"string","format":"date","nullable":true},"effective_to":{"type":"string","format":"date","nullable":true},"version":{"type":"integer","readOnly":true},"updated_at":{"type":"string","format":"date-time","readOnly":true},"updated_by":{"type":"string","readOnly":true}}},"DisplaySupplierEntry":{"type":"object","properties":{"shown":{"type":"boolean"},"priority":{"type":"integer","minimum":0,"maximum":999,"description":"Số NHỎ = ưu tiên cao."},"label":{"type":"string","maxLength":40,"example":"BGT"}}},"DisplayAirlineRow":{"type":"object","additionalProperties":false,"description":"Một dòng hãng của một thị trường. Khi GHI nhận thêm dạng cũ `true`/`false` (= `{ shown }`); khi ĐỌC luôn là object. PUT gửi dòng là THAY CẢ DÒNG; `null` = xoá dòng.","properties":{"shown":{"type":"boolean","description":"Hiện / ẩn hãng. Không khai = theo `unlisted`."},"suppliers":{"type":"object","additionalProperties":false,"properties":{"tripota":{"type":"boolean"},"airdata":{"type":"boolean"},"skeeper":{"type":"boolean"}},"description":"NCC được lấy vé của hãng này ở thị trường này. Chỉ THU HẸP trong số NCC đang bật toàn cục; thiếu key = lấy. Mã NCC lạ → 400. `shown: true` mà cả 3 NCC false → 400."}},"example":{"shown":true,"suppliers":{"tripota":false,"airdata":false,"skeeper":true}}},"DisplayMarket":{"type":"object","properties":{"unlisted":{"type":"string","enum":["SHOW","HIDE"],"description":"Hãng chưa khai: SHOW = danh sách chặn (mặc định), HIDE = danh sách cho phép."},"airlines":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/DisplayAirlineRow"},"example":{"VJ":{"shown":true,"suppliers":{"airdata":false}},"QH":{"shown":false}},"description":"Mã IATA 2 ký tự → dòng hãng."}}},"DisplayProfile":{"type":"object","properties":{"mode":{"type":"string","enum":["all","priority"]},"suppliers":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/DisplaySupplierEntry"},"description":"Khoá: `tripota` (HNH), `airdata` (BGT), `skeeper` (HPL)."},"supplierAirlines":{"type":"object","deprecated":true,"additionalProperties":{"type":"object","additionalProperties":{"type":"object","properties":{"shown":{"type":"boolean"},"priority":{"type":"integer"}}}},"description":"DEPRECATED — thay bằng `markets.<m>.airlines.<IATA>.suppliers`. Ghi đè theo hãng, mỗi hãng khai ĐỦ 3 NCC, thay toàn bộ dòng mặc định cho hãng đó (cả hai thị trường). Vẫn áp cho tới khi xoá (`supplierAirlines.<IATA> = null`), trừ ở thị trường có dòng khai `suppliers`."},"markets":{"type":"object","properties":{"domestic":{"$ref":"#/components/schemas/DisplayMarket"},"international":{"$ref":"#/components/schemas/DisplayMarket"}}},"enforceOnBooking":{"type":"boolean","description":"false = chỉ ẩn ở search, không chặn price-quote / book."}}},"DisplayRuntimeView":{"allOf":[{"$ref":"#/components/schemas/DisplayProfile"},{"type":"object","properties":{"version":{"type":"integer"},"channel":{"type":"string","example":"DEFAULT"},"stale":{"type":"boolean"},"source":{"type":"string","enum":["runtime","env","forced_off"]}}}]},"DisplayPolicyView":{"type":"object","properties":{"version":{"type":"integer"},"channels":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"example":{"AG":["dlv_portal"]},"description":"Kênh → tên key API ở gateway (viết thường)."},"profiles":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/DisplayProfile"},"description":"Luôn có `DEFAULT`."},"updatedAt":{"type":"string","format":"date-time","nullable":true},"updatedBy":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"source":{"type":"string","enum":["runtime","env"]},"forcedOff":{"type":"boolean"}}},"DisplayPolicyUpdate":{"type":"object","required":["reason"],"additionalProperties":false,"properties":{"channels":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"THAY CẢ BẢNG. `DEFAULT` là tên dành riêng."},"profiles":{"type":"object","additionalProperties":{"nullable":true,"allOf":[{"$ref":"#/components/schemas/DisplayProfile"}]},"description":"Bản vá theo profile (gộp). null = xoá profile."},"reason":{"type":"string","minLength":5,"maxLength":500},"expectedVersion":{"type":"integer","minimum":0},"acknowledgeWarnings":{"type":"boolean"}}},"DisplayCoverageCell":{"type":"object","properties":{"supplier":{"type":"string"},"label":{"type":"string"},"cell":{"type":"string","enum":["NONE","SUPPLIER_NOT_RUNNING","SUPPLIER_OFF","HAS_DATA","CONFIGURED_NO_DATA","GDS_POSSIBLE"]},"configured":{"type":"string","enum":["DIRECT","GDS"],"nullable":true},"tokens":{"type":"array","items":{"type":"string"},"example":["VN1A","VN1A_MT"]},"routed":{"type":"boolean"},"shown":{"type":"boolean","description":"Lớp NCC TRƯỚC khi chọn theo hãng (công tắc ops + toàn cục, hoặc supplierAirlines cũ)."},"selected":{"type":"boolean","description":"NCC có được lấy vé của hãng này ở thị trường này không: giá trị dòng hãng nếu có, không thì công tắc toàn cục; công tắc ops luôn thắng. Không đổi `cell` (ô tắt toàn cục vẫn `SUPPLIER_OFF` dù dòng bật riêng)."},"selectable":{"type":"boolean","description":"CMS được cho bật/tắt riêng NCC này cho hãng không: false khi `cell` = `NONE` / `SUPPLIER_NOT_RUNNING` hoặc công tắc ops ẩn NCC."},"observed":{"type":"object","nullable":true,"properties":{"fares":{"type":"integer"},"lastSeenAt":{"type":"integer","nullable":true,"description":"epoch ms"}}},"observedBySystem":{"type":"array","description":"Vé đã thấy tách theo token nguồn (supplierSource), nhiều nhất trước. Đếm từ khi có bộ đếm v2.","items":{"type":"object","properties":{"token":{"type":"string","example":"1A","description":"Tên hiển thị: catalog.systems[token]."},"system":{"type":"string","enum":["VJ_DIRECT","VNA_DIRECT","DIRECT_OTHER","GDS_1A","GDS_1G","GDS_OTHER","UNKNOWN"]},"group":{"type":"string","enum":["DIRECT","GDS","UNKNOWN"]},"fares":{"type":"integer"},"lastSeenAt":{"type":"integer","nullable":true,"description":"epoch ms"},"quality":{"type":"object","nullable":true,"description":"Tỉ lệ % (1 số lẻ) trong cửa sổ; null khi cửa sổ không có vé.","properties":{"fareFamilyPct":{"type":"number"},"refundableKnownPct":{"type":"number"},"baggageStructuredPct":{"type":"number"}}}}}}}},"DisplayCoverageRow":{"type":"object","properties":{"code":{"type":"string","example":"VJ"},"ticked":{"type":"boolean","description":"Giá trị đang lưu (kể cả khi dòng bị làm mờ)."},"declared":{"type":"boolean","description":"true = khai rõ; false = theo `unlisted`."},"suppliersDeclared":{"type":"object","nullable":true,"additionalProperties":{"type":"boolean"},"description":"`suppliers` của dòng đúng như đang lưu; null = dòng không khai."},"availability":{"type":"string","enum":["AVAILABLE","NO_ACTIVE_SUPPLIER"],"description":"AVAILABLE khi có NCC vừa `selected` vừa `selectable`."},"effectiveShown":{"type":"boolean"},"observedFares":{"type":"integer"},"lastSeenAt":{"type":"integer","nullable":true},"sources":{"type":"array","items":{"$ref":"#/components/schemas/DisplayCoverageCell"}}}},"DisplayPolicyMeta":{"type":"object","properties":{"catalog":{"type":"object"},"limits":{"type":"object"},"matching":{"type":"object"},"current":{"$ref":"#/components/schemas/DisplayPolicyView"},"request":{"type":"object","properties":{"channel":{"type":"string"},"market":{"type":"string"},"windowDays":{"type":"integer"},"profileExists":{"type":"boolean"},"effectiveProfile":{"type":"string"}}},"coverage":{"type":"object","properties":{"market":{"type":"string"},"windowDays":{"type":"integer"},"routedSuppliers":{"type":"array","items":{"type":"string"}},"opsHiddenSuppliers":{"type":"array","items":{"type":"string"}},"observedAvailable":{"type":"boolean"},"generatedAt":{"type":"string","format":"date-time"},"airlines":{"type":"array","items":{"$ref":"#/components/schemas/DisplayCoverageRow"}}}}}},"ErrorCodeEnum":{"type":"string","enum":["VALIDATION","MISSING_REF","MISSING_TICKET","BOOKING_NOT_FOUND","PARENT_NOT_FOUND","TICKET_NOT_FOUND","FARE_EXPIRED","SUPPLIER_REJECTED","NOT_SUPPORTED_BY_OWNING_SUPPLIER","NO_SUPPLIER","NO_ADAPTER","ADAPTER_THREW","MISSING_PARAMS","MISSING_SUPPLIER","SUPPLIER_REQUIRED","UNKNOWN_SUPPLIER","BOOK_FAILED","ISSUE_FAILED","PAYNOW_LEG_FAILED","SPLIT_IN_PROGRESS","SELLING_PRICE_CHANGED","VERSION_CONFLICT","FORCED_OFF","CONFIG_BUSY","SETTINGS_STORE_UNAVAILABLE","ADMIN_ACTOR_REQUIRED","RULE_NOT_FOUND","RULE_EXISTS","RULE_DELETED","RULE_WILL_NOT_MATCH","CACHE_MISS","REGIONS_IN_USE","SOURCE_POLICY_BLOCKED","DISPLAY_POLICY_BLOCKED","WOULD_HIDE_EVERYTHING","AGENCY_IN_TWO_CHANNELS","POLICY_STORE_UNAVAILABLE"]},"ErrorObj":{"type":"object","properties":{"code":{"$ref":"#/components/schemas/ErrorCodeEnum"},"message":{"type":"string"},"category":{"type":"string","enum":["validation","logical","capability","transport","unknown"]},"retryable":{"type":"boolean"},"supplierCode":{"type":"string","nullable":true},"supplierMessage":{"type":"string","nullable":true},"details":{"type":"array","nullable":true,"items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"},"code":{"type":"string"}}}}}},"ErrorEnvelope":{"type":"object","description":"Envelope chuẩn: mọi response (success + error) dùng shape này. Check `ok` trước khi đọc `data` / `error`.","required":["ok","traceId","operation","latencyMs"],"properties":{"ok":{"type":"boolean","example":true,"description":"`true` khi operation thành công. Khi `false`, đọc `error`."},"traceId":{"type":"string","example":"abc123","description":"Unique ID để trace request cross-system. Dùng `/internal/raw/:traceId` (internal) xem raw upstream."},"supplier":{"type":"string","example":"tripota","enum":["aggregator","airdata","tripota","skeeper",null],"nullable":true,"description":"`aggregator` = orchestrator (search/min-fare), else = NCC owning the op."},"operation":{"type":"string","example":"book"},"capability":{"type":"object","description":"Supplier capability metadata.","properties":{"supported":{"type":"boolean"},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"alternatives":{"type":"array","items":{"type":"object"}}}},"latencyMs":{"type":"integer","example":5200},"data":{"type":"null","nullable":true},"raw":{"type":"object","nullable":true,"description":"Debug info — upstream request/response log. Có thể strip ở prod.","properties":{"archiveKey":{"type":"string","example":"raw:abc123"},"inline":{"type":"array","nullable":true,"items":{"type":"object"}},"requests":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"url":{"type":"string"},"method":{"type":"string"},"reqBody":{},"resStatus":{"type":"integer"},"resBody":{},"ms":{"type":"integer"}}}}}},"error":{"$ref":"#/components/schemas/ErrorObj"},"meta":{"type":"object","nullable":true,"description":"Route-level metadata (vd cache state)."}}}}}}