Skip to content

Scenarios#

What-if simulations of an airport day, compared against a baseline.

The scenario object#

Attributes#

idstringrequired
objectstringrequired
Always scenario.
airportICAO coderequired
An ICAO airport code.
namestringrequired
daystringrequired
windowobjectrequired
The simulated period in UTC, midnight to midnight local time.
Child attributes
fromtimestamprequired
RFC 3339 in UTC, with up to millisecond precision.
totimestamprequired
RFC 3339 in UTC, with up to millisecond precision.
changesarray of runway_closure | taxiway_closure | stand_closure | flight_delayrequired
statusenumrequired
One of queued, running, succeeded, failed.
created_attimestamprequired
RFC 3339 in UTC, with up to millisecond precision.
completed_attimestamp | nullrequired
resultnull | objectrequired
Child attributes
movementsintegerrequired
Arrivals and departures simulated.
duration_msintegerrequired
Wall-clock time for both runs.
baselineobjectrequired
Child attributes
departure_delay_minnumberrequired
Total departure delay against schedule
arrival_delay_minnumberrequired
Total arrival delay against schedule
mean_taxi_out_minnumberrequired
max_departure_queuenumberrequired
Most aircraft waiting for departure at once.
on_time_departure_rationumberrequired
Share of departures within 15 minutes of schedule.
scenarioobjectrequired
Child attributes
departure_delay_minnumberrequired
Total departure delay against schedule
arrival_delay_minnumberrequired
Total arrival delay against schedule
mean_taxi_out_minnumberrequired
max_departure_queuenumberrequired
Most aircraft waiting for departure at once.
on_time_departure_rationumberrequired
Share of departures within 15 minutes of schedule.
differenceobjectrequired
Child attributes
departure_delay_minnumberrequired
Total departure delay against schedule
arrival_delay_minnumberrequired
Total arrival delay against schedule
mean_taxi_out_minnumberrequired
max_departure_queuenumberrequired
Most aircraft waiting for departure at once.
on_time_departure_rationumberrequired
Share of departures within 15 minutes of schedule.
affected_flightsintegerrequired

Scenario object

{
  "id": "scn_5e8c1b72d9",
  "object": "scenario",
  "airport": "VTBS",
  "name": "02R-20L closed 10:00-10:30",
  "day": "2026-11-23",
  "window": {
    "from": "2026-11-22T17:00:00Z",
    "to": "2026-11-23T17:00:00Z"
  },
  "changes": [
    {
      "type": "runway_closure",
      "runway": "runway:02R-20L",
      "from": "2026-11-23T03:00:00Z",
      "until": "2026-11-23T03:30:00Z"
    }
  ],
  "status": "queued",
  "created_at": "2026-11-23T02:59:02Z",
  "completed_at": null,
  "result": null
}

Run a scenario#

POST/v1/scenarios

Simulates one airport day twice, once as planned and once with your changes, and compares the two. The scenario runs asynchronously. A full day at VTBS takes about four seconds. Poll the scenario, stream its progress, or subscribe to the scenario.completed webhook.

Requires scenarios:write.Preview 2

Headers#

Idempotency-Keystring
A unique value, such as a UUID, that makes the request safe to retry for 24 hours.

Request body#

airportICAO coderequired
An ICAO airport code.
namestring
daystring
The local operating day to simulate. Defaults to the day of the first change.
changesarray of runway_closure | taxiway_closure | stand_closure | flight_delayrequired

Response#

202 The scenario was accepted and queued. Returns scenario object.

curl https://api.surfacelens.app/v1/scenarios \
  -H "Authorization: Bearer $SURFACELENS_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "airport": "VTBS",
  "name": "02R-20L closed 10:00-10:30",
  "day": "2026-11-23",
  "changes": [
    {
      "type": "runway_closure",
      "runway": "runway:02R-20L",
      "from": "2026-11-23T03:00:00Z",
      "until": "2026-11-23T03:30:00Z"
    }
  ]
}'
const res = await fetch("https://api.surfacelens.app/v1/scenarios", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SURFACELENS_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    airport: "VTBS",
    name: "02R-20L closed 10:00-10:30",
    day: "2026-11-23",
    changes: [
      {
        type: "runway_closure",
        runway: "runway:02R-20L",
        from: "2026-11-23T03:00:00Z",
        until: "2026-11-23T03:30:00Z",
      },
    ],
  }),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const scenario = await res.json();
