01 · Endpoint
POST https://projectmrai.lovable.app/api/public/telemetry
Content-Type: application/json. One packet per request.
02 · Authentication
Every request carries the header X-Device-Key with the 48-character key issued when the node was registered.
A missing or unknown key is rejected. Keys are node-scoped: a key can only write readings for its own node.
03 · Request schema
node_id — string, the registered node identifier.
rain — one of DRY, LIGHT, HEAVY.
obstacle — one of CLEAR, RISK, BLOCKED.
distance — integer centimetres from the ultrasonic sensor.
gas — one of SAFE, WARN, ALERT.
recorded_at — optional ISO-8601 timestamp; used for replayed offline packets.
04 · Responses
200 — packet accepted and stored.
400 — malformed body or a field outside its allowed set.
401 — missing or invalid device key.
404 — the node_id is not in the registry.
5xx — transient service fault; the node should retry.
05 · Offline buffering contract
A node that cannot reach the service queues packets locally and replays them with their original recorded_at once the link returns.
The service accepts backdated readings. Replayed packets do not re-open incidents that have already been resolved.
Retry with exponential backoff starting at 5 s, capped at 5 minutes. Do not retry a 400 or 401.