FlyghtEdge · Flyght Cloud
Documentation
From installing the library to a device you watch and control from anywhere, step by step.
Cloud · 01
Monitor
Live values, history and the fleet at a glance.
dev.page("Monitor", "activity")
.gauge("temp", "Temperature", "°C", 0, 50)
.chart("hist", "History", "°C", 90).every(2000).size(2)
.value("power", "Power", "W").decimals(0).icon("zap");
dev.ui().set("temp", 24.5); // from loop(): pushed live to browsers, MQTT and the cloud- Devices lists every device with its status, last seen and a live card; the device page shows its pages and widgets with values that move as the device reports them.
- The history chart shows 1 hour, 24 hours, 7 or 30 days of a numeric widget, drawn from the numbers the device reported (up to 500 points), with the same numbers as a table.
- Raw numbers are kept 30 days and hourly summaries 400 days. At most 64 widgets of a device are recorded.
- Overview counts your fleet: online, offline, needing attention. The bell tells you when a device connects, drops or is cut off.
How a value gets there
| Topic | Payload |
|---|---|
| flyght/<DEVICE_ID>/status | online / offline (retained, last will) |
| flyght/<DEVICE_ID>/state/<widget> | ON / OFF, a number or text |
DEVICE_ID is the board’s 12 hex digits in upper case. The browser never talks to the broker: the server relays the values over a live connection with the page’s own session.
Cloud · 02
Control
From a tap on the dashboard to a pin on the board.
dev.page("Control", "sliders")
.toggle("pump", "Pump", [](bool on) { digitalWrite(PUMP, on); })
.slider("fan", "Fan", 0, 100, 5, [](float v) { analogWrite(FAN, v * 2.55); }).unit("%")
.select("mode", "Mode", {"Auto", "Manual", "Away"}, [](const String& m) { /* ... */ })
.button("bell", "Ring", [] { /* ... */ });What happens to a command
- You change a widget in the dashboard.
- The server checks that you may control this device, checks the value against the widget the device described, limits how often, and writes it to the audit log.
- It publishes flyght/<DEVICE_ID>/set/<widget> (or hands it to the device over HTTPS if the device uses the fallback).
- Your callback runs on the board, and the device reports its new state, which the dashboard shows.
- A command is never retained: a device that was offline does not wake up and obey an old order. A command waits 60 seconds (10 for a button) and then expires.
- The latest command per widget wins; an older one still waiting is replaced.
- A value that does not fit the widget (a slider out of range, an option that is not there) is refused before it is sent.
Who may do what
| Role on a folder | May |
|---|---|
| viewer | See devices and values |
| operator | Also send commands |
| admin | Also manage the folder, its members and its dashboard |
| owner | Everything in the workspace, including keys |
Cloud · 03
Folders, dashboards and members
From one board to a fleet.
- Explorer is a tree: your workspace, folders of types (site, area, chamber, group, unit; starter packs add Agriculture, Fleet, Factory and Personal types) and devices. A device lands in the folder its key points to, or in the root as "unsorted".
- Every widget of a device is a point under it. Search points, group them, save a search as a view.
- Dashboards are your own pages of widgets on a 12 column grid: drag with the mouse or move with the keyboard, bind a tile to a widget, a subtopic or a point.
- A folder has its own dashboard, or shows the template of its type. Its items are bound by name: a slot is the point of that name below the folder, a roll-up the average, lowest or highest of every point of that name.
- Members: give an email address viewer, operator or admin on a folder; it covers everything below. The person signs in with that verified email.
- Bulk: create many keys at once from a CSV with a folder path for each, and move many items together.
Cloud · 04
License check-in
How a device learns what its license is now.
About once a day a device asks the server about its license and gets a short statement: active, update period ended, or revoked, valid for 30 days. The device verifies the answer before it believes it.
- A revoked license cuts the cloud for that device and nothing else: every local feature keeps working.
- A device is never blocked because the server could not be reached; it carries on with its last statement.
- The device page shows the last check-in and what it was told (owner only).
Cloud · 05
Cloud API: the rules
Base address, credentials, envelope, errors, headers and limits.
Every call is under https://<site>/api/v1, where <site> is this site’s address. Bodies and answers are JSON.
Who may call
| Credential | Used by | How you get it |
|---|---|---|
| Session cookie | The dashboard (a signed-in person) | Signing in with Google or an email link; the browser exchanges the sign-in for an HttpOnly cookie. Sessions last up to 7 days. |
Device token fnd_... | A claimed device | Returned once by POST /device/claim. The server keeps only a keyed hash of it. |
License key fnk_live_... | The claim call only | Made in the key registry. It identifies a license; it cannot call user endpoints. |
Answers and errors
- Success:
{"data": ...}, and for lists{"data": [...], "meta": {"total", "page", "pageSize", "pages"}}. Lists take?page(default 1) and?pageSize(1 to 100, default 20). Every answer isCache-Control: no-store. - Failure: the status and
{"error": {"code": "snake_case", "message": "..."}}. The message is in your language (cookieflyght_langor Accept-Language); branch oncode. - Something that is not yours is
404 not_found, not 403. A role that is too low is403 forbidden.
| Status | Codes |
|---|---|
| 400 | invalid_request |
| 401 | unauthenticated, session_expired, recent_login_required, invalid_token, invalid_key |
| 403 | forbidden, csrf_rejected, email_not_verified, account_disabled, license_revoked, device_blocked, role_too_high |
| 404, 409 | not_found; free_key_limit, workspace_limit, workspace_not_empty, device_limit, device_owned_elsewhere, reclaim_requires_approval, request_in_progress, device_offline, already_revoked, asset_not_empty, relation_exists |
| 412, 428 | version_conflict; precondition_required |
| 413, 422 | payload_too_large; unknown_widget, invalid_command_value, read_only, reserved_topic, invalid_layout, idempotency_key_mismatch, asset_type_not_allowed, workspace_first |
| 429, 503 | rate_limited (with Retry-After); service_unavailable, broker_unavailable, cloud_unavailable |
Headers you must send
| Header | When |
|---|---|
Origin: https://<site> | On every POST, PUT, PATCH and DELETE made with the session cookie (the CSRF rule: Sec-Fetch-Site: same-origin or an Origin equal to the site). Without either: 403 csrf_rejected. Device calls, check-in and GET are exempt. |
Idempotency-Key: <UUID> | Required on POST /keys, POST /keys/bulk and POST /keys/:id/reissue. Repeating the same key and body returns the same result (Idempotent-Replayed: true); the same key with another body is 422 idempotency_key_mismatch. |
If-Match: "v<n>" | Required on saving a dashboard (PUT). The version comes from the ETag of the last read or save. Missing: 428; stale: 412 version_conflict. |
Authorization: Bearer fnd_... | On device calls. |
Limits
- A body is 64 KB at most (device telemetry 16 KB). Every client address may make 300 calls a minute. Features have their own limits, listed with them; over a limit is
429 rate_limitedwithRetry-Afterin seconds.
Cloud · 06
Cloud API: devices and MQTT
What a board calls: claim, config, telemetry, commands, check-in, and the broker topics.
- The person signs in and opens the activation link
https://<site>/activate?device=<12 hex>&chip=<chip>&fn=<version>; each parameter is checked alone and a bad one is dropped. The link leads on to making a key for this device. - The board calls
POST /device/claimwith its license key and gets a device token and the broker address. - It connects to the broker with the token and publishes its state; or, if it cannot hold a connection, it uses the HTTPS fallback below.
Device endpoints (Bearer token, no CSRF header)
| Call | Body or query | Answer and limits |
|---|---|---|
POST /device/claim | {"device_id": "A4CF12B1C2D3", "chip": "ESP32-S3", "fn": "2.1.0", "api_key": "fnk_live_..."} (chip and fn optional) | 201 new or 200 again: {"data": {"token", "mqtt": {"url", "username", "password", "clientId", "prefix", "keepalive"}, "http": {"config", "telemetry", "commands"}}}. 401 invalid_key, key_revoked; 403 license_revoked, device_blocked; 409 device_owned_elsewhere, reclaim_requires_approval, device_limit (3 Free, 25 Pro, 250 Enterprise devices per license); 429: 10 an hour per address. A second claim gets a new token only when the first was never used, or the owner rotated, unblocked or approved it in the last 15 minutes. |
GET /device/config[?reason=auth] | Nothing; reason=auth after the broker refused the login | {"data": {"mqtt": {...}, "http": {...}, "v": "..."}} without the password (the device already holds the token). 401 invalid_token means claim again. 12 a minute. |
POST /device/telemetry | {"info": {...}, "ui": {...}, "states": [{"w": "temp", "v": 24.5, "ts": 1760000000000}]}; 64 states and 16 KB at most; ts in milliseconds, believed only within the last 24 hours | 202 {"data": {"accepted", "dropped"}}. 30 a minute. |
GET /device/commands?wait=0..25&ack=<id> | wait holds the request open up to 25 s for a command; ack confirms every command up to that id | {"data": [{"id": 1235, "topic": "set/lamp", "payload": "ON"}]}, 32 at most, each handed out once. 60 a minute, one open request per device. |
POST /checkin | {"nonce": "<32 hex>", "fn": "2.1.0"} | {"data": {"status": "active|updates_expired|revoked", "validUntil", "serverTime", "token": "fnc_..."}}. Trust only token, which repeats your nonce. 4 an hour per device. 503 is never answered as “revoked”. |
curl -sS -X POST https://<site>/api/v1/device/claim -H 'Content-Type: application/json' \
-d '{"device_id":"A4CF12B1C2D3","chip":"ESP32-S3","fn":"2.1.0","api_key":"fnk_live_..."}'
curl -sS -X POST https://<site>/api/v1/device/telemetry -H 'Authorization: Bearer fnd_<token>' \
-H 'Content-Type: application/json' -d '{"states":[{"w":"temp","v":24.5},{"w":"lamp","v":"ON"}]}'
curl -sS 'https://<site>/api/v1/device/commands?wait=20&ack=1234' -H 'Authorization: Bearer fnd_<token>'The broker contract
Connect to mqtt.url exactly as the claim gave it (mqtts:// or wss://; the address is the server’s setting and is never built into the firmware). The username and client id are the device id (12 upper-case hex digits), the password is the device token, keepalive 30 s, with a last will of offline on status. The broker lets a device publish and subscribe only below its own <prefix>/<ID>/; the prefix defaults to flyght. A browser never connects to the broker: the server relays values to the page.
| Topic (below `<prefix>/<ID>/`) | Direction | Payload | QoS, retain |
|---|---|---|---|
status | device → | online / offline | 1, retained |
info | device → | {id, name, model, fw, fn, ip, url}, strings up to 128 bytes, id equal to the device id | 1, retained |
ui | device → | {pages[], widgets{}}, 16 KB and 64 widgets at most, types toggle, button, slider, gauge, value, chart, select, text | retained |
state/<widget> | device → | ON/OFF, a number as text, or text up to 1024 bytes | 0, retained |
set/<widget> | → device | toggle ON/OFF/TOGGLE, slider a number, select an exact option, text up to 128 bytes, button PRESS | 1, never retained |
light/<id>/state, light/<id>/set | both ways | the light’s JSON state; ON/OFF/TOGGLE, #rrggbb, an effect id or a JSON patch | 0 / 1 |
- After connecting, subscribe to
<prefix>/<ID>/set/+and<prefix>/<ID>/light/+/set(QoS 1), then publishstatus,info,uiand everystate/<widget>. - Widget ids are 1 to 32 characters of letters, digits,
_and-; a device may have 160 state keys, and the server stores up to 1200 messages a minute per device (MQTT and HTTPS together). - Commands are never retained, so an old order does not replay on reconnect. The server keeps a command 60 seconds (10 for a button) for a device that is offline and hands it over when the device comes back or polls over HTTPS.
- There is no command acknowledgement message: the confirmation is the
state/<widget>that comes back.
Cloud · 07
Cloud API: keys, devices, commands, history
What the dashboard calls with your session.
These calls use the session cookie (__Host-flyght_session on the live site) and, when they change something, the Origin header. The examples write -b flyght_session=<cookie> and -H "Origin: https://<site>".
Session and account
| Call | Meaning |
|---|---|
POST /auth/email-link | Body {"email", "next"?}. Always 202, so an address is never confirmed or denied. |
POST /auth/session | Body {"idToken"}, a fresh sign-in (within 5 minutes) of a verified email. Sets the cookie. |
DELETE /auth/session[?everywhere=1] | Sign out; everywhere=1 also ends every other session. |
GET /me | {"email", "emailVerified", "displayName", "isAdmin", "quota": {"freeActive", "freeMax"}}. |
GET /license/pubkeys | The public keys that sign licenses (no login). The Verify page checks a key in your browser with them; there is no server-side verify call. |
Keys
| Call | Meaning and limits |
|---|---|
GET /keys?status=active|revoked | Your keys, a page at a time. |
POST /keys | Body {"owner": "Ninno Khusnul Khuluq", "deviceLabel"?, "activation"?: {"device", "chip", "fn"}, "targetAssetId"?}. The owner is 1 to 32 bytes of UTF-8. Needs a verified email and an Idempotency-Key. 201 {"data": {"license", "key", "replayed"}}: the key is in this answer only. 3 active Free keys, 5 an hour per person and per address (administrators may set edition and updatesUntil and are not limited). targetAssetId is a folder of any workspace you own: the device that claims the key goes into that workspace and folder; without it, into your first workspace. |
POST /keys/bulk | {"rows": [{"owner", "path"?, ...}], "levels"?, "workspaceId"?}, 1 to 100 rows, missing folders of each path are made from the root of your first workspace, or of the one workspaceId names (yours, else 404); every row is its own request. |
POST /keys/:licenseId/reveal | Shows a key again. Needs a sign-in from the last 5 minutes; 5 an hour; every time is audited. |
POST /keys/:licenseId/reissue | Body {"reason": "entitlement"|"user_rotate"}; user_rotate revokes the old key. Fresh sign-in and Idempotency-Key. |
POST /keys/:licenseId/revoke | Revokes a key and cuts the cloud for every device claimed with it. Fresh sign-in. |
Devices
| Call | Meaning |
|---|---|
GET /devices?filter=online|offline|attention&q=&sort=recent|seen|name | Your devices (and those shared with you) with online, lastSeenAt, lastCheckinStatus; meta.counts has the totals. ?workspace=<id> lists one of your workspaces, or the devices another tenant shares with you. |
GET /devices/:deviceId | One device with its info, its ui (the widgets) and the last values state[]. This is how to read current values; there is no separate state route. |
PATCH /devices/:deviceId | {"name"} renames. |
POST /devices/:deviceId/rotate-token|block|unblock|approve-reclaim | Manage the device token; rotate and unblock open a 15 minute window in which the board can claim again. |
POST /devices/:deviceId/workspace | {"workspaceId"} (null for your first): moves the device to another workspace you own, into its root folder. Data, history and token stay; its groups and links in the old workspace end and the members of that workspace no longer see it. The owner only; 404 for a workspace that is not yours. |
DELETE /devices/:deviceId | Releases the device (token and broker login removed; anyone with a key may claim it afterwards). Fresh sign-in; 204. |
Send a command
POST /devices/:deviceId/commands is how the dashboard controls a board. The caller is the owner or has operator or admin on a folder above the device. The body is one of:
| Body | Goes to |
|---|---|
{"widgetId": "lamp", "value": "on"} | set/lamp |
{"light": "strip", "value": "#2563eb"} | light/strip/set |
{"topic": "reboot", "payload": "now"} (owner only) | a custom sub-topic, not under status, info, ui, state, set or light; 256 bytes at most |
- The value is checked against the widget the device described and turned into its canonical form: a toggle takes 1/true/on/yes or 0/false/off/no or toggle, a slider a number (clamped and snapped), a select one of its options, a text up to 128 bytes, a button anything (it sends
PRESS). Gauges, values and charts are read-only. - 202
{"data": {"commandId", "delivery": "mqtt"|"queued"}}:mqttwas published now,queuedwaits (60 s, 10 s for a button) for the device. A newer waiting command to the same target replaces the older. - Errors: 403
forbidden, 404not_found, 409device_blocked, 409device_offline(a button to an offline device), 422unknown_widget,invalid_command_value,read_only,reserved_topic, 429 (10 a second per device, 50 a second per person). Every command is recorded in the audit log.
curl -sS -X POST https://<site>/api/v1/devices/A4CF12B1C2D3/commands \
-b 'flyght_session=<cookie>' -H 'Origin: https://<site>' -H 'Content-Type: application/json' \
-d '{"widgetId":"lamp","value":"on"}'
# -> 202 {"data":{"commandId":42,"delivery":"mqtt"}}History
curl -sS "https://<site>/api/v1/devices/A4CF12B1C2D3/telemetry?widget=temp&from=$(( $(date +%s)-86400 ))&to=$(date +%s)&points=240" \
-b 'flyght_session=<cookie>'
# -> {"data":{"points":[[1760000000,24.5],...],"bucket":360,"source":"raw"}}widget is a numeric widget id, from and to are Unix seconds (a range of 400 days at most), points is 1 to 500 (default 240). Up to 48 hours from the last 30 days come from the raw samples; the rest from hourly summaries (source says which). A widget with no numbers gives no points, not an error.
Realtime
| Call | Meaning |
|---|---|
GET /realtime?devices=ID1,ID2 | A Server-Sent Events stream for 1 to 50 of your devices. First event: snapshot ({devices: [{deviceId, online, lastSeenAt, state[]}], cursor}), then state {key, value, at}, status {online, at}, info, ui, revoked {reason} and reconnect. A : hb comment every 20 s; the server closes after 5 minutes (reconnect) or when your access ends. At most 10 open streams per person. |
GET /realtime/poll?devices=...&cursor=<n> | The long-poll fallback: without a cursor a snapshot, with one it waits up to 25 s for events after it. |
curl -sS -N 'https://<site>/api/v1/realtime?devices=A4CF12B1C2D3' -b 'flyght_session=<cookie>'Cloud · 08
Cloud API: dashboards, folders, members
The calls behind Explorer, the dashboard builder and sharing.
Your dashboards
| Call | Meaning |
|---|---|
GET /dashboards, POST /dashboards | List yours; create with {"name"} (up to 20; 201 and an ETag: "v1"). A dashboard is in one of your workspaces: ?workspace=<id> names another of yours, else your first (404 for one that is not yours). |
GET /dashboards/:id, DELETE /dashboards/:id | Read (with its ETag) or delete (204). |
PUT /dashboards/:id | If-Match: "v<n>" required. Body {"name", "layout": {"cols": 12, "items": [{"id", "x", "y", "w", "h", "title"?, "binding"}]}}: 60 items at most, no overlap. A binding is {"kind": "device_widget", "deviceId", "widgetId"}, {"kind": "custom_topic", "deviceId", "subtopic"} or {"kind": "point", "assetId"}, and must be something you may see (else 404). {"kind": "placeholder", "widget"} (value, gauge, chart, toggle, button, slider, select or text) is a sample that reads nothing and needs no device: it lets a dashboard be built before any hardware is connected, and is bound to data later. 422 invalid_layout, 412 stale, 428 no If-Match. |
Folders (the asset tree)
| Call | Meaning |
|---|---|
GET /assets/tree, GET /assets/unsorted, GET /assets/search?q= | The folders with counts and what is shared with you; devices waiting in the root; search by name. |
GET /assets/:id, /children, /members, /readings, /relations | One folder or device, what is below it, the points under it, the average, lowest and highest of points by name, and its links. |
POST /assets | {"parentId", "type", "name"} makes a folder. 422 asset_type_not_allowed, asset_full, asset_too_deep (8 levels). |
PATCH /assets/:id, POST /assets/:id/move, POST /assets/bulk-move, DELETE /assets/:id | Rename; move ({"parentId"}); move up to 100 at once, all or none; archive an empty folder. |
PUT /assets/:id/attributes | {"attributes": {"key": "text"|number|null}}, checked against the folder’s type. |
GET|PUT|DELETE /assets/:id/dashboard | A folder’s own dashboard. If-Match is required on PUT ("v0" when it has none); items may bind a point by name: {"kind": "slot", "name"} or {"kind": "rollup", "name", "agg": "avg|min|max"}. |
GET /asset-types, PUT|DELETE /asset-types/:key, POST /asset-types/packs | Your folder types and starter packs. |
GET|POST /views, DELETE /views/:id | Saved searches. |
Members
| Call | Meaning |
|---|---|
GET /assets/:id/grants | Who has a role on this folder (administrators of it and the owner). |
POST /assets/:id/grants | {"email", "role": "viewer"|"operator"|"admin"}. A role covers the folder and everything below it, and applies when that person signs in with that verified email. Nothing is mailed. You cannot grant above your own role (403 role_too_high); 200 grants per workspace. |
DELETE /assets/:id/grants/:grantId | Ends the role from the next request; open streams close at the next heartbeat. |
POST /workspaces | {"name"}: another workspace of your own, with an empty root folder, its own folders and devices. How many you may own follows the best edition of your active licenses (Free 1, Pro 3, Enterprise no limit); 409 workspace_limit past it. |
DELETE /workspaces/:workspaceId | Deletes a later workspace of yours when it is empty (no device, no folder); its members lose it and its sign-in address is free. Fresh sign-in; 204. 409 workspace_not_empty, 422 workspace_first for your first workspace, which stays. |
GET /workspace/grants | Who has a role in your workspace (?workspace=<id> for another one you own): every live grant, on its root folder (the members of the whole workspace) and on its folders, with folderName. The owner only; 404 for a workspace that is not yours. |
GET|PUT /workspace/profile | The profile of your workspace: {"profileId", "overrides"}. The profiles are default, devices and fleet-tracking. A module that the profile has off (tracking, trips, import) answers 404 on its routes. 422 invalid_profile for a profile or a setting that is not valid. |
PUT /workspace/branding | {"displayName", "brandColor": "#rrggbb", "appName"}; the colour needs 4.5:1 contrast with white text. appName (40 characters, optional: left out it stays) is what the tenant calls the app in its own dashboard. |
PUT|DELETE /workspace/logo | The logo of your dashboard: {"data": "<base64>"}, a PNG, JPEG or WebP from 16 to 512 pixels a side and at most 40 KB, checked by its bytes (never an SVG; a WebP must also be exactly the size its header says). The Settings page of the dashboard converts any picture to WebP of that size for you before it sends it. 422 invalid_logo or logo_too_big. |
GET /workspaces/:id/logo | The picture, for the owner and for the people the workspace shares a folder with; 404 for anybody else and for a workspace without one. |
curl -sS -X POST https://<site>/api/v1/assets/12/grants -b 'flyght_session=<cookie>' \
-H 'Origin: https://<site>' -H 'Content-Type: application/json' \
-d '{"email":"ani@example.com","role":"operator"}'