import httpx, os, uuid

res = httpx.post(
    "https://api.surfacelens.app/v1/scenarios",
    headers={
        "Authorization": f"Bearer {os.environ['SURFACELENS_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "airport": "VTBS",
        "name": "02R-20L closed 10:00-10:30",
        "day": "2026-11-23",
        "changes": [
            {
                "type": "runway_closure",
                "runway": "runway:02R-20L",
                "from": "2026-11-23T03:00:00Z",
                "until": "2026-11-23T03:30:00Z",
            },
        ],
    },
)
res.raise_for_status()
scenario = res.json()

Response202

{
  "id": "scn_5e8c1b72d9",
  "object": "scenario",
  "airport": "VTBS",
  "name": "02R-20L closed 10:00-10:30",
  "day": "2026-11-23",
  "window": {
    "from": "2026-11-22T17:00:00Z",
    "to": "2026-11-23T17:00:00Z"
  },
  "changes": [
    {
      "type": "runway_closure",
      "runway": "runway:02R-20L",
      "from": "2026-11-23T03:00:00Z",
      "until": "2026-11-23T03:30:00Z"
    }
  ],
  "status": "queued",
  "created_at": "2026-11-23T02:59:02Z",
  "completed_at": null,
  "result": null
}

Retrieve a scenario#

GET/v1/scenarios/{scenario}

Returns the scenario. Once status is succeeded, result holds the baseline, the scenario and the difference between them.

Requires scenarios:read.Preview 2

Path parameters#

scenariostringrequired
The scenario ID.

Response#

200 The scenario. Returns scenario object.

curl https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9 \
  -H "Authorization: Bearer $SURFACELENS_KEY"
