Devices & Device Hub API
Cloud device ledger, hub pairing, and the local Device Hub protocol for printing.
Cloud device ledger#
GET /api/wms/print-devices?warehouse_id=<uuid>&hub_id=<uuid>&page=1&page_size=50
// -> items: id, name, model, device_type, connection, address,
// is_default_label_printer, status, last_seen_at, hub_id, hub_name,
// warehouse_id, warehouse_name, created_atOnline/offline is computed from last_seen_at (2-minute heartbeat threshold). Printers are synced to this ledger automatically by the Hub after pairing — including the default-label-printer flag used by cloud print.
Device Hub local protocol#
Pairing and local printing go through the Device Hub tray app over WebSocket at ws://127.0.0.1:18443 (JSON request/response with action + params; events are pushed as { event, data }). hub.info and hub.pair need no auth; everything else requires the token obtained from pairing.
// 1. user reads the 6-digit code shown in the Device Hub tray app
// 2. pair (no auth required):
ws -> { "action": "hub.pair", "params": { "code": "482910" }, "id": "1" }
ws <- { "id": "1", "ok": true, "data": { "token": "<hub-token>" } }
// 3. store the token locally; all later requests send it (see device-hub lib).
// success envelope: { id, ok: true, data }
// error envelope: { id, ok: false, error: { code, message } }- hub.info — hub version/platform, no auth.
- printer.list → { printers } (id, name, model, connection); printer.discover triggers a USB + network (mDNS) scan, results pushed as printer.discovered events.
- printer.print { device_id, data: "<zpl>", copies } → { job_id }; completion/failure arrives as a print.job_completed event.
- printer.status { device_id } — real-time printer state (out of paper/ribbon, cover open).
- device.register { device_id, name, is_default } — register a discovered device (also reports to the cloud ledger).
Cloud-relay binding#
ws -> { "action": "hub.cloud_bind", "params": {
"supabase_url": "https://<ref>.supabase.co",
"supabase_anon_key": "<anon-key>",
"organization_id": "<uuid>",
"warehouse_id": "<uuid>" // optional
}, "id": "2" }
ws <- { "id": "2", "ok": true, "data": {} }
// after binding, the Hub pulls print_jobs with its cloud credentials and syncs the device ledger.