Local API¶
On this page: what the local API is for, how a client trusts the box and pairs with it, the endpoints, the rules every request must pass, and the limits. Firmware 0.6.0 and later, in every build. The API is read-only in this version.
The local API is the foundation for the Lutra app on phones (planned): at home the app talks to the box directly over the local network, also without internet. In this version there is no app yet; owners keep using app.lutrapool.com through the cloud.
How a client trusts the box¶
- The box makes its own key (ECDSA P-256) on first start. The key never leaves the box. It is separate from the key the box uses for the Lutra cloud.
- The certificate is self-signed (
CN=Lutra Lite). Browsers show a warning for it; that is expected. Clients do not trust the certificate chain, they pin the key: the SHA-256 of the public key (SubjectPublicKeyInfo). - The box reports that pin to the cloud. A client that pairs through the owner's Lutra account receives the pin together with the pairing ticket, and accepts no other key for that box.
- A factory reset keeps the key, so paired phones keep their pin. A replaced board has a new key: pair again.
Pairing¶
- The owner (invited by the partner) or a technician asks the Lutra cloud for a pairing ticket for one pool. The ticket is signed by Lutra, valid for at most 10 minutes, for one box and one key only.
- The client sends the ticket to the box:
POST https://<box IP>/api/v1/pairwith the ticket as the JSON body. - The box checks the ticket on its own, without internet, and returns a session token.
The box never stores names or email addresses: only a pseudonymous account id, the role and a hash of the token.
| Role | Session lifetime |
|---|---|
| owner | 30 days after the last use, at most 90 days |
| tech | 12 hours |
At most 16 sessions per box; a new one replaces the least recently used. A factory reset (hold BOOT 10 s) ends all
sessions. On site, the USB console command lan revoke all does the same without a reset.
Endpoints¶
Base: https://<box IP>/api/v1/ on port 443. JSON only.
| Endpoint | Needs | Returns |
|---|---|---|
POST pair |
pairing ticket in the body | token, sid (public session id), role, exp, idle_s |
GET info |
session | firmware, build, board, Device ID, uptime, clock, network, cloud state, caps, own session |
GET status |
session | age_s and telemetry: the latest reading exactly as the box sends it to the cloud |
POST logout |
session | ends the own session |
Send the session as Authorization: Bearer <token>. Every other path answers 404.
Rules for every request¶
| Rule | Answer when broken |
|---|---|
| Only on the customer network, never on the box's temporary setup network | 403 interface |
| Client address must be private (10.x, 172.16 to 172.31, 192.168.x) | 403 source |
Host must be exactly the box IP the client connected to (optionally :443) |
421 host |
No Origin header (browser pages on other sites cannot use the API) |
403 origin |
| No query string; known path and method | 400 query, 404 not_found, 405 method |
POST with Content-Type: application/json and a length; body at most 2 KB |
415, 411, 413 |
Valid session (all except pair) |
401 auth |
| Box clock valid (sessions have dates) | 503 clock |
Errors have the form {"error":"<code>"}. Pairing errors: bad_request, fields, signature, typ, thing,
spki, clock, expired, replay.
Limits¶
- Pairing: 5 attempts per client address per 10 minutes, 20 per box per 10 minutes. Then
429withRetry-After. - Wrong or missing tokens: 20 per client address per minute, then
429. - At most 3 connections at the same time. The first connection takes up to about 2 seconds (key exchange in software); later requests reuse the connection or a TLS session ticket and are fast.
For the installer¶
- Nothing to set up. The API starts by itself on boxes with firmware 0.6.0 or later and a Device ID.
- It does not open anything to the internet: no port forwarding, no UPnP. Only devices on the same network can reach it, and only after pairing.
- The pin is visible on the USB console (
lan) and to Lutra support.
Last reviewed: 2026-11-26. Applies to Lutra Lite 0.6.0.