const res = await fetch("https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9", {
  headers: { Authorization: `Bearer ${process.env.SURFACELENS_KEY}` },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const scenario = await res.json();
import httpx, os

res = httpx.get(
    "https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9",
    headers={"Authorization": f"Bearer {os.environ['SURFACELENS_KEY']}"},
)
res.raise_for_status()
scenario = res.json()

Response200

{
  "id": "scn_5e8c1b72d9",
  "object": "scenario",
  "airport": "VTBS",
  "name": "02R-20L closed 10:00-10:30",
  "day": "2026-11-23",
  "window": {
    "from": "2026-11-22T17:00:00Z",
    "to": "2026-11-23T17:00:00Z"
  },
  "changes": [
    {
      "type": "runway_closure",
      "runway": "runway:02R-20L",
      "from": "2026-11-23T03:00:00Z",
      "until": "2026-11-23T03:30:00Z"
    }
  ],
  "status": "succeeded",
  "created_at": "2026-11-23T02:59:02Z",
  "completed_at": "2026-11-23T02:59:06.214Z",
  "result": {
    "movements": 1046,
    "duration_ms": 3870,
    "baseline": {
      "departure_delay_min": 2184,
      "arrival_delay_min": 1312,
      "mean_taxi_out_min": 16.8,
      "max_departure_queue": 9,
      "on_time_departure_ratio": 0.812
    },
    "scenario": {
      "departure_delay_min": 3047,
      "arrival_delay_min": 1690,
      "mean_taxi_out_min": 18.1,
      "max_departure_queue": 17,
      "on_time_departure_ratio": 0.774
    },
    "difference": {
      "departure_delay_min": 863,
      "arrival_delay_min": 378,
      "mean_taxi_out_min": 1.3,
      "max_departure_queue": 8,
      "on_time_departure_ratio": -0.038
    },
    "affected_flights": 71
  }
}

List affected flights#

GET/v1/scenarios/{scenario}/flights

Returns flights whose times differ between baseline and scenario, largest delay first.

Requires scenarios:read.Preview 2

Path parameters#

scenariostringrequired
The scenario ID.

Query parameters#

limitinteger
Page size, from 1 to 500. Default 100.
cursorstring
The next_cursor from the previous page. Other parameters must not change between pages. Cursors expire after one hour.

Response#

200 A page of affected flights.

objectstringrequired
Always list.
dataarray of objectsrequired
Child attributes
flightentity IDrequired
type:key. The key is stable for the life of the entity.
directionenumrequired
One of arrival, departure.
baselineobjectrequired
Child attributes
off_block_attimestamp
RFC 3339 in UTC, with up to millisecond precision.
on_block_attimestamp
RFC 3339 in UTC, with up to millisecond precision.
runwayentity IDrequired
type:key. The key is stable for the life of the entity.
runway_attimestamprequired
RFC 3339 in UTC, with up to millisecond precision.
scenarioobjectrequired
Child attributes
off_block_attimestamp
RFC 3339 in UTC, with up to millisecond precision.
on_block_attimestamp
RFC 3339 in UTC, with up to millisecond precision.
runwayentity IDrequired
type:key. The key is stable for the life of the entity.
runway_attimestamprequired
RFC 3339 in UTC, with up to millisecond precision.
delay_minintegerrequired
Scenario minus baseline at the runway.
reasonenumrequired
One of runway_closure, taxiway_closure, stand_closure, flight_delay, knock_on.
next_cursorstring | nullrequired
Pass as cursor to fetch the next page. Null on the last page.
curl -G https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/flights \
  -H "Authorization: Bearer $SURFACELENS_KEY" \
  -d limit=2
const res = await fetch("https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/flights?limit=2", {
  headers: { Authorization: `Bearer ${process.env.SURFACELENS_KEY}` },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const page = await res.json();
import httpx, os

res = httpx.get(
    "https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/flights",
    params={
        "limit": "2",
    },
    headers={"Authorization": f"Bearer {os.environ['SURFACELENS_KEY']}"},
)
res.raise_for_status()
page = res.json()

Response200

{
  "object": "list",
  "data": [
    {
      "flight": "flight:TG403-20261123",
      "direction": "departure",
      "baseline": {
        "off_block_at": "2026-11-23T03:31:00Z",
        "runway": "runway:02R-20L",
        "runway_at": "2026-11-23T03:47:00Z"
      },
      "scenario": {
        "off_block_at": "2026-11-23T03:31:00Z",
        "runway": "runway:02R-20L",
        "runway_at": "2026-11-23T04:16:00Z"
      },
      "delay_min": 29,
      "reason": "knock_on"
    },
    {
      "flight": "flight:TG102-20261123",
      "direction": "departure",
      "baseline": {
        "off_block_at": "2026-11-23T03:05:00Z",
        "runway": "runway:02R-20L",
        "runway_at": "2026-11-23T03:19:00Z"
      },
      "scenario": {
        "off_block_at": "2026-11-23T03:05:00Z",
        "runway": "runway:02L-20R",
        "runway_at": "2026-11-23T03:44:00Z"
      },
      "delay_min": 25,
      "reason": "runway_closure"
    }
  ],
  "next_cursor": "c_7a20e4f1b95d3c68"
}

Stream scenario progress#

GET/v1/scenarios/{scenario}/events

Opens a server-sent events stream of scenario.progress events, then one scenario.succeeded or scenario.failed event, then closes.

Requires scenarios:read.Preview 2

Path parameters#

scenariostringrequired
The scenario ID.

Response#

200 An event stream that closes when the scenario finishes.

curl -N https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/events \
  -H "Authorization: Bearer $SURFACELENS_KEY"
const res = await fetch(
  "https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/events",
  { headers: { Authorization: `Bearer ${process.env.SURFACELENS_KEY}` } },
);
for await (const chunk of res.body!.pipeThrough(new TextDecoderStream())) {
  process.stdout.write(chunk);
}
import os, httpx

url = "https://api.surfacelens.app/v1/scenarios/scn_5e8c1b72d9/events"
headers = {"Authorization": f"Bearer {os.environ['SURFACELENS_KEY']}"}

with httpx.stream("GET", url, headers=headers, timeout=None) as res:
    for line in res.iter_lines():
        if line:
            print(line)

Response200

event: scenario.progress
data: {"scenario":"scn_5e8c1b72d9","run":"baseline","simulated_until":"2026-11-23T05:00:00Z","ratio":0.25}

event: scenario.progress
data: {"scenario":"scn_5e8c1b72d9","run":"scenario","simulated_until":"2026-11-23T17:00:00Z","ratio":1}

event: scenario.succeeded
data: {"scenario":"scn_5e8c1b72d9","duration_ms":3870,"affected_flights":71}