Create a subscription
create_subscriptionWatch a specific flight and receive signed webhook POSTs for every status, gate, terminal, delay, or baggage change until the flight ends. Relay the returned signing secret to the user.
Instructions
Watch a flight: FlightByte polls it on an adaptive schedule and POSTs a signed webhook to webhookUrl for every change (status, gates, terminals, times, delays, departure, arrival, baggage carousel, cancellation, diversion, aircraft, route, codeshares) until the flight is over. Each new subscription counts as a watched flight on the user's plan (Free: 3 per month) and starts outbound requests to the URL, so only call this when the user asked to watch or be notified about a specific flight and gave the webhook URL. If the flight number operates more than one leg that day the call is refused with the list of legs: pass origin. Flights up to seven days ahead are accepted and wait as pending until published. The response includes the signing secret in full; this is the only time it is shown, so relay it to the user to store for webhook signature verification. Pass Idempotency-Key to make a retry return the same subscription.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Local departure date at the origin airport, YYYY-MM-DD. A flight that leaves at 23:50 and lands the next morning belongs to the day it left. Live records cover a few days back to about two days ahead. | |
| events | No | Change types to deliver; omit to deliver all 23. Common picks: "flight.departed", "flight.arrived", "flight.cancelled", "flight.diverted", "departure.gate.changed", "arrival.baggage.changed", "delay.increased". | |
| origin | No | Departure airport, IATA code (e.g. "IST"; the upstream code such as "ISL" also works). Picks the leg when the flight number operates more than one leg that day. | |
| secret | No | Bring your own signing secret, only when the user explicitly provides one their receiver already uses. Normally omit it: FlightByte generates one and returns it once. | |
| carrier | Yes | Airline code: the 2-character IATA code (e.g. "TK") or 3-character ICAO code (e.g. "THY"). For flight "TK1848" this is "TK". | |
| headers | No | Extra HTTP headers sent with every delivery, e.g. {"Authorization": "Bearer <receiver token>"}. | |
| flightId | No | Exact leg pick: a providerFlightId from a previous response's `alternates`, or a flightId from an error's list of legs. | |
| metadata | No | String map echoed back in every webhook, e.g. {"bookingId": "BK-1042"}. Use it to tie deliveries to your own records. | |
| webhookUrl | Yes | The user's public http(s) endpoint that receives a signed POST for every change. Addresses that resolve to private, loopback or link-local ranges are refused. Never invent one. | |
| destination | No | Arrival airport, IATA code (e.g. "JFK"). Narrows further when several legs leave the same airport. | |
| flightNumber | Yes | Flight number without the airline code: 1 to 4 digits and an optional letter suffix. For "TK1848" this is "1848". Leading zeros are ignored. | |
| Idempotency-Key | No | Any unique string (e.g. a UUID). Replaying the same key within 24 hours returns the original subscription instead of creating a second one. | |
| delayThresholdMinutes | No | Delay changes smaller than this many minutes are not delivered. 1 to 240; the default is 1. |