Skip to content
Flyght
Sign in

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.

C++
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

TopicPayload
flyght/<DEVICE_ID>/statusonline / 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.

C++
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

  1. You change a widget in the dashboard.
  2. 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.
  3. It publishes flyght/<DEVICE_ID>/set/<widget> (or hands it to the device over HTTPS if the device uses the fallback).
  4. 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 folderMay
viewerSee devices and values
operatorAlso send commands
adminAlso manage the folder, its members and its dashboard
ownerEverything 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

CredentialUsed byHow you get it
Session cookieThe 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 deviceReturned once by POST /device/claim. The server keeps only a keyed hash of it.
License key fnk_live_...The claim call onlyMade 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 is Cache-Control: no-store.
  • Failure: the status and {"error": {"code": "snake_case", "message": "..."}}. The message is in your language (cookie flyght_lang or Accept-Language); branch on code.
  • Something that is not yours is 404 not_found, not 403. A role that is too low is 403 forbidden.
StatusCodes
400invalid_request
401unauthenticated, session_expired, recent_login_required, invalid_token, invalid_key
403forbidden, csrf_rejected, email_not_verified, account_disabled, license_revoked, device_blocked, role_too_high
404, 409not_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, 428version_conflict; precondition_required
413, 422payload_too_large; unknown_widget, invalid_command_value, read_only, reserved_topic, invalid_layout, idempotency_key_mismatch, asset_type_not_allowed, workspace_first
429, 503rate_limited (with Retry-After); service_unavailable, broker_unavailable, cloud_unavailable

Headers you must send

HeaderWhen
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_limited with Retry-After in seconds.

Cloud · 06

Cloud API: devices and MQTT

What a board calls: claim, config, telemetry, commands, check-in, and the broker topics.

  1. 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.
  2. The board calls POST /device/claim with its license key and gets a device token and the broker address.
  3. 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)

CallBody or queryAnswer 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 hours202 {"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”.
Terminal
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>/`)DirectionPayloadQoS, retain
statusdevice →online / offline1, retained
infodevice →{id, name, model, fw, fn, ip, url}, strings up to 128 bytes, id equal to the device id1, retained
uidevice →{pages[], widgets{}}, 16 KB and 64 widgets at most, types toggle, button, slider, gauge, value, chart, select, textretained
state/<widget>device →ON/OFF, a number as text, or text up to 1024 bytes0, retained
set/<widget>→ devicetoggle ON/OFF/TOGGLE, slider a number, select an exact option, text up to 128 bytes, button PRESS1, never retained
light/<id>/state, light/<id>/setboth waysthe light’s JSON state; ON/OFF/TOGGLE, #rrggbb, an effect id or a JSON patch0 / 1
  • After connecting, subscribe to <prefix>/<ID>/set/+ and <prefix>/<ID>/light/+/set (QoS 1), then publish status, info, ui and every state/<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

CallMeaning
POST /auth/email-linkBody {"email", "next"?}. Always 202, so an address is never confirmed or denied.
POST /auth/sessionBody {"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/pubkeysThe 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

CallMeaning and limits
GET /keys?status=active|revokedYour keys, a page at a time.
POST /keysBody {"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/revealShows a key again. Needs a sign-in from the last 5 minutes; 5 an hour; every time is audited.
POST /keys/:licenseId/reissueBody {"reason": "entitlement"|"user_rotate"}; user_rotate revokes the old key. Fresh sign-in and Idempotency-Key.
POST /keys/:licenseId/revokeRevokes a key and cuts the cloud for every device claimed with it. Fresh sign-in.

Devices

CallMeaning
GET /devices?filter=online|offline|attention&q=&sort=recent|seen|nameYour 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/:deviceIdOne 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-reclaimManage 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/:deviceIdReleases 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:

BodyGoes 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"}}: mqtt was published now, queued waits (60 s, 10 s for a button) for the device. A newer waiting command to the same target replaces the older.
  • Errors: 403 forbidden, 404 not_found, 409 device_blocked, 409 device_offline (a button to an offline device), 422 unknown_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.
Terminal
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

Terminal
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

CallMeaning
GET /realtime?devices=ID1,ID2A 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.
Terminal
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

CallMeaning
GET /dashboards, POST /dashboardsList 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/:idRead (with its ETag) or delete (204).
PUT /dashboards/:idIf-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)

CallMeaning
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, /relationsOne 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/:idRename; 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/dashboardA 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/packsYour folder types and starter packs.
GET|POST /views, DELETE /views/:idSaved searches.

Members

CallMeaning
GET /assets/:id/grantsWho 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/:grantIdEnds 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/:workspaceIdDeletes 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/grantsWho 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/profileThe 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/logoThe 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/logoThe picture, for the owner and for the people the workspace shares a folder with; 404 for anybody else and for a workspace without one.
Terminal
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"}'