{"openapi":"3.1.0","info":{"title":"KeyFlight PNR API","version":"1.0.0","summary":"Decode Amadeus, Sabre, Galileo and Worldspan PNRs into JSON and a readable itinerary.","description":"Paste a raw booking from a GDS and get the passengers and flight segments as JSON (dates, times, airports, terminals, aircraft, airline references) plus the itinerary as text and e-mail HTML.\n\nRequires an API key from the KeyFlight subscription for travel agents. Limits: 60 requests a minute per key, 3,000 decodes a month per subscription; only answers with flights count.","contact":{"name":"KeyFlight","url":"https://keyflight.io/pnr-api"}},"externalDocs":{"description":"Documentation, examples and limits","url":"https://keyflight.io/pnr-api"},"servers":[{"url":"https://keyflight.io"}],"security":[{"apiKey":[]}],"paths":{"/api/v1/pnr/decode":{"post":{"operationId":"decodePnr","summary":"Decode a PNR","tags":["PNR"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeRequest"},"example":{"text":"RP/LHRBA/LHRBA            BA/BA  26APR26/1200Z   PQ7XNR\nPQ7XNR/BA QLHR 03MAY\n1.JOHNSON JOHN\n2.JOHNSON JANE\n3  BA 178 Y 03MAY 7 LHRJFK HK2  0855 1205  03MAY  E  BA/PQ7XNR\n4  BA 117 Y 10MAY 7 JFKLHR HK2  1830 0640  11MAY  E  BA/PQ7XNR\n5 TKT/TIME LIMIT\n6 OPC LHRBA-10MAY:1900/1S2/Q TKT/T-BA\n7 FA PAX 125-2196837482/ETBA/GBP560.20/03MAY26/LHRBA2104/00390755/S3-4","options":{"view":"table"}}}}},"responses":{"200":{"description":"The decoded booking.","headers":{"X-Monthly-Limit":{"description":"Decodes a month for the subscription.","schema":{"type":"integer"}},"X-Monthly-Remaining":{"description":"Decodes left this month.","schema":{"type":"integer"}},"X-Monthly-Reset":{"description":"When the monthly limit starts again (ISO time, the 1st 00:00 UTC).","schema":{"type":"string"}},"X-RateLimit-Limit":{"description":"Requests a minute for the key.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in this minute.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"When the minute ends (Unix time).","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeResponse"},"example":{"pnrCode":"PQ7XNR","passengers":[{"name":"JOHNSON JOHN"},{"name":"JOHNSON JANE"}],"segments":[{"airlineCode":"BA","airlineName":"British Airways","flightNumber":"178","bookingClass":"Y","cabin":"Economy","status":"HK2","statusText":"Confirmed","logoUrl":"https://keyflight.io/img/airlines/BA.png","duration":490,"distance":{"km":5540,"miles":3442},"aircraftCode":null,"aircraft":null,"operatedBy":null,"airlineLocator":{"airlineCode":"BA","code":"PQ7XNR"},"departure":{"code":"LHR","city":"London","airport":"London Heathrow Airport","terminal":null,"date":"2026-05-03","time":"08:55"},"arrival":{"code":"JFK","city":"New York","airport":"John F Kennedy International Airport","terminal":null,"date":"2026-05-03","time":"12:05"}},{"airlineCode":"BA","airlineName":"British Airways","flightNumber":"117","bookingClass":"Y","cabin":"Economy","status":"HK2","statusText":"Confirmed","logoUrl":"https://keyflight.io/img/airlines/BA.png","duration":430,"distance":{"km":5540,"miles":3442},"aircraftCode":null,"aircraft":null,"operatedBy":null,"airlineLocator":{"airlineCode":"BA","code":"PQ7XNR"},"departure":{"code":"JFK","city":"New York","airport":"John F Kennedy International Airport","terminal":null,"date":"2026-05-10","time":"18:30"},"arrival":{"code":"LHR","city":"London","airport":"London Heathrow Airport","terminal":null,"date":"2026-05-11","time":"06:40"}}],"itinerary":{"view":"table","text":"BA 178 · British Airways · 8h 10m\n3 May 2026 08:55  London (LHR), London Heathrow Airport\n3 May 2026 12:05  New York (JFK), John F Kennedy International Airport\n\nBA 117 · British Airways · 7h 10m\n10 May 2026 18:30  New York (JFK), John F Kennedy International Airport\n11 May 2026 06:40  London (LHR), London Heathrow Airport","html":"<div style=\"font-family:Arial,Helvetica,sans-serif;font-size…"}}}}},"400":{"description":"`invalid_json`: The body is not a JSON object.\n`text_required`: `text` is missing or empty.\n`invalid_option`: An unknown option or a wrong value. `field` names it, `allowed` lists the values.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["invalid_json","text_required","invalid_option"]}}}]}}}},"401":{"description":"`missing_api_key`: No `Authorization: Bearer …` header.\n`invalid_api_key`: The key is not valid or was revoked.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["missing_api_key","invalid_api_key"]}}}]}}}},"403":{"description":"`subscription_inactive`: The subscription of the key is not active.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["subscription_inactive"]}}}]}}}},"404":{"description":"`not_found`: No such endpoint.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["not_found"]}}}]}}}},"405":{"description":"`method_not_allowed`: The method is not POST.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["method_not_allowed"]}}}]}}}},"413":{"description":"`too_long`: The text is longer than 20,000 characters (`max` in the answer).\n`payload_too_large`: The body is larger than 100kb.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["too_long","payload_too_large"]}}}]}}}},"415":{"description":"`unsupported_encoding`: The body is not UTF-8.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["unsupported_encoding"]}}}]}}}},"422":{"description":"`no_flights`: No flights in the text. Does not count towards the monthly limit.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["no_flights"]}}}]}}}},"429":{"description":"`too_many_requests`: Over the per-minute limit; wait `Retry-After` seconds.\n`monthly_limit_reached`: The subscription has used its decodes for this month.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["too_many_requests","monthly_limit_reached"]}}}]}}}},"500":{"description":"`server_error`: Something went wrong on our side.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["server_error"]}}}]}}}},"503":{"description":"`service_unavailable`: The key cannot be checked right now. Try again in a minute.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Error"},{"type":"object","properties":{"error":{"enum":["service_unavailable"]}}}]}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"The API key from the KeyFlight subscription: `Authorization: Bearer kfp_…`."}},"schemas":{"DecodeRequest":{"type":"object","required":["text"],"additionalProperties":false,"properties":{"text":{"type":"string","minLength":1,"maxLength":20000,"description":"The booking as the GDS shows it (Amadeus, Sabre, Galileo, Worldspan). The format is recognised from the text."},"options":{"type":"object","additionalProperties":false,"description":"All optional. An unknown option or value answers `400 invalid_option`. The options change only `itinerary`.","properties":{"view":{"type":"string","enum":["table","lines2","lines3","whatsapp"],"default":"table","description":"`table`: HTML: a table with logo, flight, departure and arrival. Text: three lines per flight.\n`lines2`: Two lines per flight: the route, then the times; airport names on a third line.\n`lines3`: Three lines per flight: flight and airline, departure, arrival.\n`whatsapp`: Text only, flight titles in *bold* for WhatsApp. html is null."},"timeFormat":{"type":"string","enum":["24","12"],"default":"24"},"dateFormat":{"type":"string","enum":["short","numeric"],"default":"short"},"show":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"boolean","default":true,"description":"Airline logos (HTML only)."},"airports":{"type":"boolean","default":true,"description":"Airport names and terminals next to the city."},"cabin":{"type":"boolean","default":false,"description":"Cabin and booking class: Economy (Y)."},"status":{"type":"boolean","default":false,"description":"Segment status: Confirmed, Waitlisted."},"passengers":{"type":"boolean","default":false,"description":"Passenger names above the flights."},"pnr":{"type":"boolean","default":false,"description":"The booking reference and the airlines' references above the flights."}}}}}}},"DecodeResponse":{"type":"object","properties":{"pnrCode":{"description":"The booking reference found in the text, or `null`.","type":["string","null"]},"passengers":{"type":"array","items":{"type":"object","properties":{"name":{"description":"A passenger name as the PNR writes it.","type":"string"}},"required":["name"]}},"segments":{"type":"array","items":{"type":"object","properties":{"airlineCode":{"description":"IATA code of the airline.","type":"string"},"airlineName":{"description":"Airline name; an unknown code is its own name.","type":"string"},"flightNumber":{"description":"Flight number without leading zeros: `\"950\"` for UA0950.","type":"string"},"bookingClass":{"description":"Booking class letter, or `null`.","type":["string","null"]},"cabin":{"description":"By the booking class: Economy, Premium Economy, Business, First Class.","type":"string"},"status":{"description":"Status code as in the PNR (`\"HK2\"`), or `null`.","type":["string","null"]},"statusText":{"description":"Confirmed, Waitlisted, or the code itself; `null` without a status.","type":["string","null"]},"logoUrl":{"description":"URL of the airline logo, 64×64 PNG (a plane silhouette when we have none).","type":"string"},"duration":{"description":"Flight time in minutes, counted across the two airports' time zones (summer time included), or `null` when an airport, its time zone, a date or a time is not known.","type":["integer","null"]},"distance":{"type":["object","null"],"properties":{"km":{"description":"Great-circle distance between the airports in kilometres; `distance` is `null` when an airport is not known.","type":"integer"},"miles":{"description":"The same distance in statute miles.","type":"integer"}},"required":["km","miles"]},"aircraftCode":{"description":"IATA code of the aircraft type when the PNR shows it (Amadeus `E 0 744 LM` after the times), or `null`.","type":["string","null"]},"aircraft":{"description":"Aircraft name for `aircraftCode`: `\"Boeing 747-400\"`, or `null`.","type":["string","null"]},"operatedBy":{"description":"Operating airline as the PNR prints it under the flight (`OPERATED BY …`), or `null`.","type":["string","null"]},"airlineLocator":{"type":["object","null"],"properties":{"airlineCode":{"description":"Airline of the airline's own booking reference (Amadeus `BA/PQ7XNR`, Sabre `/DCBA*PQ7XNR`); `airlineLocator` is `null` when the text has none.","type":"string"},"code":{"description":"The airline's booking reference, 6 characters.","type":"string"}},"required":["airlineCode","code"]},"departure":{"type":"object","properties":{"code":{"description":"IATA code of the airport.","type":"string"},"city":{"description":"City, or `null`.","type":["string","null"]},"airport":{"description":"Airport name, or `null`.","type":["string","null"]},"terminal":{"description":"Terminal as the PNR prints it (`\"5\"`, `\"2E\"`), or `null`.","type":["string","null"]},"date":{"description":"Local date at the airport, `YYYY-MM-DD`, or `null` when the text has none.","type":["string","null"]},"time":{"description":"Local time at the airport, `HH:MM` (24 h), or `null`.","type":["string","null"]}},"required":["code","city","airport","terminal","date","time"]},"arrival":{"type":"object","properties":{"code":{"description":"IATA code of the airport.","type":"string"},"city":{"description":"City, or `null`.","type":["string","null"]},"airport":{"description":"Airport name, or `null`.","type":["string","null"]},"terminal":{"description":"Terminal as the PNR prints it (`\"5\"`, `\"2E\"`), or `null`.","type":["string","null"]},"date":{"description":"Local date at the airport, `YYYY-MM-DD`, or `null` when the text has none.","type":["string","null"]},"time":{"description":"Local time at the airport, `HH:MM` (24 h), or `null`.","type":["string","null"]}},"required":["code","city","airport","terminal","date","time"],"description":"The same fields for the arrival airport."}},"required":["airlineCode","airlineName","flightNumber","bookingClass","cabin","status","statusText","logoUrl","duration","distance","aircraftCode","aircraft","operatedBy","airlineLocator","departure","arrival"]}},"itinerary":{"type":"object","properties":{"view":{"description":"The view used.","type":"string"},"text":{"description":"The itinerary as plain text.","type":"string"},"html":{"description":"The itinerary as e-mail HTML (tables, inline styles); `null` for `whatsapp`.","type":["string","null"]}},"required":["view","text","html"]}},"required":["pnrCode","passengers","segments","itinerary"]},"Error":{"type":"object","required":["error","message"],"properties":{"error":{"type":"string","description":"The error code: check this one."},"message":{"type":"string","description":"For people; may change."},"field":{"type":"string","description":"`invalid_option`: the option at fault."},"allowed":{"type":"array","items":{},"description":"`invalid_option`: the values it takes."},"max":{"type":"integer","description":"`too_long`: the longest text in characters."}}}}}}