Meryxon docs

Meryxon public API guide

The full reference is the contract: contracts/openapi.yaml (REST) and contracts/realtime.asyncapi.yaml (live updates). Every API serves it as a web page at GET /v1/docs (rendered with Redoc, MIT) and as YAML at GET /v1/openapi.yaml, with no sign-in; pnpm -F @meryxon/api docs:build writes the same page to one static HTML file. This guide shows the common tasks.

flowchart LR
    you["Your system"] -->|"Bearer meryxon_key_…"| api["REST /v1"]
    you -->|"auth frame"| ws["WebSocket /v1/realtime"]
    api --> pdp["Every call checked: tenant, role, deny"]

Authentication

Who How Gets
People (web, mobile) Meryxon sign-in (Ory); send Authorization: Bearer <access token> Their roles
Systems An API key; send Authorization: Bearer meryxon_key_… Viewer or operator at one scope

A key belongs to one account and holds one role at one scope (account, organization, site or device).

No key can configure devices, manage access, or run guarded actions such as unlocking or switching mains; those always need a person. A revoked or expired key stops working on its next request.

# An admin creates a key (in the web app, or with a person's token):
curl -s -X POST https://api.meryxon.com/v1/api-keys \
  -H "Authorization: Bearer $PERSON_TOKEN" -H "Idempotency-Key: $(uuidgen)" -H 'content-type: application/json' \
  -d '{"name":"BMS integration","role":"operator","scope":"site_…","expiresInDays":90}'
# → {"id":"key_…","key":"meryxon_key_…","expiresAt":"…"}   The key is shown only once.
export KEY=meryxon_key_…

Revoke it with DELETE /v1/api-keys/{id}. List keys with GET /v1/api-keys; secrets are never returned.

Devices and state

curl -s -H "Authorization: Bearer $KEY" https://api.meryxon.com/v1/sites/site_…/devices
curl -s -H "Authorization: Bearer $KEY" https://api.meryxon.com/v1/devices/dev_…/state

State separates reported (what the device said), desired (what was asked) and connection (online, lastSeen). Never treat desired as the device's state.

Commands

curl -s -X POST https://api.meryxon.com/v1/devices/dev_…/commands \
  -H "Authorization: Bearer $KEY" -H "Idempotency-Key: order-4711-lamp-on" -H 'content-type: application/json' \
  -d '{"capability":"switch@1","action":"set","params":{"on":true},"timeoutS":30}'
# → 202 {"id":"cmd_…","status":"queued", …}
curl -s -H "Authorization: Bearer $KEY" https://api.meryxon.com/v1/commands/cmd_…

Telemetry

curl -s -X POST https://api.meryxon.com/v1/metrics/query \
  -H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
  -d '{"queries":[{"metric":"meter.energy@1.watts","aggregation":"avg","range":{"relative":"24h"},"interval":"1h","scope":{"siteIds":["site_…"]}}]}'
# → {"results":[{"series":[{"key":"dev_…","unit":"W","points":[["2026-11-18T10:00:00Z",61.2], …]}],"dataUntil":"…","resolution":"1h"}]}
# Energy used this month per room, against last month:
curl -s -X POST https://api.meryxon.com/v1/metrics/query -H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
  -d '{"queries":[{"metric":"meter.energy@1.kwh","aggregation":"delta","range":{"relative":"this_month"},"interval":"1d","scope":{"siteIds":["site_…"]},"groupBy":["asset"],"compareTo":"previous_period"}]}'

Alarms

# A rule on one device (or on whole sites with siteIds), notifying a webhook:
curl -s -X POST https://api.meryxon.com/v1/alert-rules \
  -H "Authorization: Bearer $PERSON_TOKEN" -H "Idempotency-Key: $(uuidgen)" -H 'content-type: application/json' \
  -d '{"name":"Server room warm","enabled":true,"severity":"critical",
       "metric":{"metric":"sensor.temperature@1.celsius","range":{"relative":"24h"},"scope":{"deviceIds":["dev_…"]}},
       "condition":{"op":">","value":28,"forSeconds":120,"hysteresis":1},
       "notify":[{"channel":"webhook","to":"https://hooks.example/meryxon"}]}'
curl -s -H "Authorization: Bearer $KEY" 'https://api.meryxon.com/v1/alarms?siteId=site_…'
curl -s -X POST -H "Authorization: Bearer $KEY" https://api.meryxon.com/v1/alarms/alm_…/acknowledge

Automation

Compound residents

