{"servers":[{"url":"https://ws.airplate.dk","description":"AirPlate API"}],"info":{"title":"AirPlate API","description":"AirPlate's reference for third-party integrators. Every operation here authenticates with an organization API key issued by AirPlate and only ever returns that organization's data.\n\n**Base URL** — `https://ws.airplate.dk`. All three surfaces live on this host.\n\n**Authentication** — REST and the event stream take the key in an `api-key` header. The live WebSocket takes it as the `x-api-key` query parameter, because a browser cannot set headers on an upgrade request. A missing or invalid key answers `401` with a JSON body `{ \"error\": \"...\" }`.\n\n**Surfaces**\n- `GET /api/v1/organization_scanners` — the organization's scanners (REST).\n- `GET /api/v1/events/scanners` — server-sent events when a scanner checks in, changes status, is added to the organization or moves.\n- `GET /scanning` — WebSocket with live drone detections from the organization's scanners.\n\n**Limits and conventions** — REST calls are rate-limited per key (60 per minute by default); over the limit you get `429` with a `Retry-After` header. All surfaces are server-to-server: the api's CORS policy does not allow the `api-key` header, so call from your backend rather than from a web page. Encrypted (OcuSync) detections reach the WebSocket only once AirPlate has enabled that opt-in for your organization.","version":"1.0.0"},"tags":[{"name":"Public API","description":"Third-party integrator surface: api-key authenticated REST, server-sent events and the live detection WebSocket"}],"x-tagGroups":[{"name":"Integrations","tags":["Public API"]}],"paths":{"/api/v1/organization_scanners":{"get":{"tags":["Public API"],"x-access":"third-party","summary":"List the scanners of the API key's organization","description":"Authenticate with an `api-key` header. The organization is resolved from the key server-side; only that organization's scanners are returned. Server-to-server only (CORS does not allow the api-key header). Returns 404 when the organization has no scanners.\n\n**Fields.** The response is an array with one object per scanner:\n- `IMEI` — the scanner's id; the event stream's events carry the same value.\n- `name` — your organization's name for the scanner.\n- `last_seen` — when the scanner last checked in.\n- `charging`, `batteryVoltage` — its power state at that check-in.\n- `signal_bars` — its cellular signal at that check-in, 0–4; `null` if it has never reported one.\n- `latitude`, `longitude` — its last reported position; both 0 when none is known.\n- `location` — the place name for that position; empty when none is known.","security":[{"apiKey":[]}],"operationId":"getApiV1Organization_scanners"}},"/api/v1/events/scanners":{"get":{"tags":["Public API"],"x-access":"third-party","security":[{"apiKey":[]}],"operationId":"streamOrganizationScannerEvents","summary":"Stream scanner events for the API key's organization (SSE)","description":"Server-sent events (`text/event-stream`) for the organizations your key belongs to — the event twin of `GET /api/v1/organization_scanners`. Authenticate with the `api-key` header. Server-to-server only: there is no CORS, and a browser `EventSource` cannot set headers anyway.\n\n**Framing.** The stream opens with the comment `: connected` and a `retry: 3000` hint, then sends a `: keepalive` comment every 25 s while idle. Every event carries an `id:` (a per-organization sequence), an `event:` name and one JSON `data:` line.\n\n**Events.**\n- `sensor_checkin` — a scanner checked in; use it as the scanner's heartbeat: `{ schemaVersion: 1, event, organization_id, IMEI, last_seen, status, charging, batteryVoltage, signal_bars }`. `last_seen` is the check-in time (ISO 8601 UTC), `status` is `active`, `signal_bars` is 0–4.\n- `sensor_status` — a scanner's status changed because it stopped checking in; same fields. `status` becomes `missed_checkin` 30 minutes after the last check-in, `stale` after 4 hours and `inactive` after 7 days; `last_seen` is still that last check-in. The next `sensor_checkin` means it is back.\n- `scanner_added` — a scanner was linked to the organization: `{ schemaVersion: 1, event, organization_id, IMEI, name, added_at }` (`added_at` is ISO 8601 UTC).\n- `scanner_moved` — a scanner's reported GPS position left the jitter envelope around its confirmed anchor: `{ schemaVersion: 1, event, organization_id, IMEI, latitude, longitude, previous_latitude, previous_longitude, distance_m, moved_at }`.\n\nNewer producers may add event kinds; ignore names you do not know.\n\n**Current state.** The stream sends no snapshot when it opens. Read `GET /api/v1/organization_scanners` once for each scanner's name and latest `last_seen`, then join the events on `IMEI`. Do the same after a reconnect that could not replay: a `sensor_status` you missed is not sent again.\n\n**Reconnecting.** Send the last `id` you saw as `Last-Event-ID` and the missed events are replayed — for keys that belong to exactly one organization (ids are per organization, so a multi-organization key gets no replay). If the server's sequence was reset in between, the stream says so with a `: replay-reset` comment and replays everything it still holds; reconcile older state through the REST endpoint.","parameters":[{"name":"Last-Event-ID","in":"header","required":false,"schema":{"type":"string"},"description":"The last event `id` you processed; replays what you missed (single-organization keys)."}],"responses":{"200":{"description":"An open `text/event-stream`; the frames are described above.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Missing or invalid API key — `{ \"error\": \"API key required\" }` or `{ \"error\": \"Invalid API key\" }`."}}}},"/scanning":{"get":{"tags":["Public API"],"x-access":"third-party","security":[{"apiKeyQuery":[]}],"operationId":"connectLiveDetections","summary":"Live drone detections for the API key's organization (WebSocket)","servers":[{"url":"wss://ws.airplate.dk","description":"WebSocket gateway"}],"x-codeSamples":[{"lang":"shell","label":"curl (8.11+)","source":"# curl 8.11 or newer speaks WebSocket (macOS's bundled curl does not).\n# -N streams frames to stdout as they arrive; -T . lets you type messages on stdin.\ncurl --no-progress-meter -N -T . 'wss://ws.airplate.dk/scanning?organization_id=ORGANIZATION_ID&x-api-key=YOUR_API_KEY'"},{"lang":"shell","label":"wscat","source":"# npm i -g wscat\nwscat -c 'wss://ws.airplate.dk/scanning?organization_id=ORGANIZATION_ID&x-api-key=YOUR_API_KEY'"},{"lang":"javascript","label":"Node (ws)","source":"import WebSocket from \"ws\";\n\nconst ws = new WebSocket(\"wss://ws.airplate.dk/scanning?organization_id=ORGANIZATION_ID&x-api-key=YOUR_API_KEY\");\nws.on(\"message\", (data) => {\n  const text = data.toString();\n  if (text === \"Connected\") return; // session is up\n  try {\n    console.log(JSON.parse(text)); // one detection frame\n  } catch {\n    // non-JSON text = heartbeat, ignore\n  }\n});\nws.on(\"close\", (code, reason) => console.log(\"closed\", code, reason.toString()));"},{"lang":"python","label":"Python (websockets)","source":"import asyncio, json, websockets\n\nasync def main():\n    async with websockets.connect(\"wss://ws.airplate.dk/scanning?organization_id=ORGANIZATION_ID&x-api-key=YOUR_API_KEY\") as ws:\n        async for msg in ws:\n            if msg == \"Connected\":\n                continue  # session is up\n            try:\n                print(json.loads(msg))  # one detection frame\n            except ValueError:\n                pass  # non-JSON text = heartbeat\n\nasyncio.run(main())"}],"description":"A WebSocket, not an HTTP GET. Connect to\n\n`wss://ws.airplate.dk/scanning?organization_id=<id>&x-api-key=<key>`\n\nThe samples on the right use that URL (the curl one needs curl 8.11 or newer, which speaks WebSocket natively). The key travels in the `x-api-key` query parameter (an upgrade request from a browser cannot carry headers) and `organization_id` must be the organization the key belongs to.\n\n**Session.** The first message is the plain text `Connected` — authentication and permissions are in place. Every later JSON message is one detection frame from one of the organization's scanners. Ignore any non-JSON text frame (heartbeat).\n\n**Messages.** After `Connected`, every JSON message is one frame. The response panel documents the shapes and holds one example of each; `type` tells them apart: `scanned_DRI` (a Remote ID detection) and `DJI` (an OcuSync detection, `encrypted` true or false) share the detection shape; `EncryptedOcusync` and `EncryptedOcusyncLost` are the encrypted ring frames, delivered only once AirPlate has enabled the third-party opt-in for your organization. The gateway adds `_serverSeq` (a running counter that starts over when the gateway restarts, so a lower value after a reconnect is normal), `subscription_id` when the frame reached you through a subscription area, and `approvedStatus` / `watchlistStatus` evaluated for your organization. Ignore any non-JSON text frame (heartbeat).\n\n**Close codes.** `4001` invalid key, organization or origin; `4002` missing `organization_id`; `4401` permissions revoked — the key's access changed, check with AirPlate before reconnecting; `1011` the server failed to load permissions — reconnect with backoff; `1001` the gateway is restarting and `1013` your client fell too far behind reading — reconnect with backoff. A connection that ends without a close frame (your library reports `1006`, e.g. a network drop): reconnect with backoff then too.","parameters":[{"name":"organization_id","in":"query","required":true,"schema":{"type":"integer"},"description":"The organization the key belongs to. Missing → close code 4002; not the key's organization → 4001."}],"responses":{"101":{"description":"Switching Protocols — the socket is open; the first message is the text `Connected`. There is no HTTP body: documented here is the stream of JSON messages that follows.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/DetectionFrame"},{"$ref":"#/components/schemas/EncryptedOcusyncFrame"},{"$ref":"#/components/schemas/EncryptedOcusyncLostFrame"}],"discriminator":{"propertyName":"type","mapping":{"scanned_DRI":"#/components/schemas/DetectionFrame","DJI":"#/components/schemas/DetectionFrame","EncryptedOcusync":"#/components/schemas/EncryptedOcusyncFrame","EncryptedOcusyncLost":"#/components/schemas/EncryptedOcusyncLostFrame"}}},"examples":{"scanned_DRI":{"summary":"scanned_DRI — Remote ID detection","value":{"type":"scanned_DRI","encrypted":false,"identification":{"mac_address":"f2:4d:48:53:b7:e5","imei_scanner":"352709570880989"},"operator":{"operatorID":"DNK000002690537g","operatorID_type":0,"location":{"latitude":55.4051,"longitude":10.3812,"operator_location_type":1}},"uas":{"uas_id":"1581F2382388123823872","ua_type":2,"classification_type":1,"class_eu":1,"manufacturer":"DJI","model":"Mavic 3","identificationConfidence":"high","identificationSource":"serial_range"},"operation":{"operation_status":1,"operation_category_eu":1},"location":{"latitude":55.4048004,"longitude":10.3809614},"altitude":{"value":42,"altitude_type":1,"reference":"AGL","unit":"meter"},"altitude_geo":{"value":61.5,"unit":"meter","reference":"WGS84"},"heading":{"value":49,"unit":"degrees"},"speed":{"value":2.5,"unit":"m/s"},"time":{"deviceTime":1720011085,"unit":"seconds"},"_serverSeq":1042,"approvedStatus":{"triggerAlarm":true,"showOnMap":true,"isApprovedDrone":false,"approvedDroneNote":null},"watchlistStatus":{"isWatchlisted":false,"watchlistNote":null}}},"DJI":{"summary":"DJI — OcuSync detection","value":{"type":"DJI","encrypted":false,"identification":{"mac_address":"55.404800400000000:10.380961400000000","imei_scanner":"352709570880989"},"operator":{"operatorID":"","operatorID_type":0,"location":{"latitude":55.4048004,"longitude":10.3809614,"operator_location_type":0}},"uas":{"uas_id":"DJI Mini 2","ua_type":2,"classification_type":0,"class_eu":0,"manufacturer":"DJI","model":"Mini 2","identificationConfidence":"reported","identificationSource":"ocusync_model"},"operation":{"operation_status":0,"operation_category_eu":0},"location":{"latitude":55.4052,"longitude":10.3821},"altitude":{"value":35,"altitude_type":0,"reference":"AGL","unit":"meter"},"heading":{"value":0,"unit":"degrees"},"speed":{"value":0,"unit":"m/s"},"time":{"deviceTime":1720011091,"unit":"seconds"},"_serverSeq":1043,"approvedStatus":{"triggerAlarm":true,"showOnMap":true,"isApprovedDrone":false,"approvedDroneNote":null},"watchlistStatus":{"isWatchlisted":false,"watchlistNote":null}}},"EncryptedOcusync":{"summary":"EncryptedOcusync — encrypted ring (opt-in)","value":{"type":"EncryptedOcusync","ring_id":"Encrypted:352709570880989","identification":{"mac_address":"Encrypted:352709570880989","imei_scanner":"352709570880989"},"ppm":3.2,"radius_m":850,"sensor_lat":55.4048,"sensor_lon":10.3809,"encrypted":true,"last_seen_age_s":0.4,"last_seen_ms":1720011085400,"calibration_basis":"sensor","_serverSeq":1044,"approvedStatus":{"triggerAlarm":true,"showOnMap":true,"isApprovedDrone":false,"approvedDroneNote":null},"watchlistStatus":{"isWatchlisted":false,"watchlistNote":null}}},"EncryptedOcusyncLost":{"summary":"EncryptedOcusyncLost — ring gone","value":{"type":"EncryptedOcusyncLost","ring_id":"Encrypted:352709570880989","identification":{"mac_address":"Encrypted:352709570880989","imei_scanner":"352709570880989"},"_serverSeq":1045,"approvedStatus":{"triggerAlarm":true,"showOnMap":true,"isApprovedDrone":false,"approvedDroneNote":null},"watchlistStatus":{"isWatchlisted":false,"watchlistNote":null}}}}}}}}}}},"components":{"schemas":{"DetectionFrame":{"type":"object","description":"One detection. `scanned_DRI` is a Remote ID broadcast; `DJI` is an OcuSync detection, in which case `operator.operatorID` is empty, `uas.uas_id` is the device type, `heading`/`speed` are 0 and `altitude_geo` is absent. With `encrypted: true` the positions are 0 — the EncryptedOcusync frame is what an encrypted detection actually carries.","properties":{"type":{"type":"string","enum":["scanned_DRI","DJI"]},"encrypted":{"type":"boolean"},"identification":{"type":"object","properties":{"mac_address":{"type":"string","description":"Remote ID: the drone's MAC. OcuSync: the take-off point as `<lat>:<lon>` (15 decimals). Encrypted rings: `Encrypted:<imei>`."},"imei_scanner":{"type":"string","description":"IMEI of the reporting scanner."}},"required":["mac_address","imei_scanner"]},"operator":{"type":"object","properties":{"operatorID":{"type":"string"},"operatorID_type":{"type":"integer"},"location":{"type":"object","properties":{"latitude":{"type":"number"},"longitude":{"type":"number"},"operator_location_type":{"type":"integer"}},"required":["latitude","longitude","operator_location_type"]}},"required":["operatorID","operatorID_type","location"]},"uas":{"type":"object","properties":{"uas_id":{"type":"string"},"ua_type":{"type":"integer"},"classification_type":{"type":"integer"},"class_eu":{"type":"integer"},"manufacturer":{"type":"string","nullable":true},"model":{"type":"string","nullable":true},"identificationConfidence":{"type":"string","enum":["high","medium","low","reported","unknown"]},"identificationSource":{"type":"string","enum":["exact_serial","serial_range","curated_rule","manufacturer_code","ocusync_model","unknown"],"description":"How manufacturer/model were derived."}},"required":["uas_id","ua_type","classification_type","class_eu","manufacturer","model","identificationConfidence","identificationSource"]},"operation":{"type":"object","properties":{"operation_status":{"type":"integer"},"operation_category_eu":{"type":"integer"}},"required":["operation_status","operation_category_eu"]},"location":{"type":"object","description":"The drone's position.","properties":{"latitude":{"type":"number"},"longitude":{"type":"number"}},"required":["latitude","longitude"]},"altitude":{"type":"object","properties":{"value":{"type":"number"},"unit":{"type":"string","enum":["meter"]},"altitude_type":{"type":"integer"},"reference":{"type":"string","enum":["Above Take-off","AGL"]}},"required":["value","unit"]},"altitude_geo":{"type":"object","properties":{"value":{"type":"number"},"unit":{"type":"string","enum":["meter"]},"reference":{"type":"string","enum":["WGS84"]}},"required":["value","unit"]},"heading":{"type":"object","properties":{"value":{"type":"number"},"unit":{"type":"string","enum":["degrees"]}},"required":["value","unit"]},"speed":{"type":"object","properties":{"value":{"type":"number"},"unit":{"type":"string","enum":["m/s"]}},"required":["value","unit"]},"time":{"type":"object","properties":{"deviceTime":{"type":"integer","description":"Unix seconds."},"unit":{"type":"string","enum":["seconds"]}},"required":["deviceTime","unit"]},"_serverSeq":{"type":"integer","description":"Monotonic sequence number the gateway assigns per broadcast; gaps are frames you were not entitled to."},"subscription_id":{"oneOf":[{"type":"integer"},{"type":"string"}],"description":"Present only when the frame reached you through a subscription area rather than one of your own scanners."},"approvedStatus":{"type":"object","description":"Your organization's approved-drones list, evaluated for this frame.","properties":{"triggerAlarm":{"type":"boolean"},"showOnMap":{"type":"boolean"},"isApprovedDrone":{"type":"boolean"},"approvedDroneNote":{"type":"string","nullable":true}},"required":["triggerAlarm","showOnMap","isApprovedDrone","approvedDroneNote"]},"watchlistStatus":{"type":"object","description":"Your organization's watchlist, evaluated for this frame.","properties":{"isWatchlisted":{"type":"boolean"},"watchlistNote":{"type":"string","nullable":true}},"required":["isWatchlisted","watchlistNote"]}},"required":["type","encrypted","identification","operator","uas","operation","location","altitude","heading","speed","time","_serverSeq"]},"EncryptedOcusyncFrame":{"type":"object","description":"An encrypted OcuSync ring: the drone cannot be decoded, only ranged. Delivered only once AirPlate has enabled the third-party opt-in for your organization. No `location` field.","properties":{"type":{"type":"string","enum":["EncryptedOcusync"]},"ring_id":{"type":"string","description":"`Encrypted:<imei>` — stable for the ring's lifetime. On a subscription-area delivery (`subscription_id` set) the sensor is an AirPlate pool sensor and `<imei>`, `identification.imei_scanner` and `identification.mac_address` carry a stable alias instead."},"identification":{"type":"object","properties":{"mac_address":{"type":"string","description":"Remote ID: the drone's MAC. OcuSync: the take-off point as `<lat>:<lon>` (15 decimals). Encrypted rings: `Encrypted:<imei>`."},"imei_scanner":{"type":"string","description":"IMEI of the reporting scanner."}},"required":["mac_address","imei_scanner"]},"ppm":{"type":"number"},"radius_m":{"type":"number","description":"Estimated distance from the sensor, metres."},"sensor_lat":{"type":"number"},"sensor_lon":{"type":"number"},"encrypted":{"type":"boolean","enum":[true]},"last_seen_age_s":{"type":"number","description":"Age of the underlying packet when this frame was sent, seconds."},"last_seen_ms":{"type":"integer","description":"Server epoch millis of the ring's last packet."},"calibration_basis":{"type":"string","enum":["sensor","fleet","none"],"description":"Which calibration produced `radius_m`; render `fleet` rings softened."},"_serverSeq":{"type":"integer","description":"Monotonic sequence number the gateway assigns per broadcast; gaps are frames you were not entitled to."},"subscription_id":{"oneOf":[{"type":"integer"},{"type":"string"}],"description":"Present only when the frame reached you through a subscription area rather than one of your own scanners."},"approvedStatus":{"type":"object","description":"Your organization's approved-drones list, evaluated for this frame.","properties":{"triggerAlarm":{"type":"boolean"},"showOnMap":{"type":"boolean"},"isApprovedDrone":{"type":"boolean"},"approvedDroneNote":{"type":"string","nullable":true}},"required":["triggerAlarm","showOnMap","isApprovedDrone","approvedDroneNote"]},"watchlistStatus":{"type":"object","description":"Your organization's watchlist, evaluated for this frame.","properties":{"isWatchlisted":{"type":"boolean"},"watchlistNote":{"type":"string","nullable":true}},"required":["isWatchlisted","watchlistNote"]}},"required":["type","ring_id","identification","ppm","radius_m","sensor_lat","sensor_lon","encrypted","last_seen_age_s","last_seen_ms","_serverSeq"]},"EncryptedOcusyncLostFrame":{"type":"object","description":"The encrypted ring with this `ring_id` has gone silent; remove it.","properties":{"type":{"type":"string","enum":["EncryptedOcusyncLost"]},"ring_id":{"type":"string"},"identification":{"type":"object","properties":{"mac_address":{"type":"string","description":"Remote ID: the drone's MAC. OcuSync: the take-off point as `<lat>:<lon>` (15 decimals). Encrypted rings: `Encrypted:<imei>`."},"imei_scanner":{"type":"string","description":"IMEI of the reporting scanner."}},"required":["mac_address","imei_scanner"]},"_serverSeq":{"type":"integer","description":"Monotonic sequence number the gateway assigns per broadcast; gaps are frames you were not entitled to."},"subscription_id":{"oneOf":[{"type":"integer"},{"type":"string"}],"description":"Present only when the frame reached you through a subscription area rather than one of your own scanners."},"approvedStatus":{"type":"object","description":"Your organization's approved-drones list, evaluated for this frame.","properties":{"triggerAlarm":{"type":"boolean"},"showOnMap":{"type":"boolean"},"isApprovedDrone":{"type":"boolean"},"approvedDroneNote":{"type":"string","nullable":true}},"required":["triggerAlarm","showOnMap","isApprovedDrone","approvedDroneNote"]},"watchlistStatus":{"type":"object","description":"Your organization's watchlist, evaluated for this frame.","properties":{"isWatchlisted":{"type":"boolean"},"watchlistNote":{"type":"string","nullable":true}},"required":["isWatchlisted","watchlistNote"]}},"required":["type","ring_id","identification","_serverSeq"]}},"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Organization API key issued by AirPlate; the request is scoped to the key's organization. The credential of the third-party surface (`/api/v1/*`), and accepted there only: other routes are for signed-in sessions. Server-to-server: CORS does not allow the header."},"apiKeyQuery":{"type":"apiKey","in":"query","name":"x-api-key","description":"The same organization API key as the `x-api-key` query parameter — the live WebSocket (`/scanning`) reads it from the URL only, because a browser cannot set headers on an upgrade request."}}},"openapi":"3.1.2"}