API Reference
Overview

API Overview

All Parlevel API routes are Next.js Route Handlers under /api. They require authentication via Supabase JWT.

Authentication

Every request must include a valid Supabase access token:

Authorization: Bearer <supabase-access-token>

To get the token client-side:

const { data: { session } } = await supabase.auth.getSession()
const token = session?.access_token

Location context

RFID endpoints are location-scoped. Pass the active location ID in a header:

x-selected-location: 42

If omitted, the first location the authenticated user has access to is used.

Response format

All endpoints return JSON with an ok boolean:

{ "ok": true, "result": { ... } }

Errors:

{ "ok": false, "error": "Description of the error" }

HTTP status codes:

  • 200 — success
  • 400 — bad request (missing/invalid params)
  • 401 / 403 — authentication failure
  • 502 — relay unreachable or returned an error
  • 503 — feature disabled (e.g. ingest not enabled)
  • 500 — unexpected server error

RFID API routes

MethodPathDescription
GET/api/rfid/u300/configGet effective RFID config for the location
PATCH/api/rfid/u300/configSave partial RFID config fields
POST/api/rfid/u300/ingest/startStart RFID ingest
POST/api/rfid/u300/ingest/stopStop RFID ingest
POST/api/rfid/u300/ingestReceive tag events from the relay (relay → server)
GET/api/rfid/u300/antennas/statusGet currently active antenna ports
POST/api/rfid/u300/antennas/maskSet active antenna ports
GET/api/rfid/u300/moisture/liveLive fluid levels for all in-range sensor tags
POST/api/rfid/u300/buzzer/muteMute the U300 buzzer
POST/api/rfid/u300/buzzer/unmuteUnmute the U300 buzzer