A compound manager invites a resident to sign in for one unit: POST /v1/community/units/{unitId}/resident-accounts returns a one-time invitation link (emailed when email is given). Signed in, the resident lists their units with GET /v1/me/units and acts only for those, under /v1/community/units/{unitId}/: passes (visitor passes, at most 7 days), amenities and bookings (the same capacity and limits as the manager's), requests, charges and their pay-link, posts (shown once the manager approves), and announcements. Any other unit is a 404.

Dashboards and plugins

Live updates

const ws = new WebSocket('wss://api.example/v1/realtime');
ws.onopen = () => {
  ws.send(JSON.stringify({ type: 'auth', token: KEY }));                       // a key or a person's token
  ws.send(JSON.stringify({ type: 'subscribe', channel: 'device:dev_…' }));     // add fromCursor to resume
  ws.send(JSON.stringify({ type: 'subscribe', channel: 'alarms:site_…' }));    // a site's alarms, live
};
ws.onmessage = (m) => console.log(JSON.parse(m.data));                         // subscribed, update, closed, error

Event webhooks

Subscribe an HTTPS endpoint to events in your account (account admins):

curl -s -X POST https://api.meryxon.com/v1/webhooks \
  -H "Authorization: Bearer $PERSON_TOKEN" -H "Idempotency-Key: $(uuidgen)" -H 'content-type: application/json' \
  -d '{"name":"BMS","url":"https://hooks.example/meryxon","events":["alarm.raised","alarm.cleared","command.finished"],"siteIds":["site_…"]}'
# → 201 {"id":"whk_…","secret":"whsec_…", …}   The secret is shown only now.
Event When
alarm.raised, alarm.acknowledged, alarm.cleared An alarm changes. Thresholds on telemetry are alert rules, so a reading past one arrives as alarm.raised; a device going offline is the connectivity/offline alarm
command.created, command.finished A command is accepted, and when it ends (succeeded, failed, timed_out, expired, rejected, cancelled)
device.registered, device.decommissioned A device is added to a site, or removed for good
installation.created, installation.status_changed A partner plans an installation on your site, and each step to handover
booking.created, booking.changed, booking.cancelled A stay is booked (by hand or from the listing's calendar feed), moves to other dates, or is cancelled. Personal: the guest's name
pass.created, pass.used, pass.refused A visitor pass is issued, a guard lets the visitor in, or a check at the gate is refused. Personal: the visitor's name
request.opened, request.status_changed A resident's request or complaint is filed, and moves to in progress or resolved. Personal: what the resident wrote
amenity.booked, charge.issued, charge.paid, announcement.published A unit books an amenity slot, a service charge is raised or paid, the manager posts an announcement
member.invited, member.joined, member.removed Someone is invited to the account, accepts, or is taken out. Personal: the invitation's email
gateway.offline, gateway.online, gateway.updated A gateway has been offline for ten minutes, comes back, or runs a new agent version
report.ready, scene.ran A scheduled report was sent; a scene or routine finished a run

Events marked personal carry "dataClass": "personal". When the person who created the subscription may not read personal data in the account (not an admin), those fields arrive masked (•••, an email keeps its first letter and domain). guest.checked_in, guest.checked_out, energy.budget_crossed, plugin.quarantined and plan.limit_reached are in the catalogue but not sent yet.

GET /v1/webhooks/event-types lists them. Leave siteIds out to get every site, and events that belong to no site.

Each delivery is a POST with the body in webhook-event.v1 ({ id, type, occurredAt, tenantId, siteId?, data }) and these headers:

const ok = req.headers['x-meryxon-signature'].split(',').some((s) =>
  crypto.timingSafeEqual(Buffer.from(s), Buffer.from(`sha256=${crypto.createHmac('sha256', SECRET).update(`${ts}.${rawBody}`).digest('hex')}`)));

The older account-wide secret (POST /v1/integrations/webhook-secret) still signs the per-rule alarm webhooks in notify.

Rate limits

Calls with an API key are counted per key and per account (all its keys together) in one-minute windows; the limits come from the account's plan. People signed in to the apps are not counted.

Header Meaning
RateLimit-Limit Calls allowed in this window (the tighter of the key and account limits)
RateLimit-Remaining Calls left
RateLimit-Reset Seconds until the window resets

Over the limit the answer is 429 rate_limited with Retry-After in seconds. Wait that long; spreading calls out helps more than retrying at once.

Versions and deprecation

/v1 only changes in ways that keep working clients working: new endpoints, new optional fields, new response fields and enum values (ignore ones you don't know), new event types. A breaking change gets a new endpoint or /v2. An endpoint that will go away answers with Deprecation and Sunset headers and a Link to its successor at least 12 months before it is removed (proposed).

Errors

Errors are RFC 9457 problem details with a stable code from contracts/errors.yaml, for example:

{ "type": "https://errors.meryxon.dev/no_relation", "title": "You do not have permission for this", "status": 403, "code": "no_relation" }

More

Task Endpoints
Reports GET /v1/reports/{kind}?siteId&from&to[&format=csv]; schedules at /v1/report-schedules
Audit GET /v1/audit?resource= and GET /v1/audit/verify
Access governance /v1/access-requests, /v1/access-reviews, POST /v1/authz/explain, GET /v1/orgs/{orgId}/principals/{userId}/effective-access
Staff access to your account GET /v1/tenants/{tenantId}/staff-access (break-glass, with its review date)
Billing /v1/tenants/{id}/subscription, /v1/tenants/{id}/invoices
Branding /v1/tenants/{id}/branding, /v1/tenants/{id}/domains

Customer-facing guides: docs/guides.