HTTP API
Machine-readable contract:
- This docs site: openapi.yaml
- Production: probeharbor.dev/openapi.yaml
- In-app page: probeharbor.dev/docs/api
Authentication
| Audience | Mechanism |
|---|---|
| Device firmware | Device key in /api/ingest/{deviceKey} (or X-Ingest-Key for MQTT bridge) |
| Pro integrations | Bearer API key from Dashboard → Share |
| Browser dashboard | Supabase session cookies (not for third-party clients) |
| Share links | Opaque token in the URL path |
Endpoint map
| Method | Path | Auth | Purpose |
|---|---|---|---|
POST | /api/ingest/{deviceKey} | Path key | Push sensor readings |
POST | /api/ingest/mqtt | X-Ingest-Key | MQTT→HTTP bridge |
POST | /api/user/pull-setup | Session cookie | Save pull feeds + probe labels (JSON body) |
GET | /api/user/door-events | Session cookie | Door openings: the latest limit (default 12, max 50), or with from / to (YYYY-MM-DD in your browser's time zone, or ISO timestamps) the openings that started in that range, newest first (limit default 100, max 500; adds range and truncated). Also live_sessions for the last 24 h |
GET | /api/door-events/export.csv | Session cookie (CSV plan) | Door openings with temperature and humidity at open and close (from, to, days, door); UTC times |
POST | /api/devices/reveal-ingest-key | Session cookie | Recover encrypted push ingest key (rate-limited; audited) |
GET | /api/v1/metrics | Bearer API key (read) | Prometheus text exposition |
GET | /api/v1/devices | Bearer API key (read) | List household devices |
POST | /api/v1/devices | Bearer API key (write) | Create push device (returns its ingest key) |
POST | /api/v1/devices/sensors-batch | Bearer API key (write) | Rename / hide sensors |
POST | /api/v1/pull-setup | Bearer API key (write) | Replace the household's pull feeds + probe labels |
POST | /api/inbound/{token} | Token + HMAC signature (timestamped V2 recommended) | Snooze / vacation / status actions |
GET | /api/share/{token}/readings | Share token | Public JSON readings (Free family live; Pro expands scopes) |
POST | /api/pucks/register | Companion session | Register claim-puck secret |
POST | /api/pucks/claim/start | Companion session | Issue claim nonce |
POST | /api/pucks/claim/finish | Companion session | Verify HMAC and bind bay |
GET | /api/bays/{bay_id}/mood | Companion session | Derived bay mood (Bay Buddy / claim puck) |
PUT | /api/bays/{bay_id}/mood | Companion session | Override mood (demo / test) |
Bearer API keys need the household owner's plan to include the API (Pro) at the time of each call. After a downgrade, /api/v1/* returns 403 {"error": "API access needs a Pro plan"}; creating a device past the plan's limit returns 403 with "code": "device_limit". Device ingest keys keep working.
API key scopes
Each API key is read-only (read, the default when you create one) or read and write (write). You pick it when creating the key, and the key list on Dashboard → Share → API shows each key's scope. Only the household owner and editors (full members) can create keys, of either scope.
read:GET /api/v1/metrics,GET /api/v1/devices. Use this for Prometheus, Grafana, Home Assistant scrapes.write: everythingreadcan do, plusPOST /api/v1/devices,POST /api/v1/devices/sensors-batch,POST /api/v1/pull-setup.
A read-only key on a write endpoint gets 403:
{"error": "This API key is read-only. Create a key with write access (Dashboard → Share → API) to use this endpoint.", "code": "insufficient_scope", "required_scope": "write"}(plus "ok": false on sensors-batch and pull-setup, whose other errors carry it too) and the header WWW-Authenticate: Bearer error="insufficient_scope", scope="write". Keys created before scopes existed are write, so they keep working as before. A key's scope can't be changed; create a new key and revoke the old one.
Claim puck
Physical RP2040-Zero presence key. Product page: probeharbor.dev/claim-puck. Firmware: probeharbor-claim-puck.
Auth matches Bay Buddy: Authorization: Bearer <access> + X-SB-Refresh-Token: <refresh>.
Flow: register → claim/start → device CHALLENGE + button → claim/finish → poll GET /api/bays/{bay}/mood.
Create an API key (Pro)
- Sign in → Dashboard → Share
- Create an API key (read-only unless you need the write endpoints); copy it once
- Call:
curl -sS "https://probeharbor.dev/api/v1/metrics" \
-H "Authorization: Bearer YOUR_API_KEY" | headExample: list devices
curl -sS "https://probeharbor.dev/api/v1/devices" \
-H "Authorization: Bearer YOUR_API_KEY"Spec versioning
openapi.yaml in the repo (public/openapi.yaml) is the source of truth. The docs build copies it into this site on every Pages deploy.
Legacy per-feed routes (/api/user/temp-feeds, /api/user/temp-probes) are retired — use POST /api/user/pull-setup instead.