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).
- Viewer: reads devices, state and telemetry.
- Operator: can also send normal commands.
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_…
- Idempotency: the same
Idempotency-Keyruns a command at most once, and a retry returns the same command. Reusing the key with a different body is a 409. - Deadline: a command that can't be delivered before its deadline ends
expiredand never runs late. - Guarded actions: these wait in
awaiting_confirmationuntil a person confirms them withPOST /v1/commands/{id}/confirmor declines them with/decline. - What a device can do: actions and their parameters come from the capability catalog (
GET /v1/catalog/capabilities). Device types and their capabilities are inGET /v1/catalog/templates.
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"}]}
- Metrics:
capability@version.property, for examplesensor.temperature@1.celsiusorswitch@1.on. - Platform metrics:
device.availability(share of time online),alert.count,command.success_rateandautomation.runs. - Aggregations:
avg,min,max,sum,count,last,delta(what a counter went up by, the step between buckets included),p95, andratio_true(the share of readings that were true). - Ranges:
1hto365d, or calendar rangestoday,this_week(from Monday) andthis_month, intimeZone(the site's or yours by default); orfromandto. - Scope:
siteIds,assetIds(a room and what is inside it),groupIds,tagsordeviceIds. - Grouping:
groupByup to two ofsite,asset,group,device,template,severity,type; each series carries itslabels.limitkeeps the top N. - Comparisons:
compareTo: previous_periodorsame_period_last_yearadds series marked withperiod, their times moved onto the current period so both share one axis. - Buckets: aligned to the clock (UTC) for relative ranges, to local midnight for calendar ones.
- Visibility: devices you can't read are left out, never reported as errors.
# 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
One open alarm per device and rule: repeat breaches raise its
occurrences, not new alarms.Clearing: an alarm clears itself when the reading is back past the threshold by
hysteresis, or an operator clears it.Default alarms: device types bring default alarms, listed under
defaultAlarmsinGET /v1/catalog/templates.Comparisons:
>,>=,<,<=,insideandoutside(valuetovalue2).Webhook security: create a signing secret with
POST /v1/integrations/webhook-secret. Each webhook carries:X-Meryxon-Timestamp;X-Meryxon-Signature: sha256=<hex>, an HMAC-SHA256 of"<timestamp>.<body>".
Check both, and refuse anything older than a few minutes.
Not delivered yet:
smsandpushare accepted but recorded as not configured until there's a provider.
Automation
- Scenes and routines (
/v1/scenes): stepscommand,delay(routines),runScene, andnotify, which sendsmessage(up to 200 characters) to the person the scene runs as, bypush(default) oremail. - Schedules (
/v1/schedules):daily,weekly,monthly,once, orsun:sunEventsunriseorsunsetwithoffsetMinutesup to ±180. Sun schedules need the site's location:PATCH /v1/sites/{siteId}with{"location":{"latitude":30.0444,"longitude":31.2357}}(nullclears it; without one the schedule is refused withsite_location_missing).
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
- Plugin cards: a
ui-card-declarativeplugin adds cards with no code.GET /v1/plugin-cardslists those of enabled plugins; a dashboard places one as widget typeplugin:<plugin id>/<card id>. - Partner templates: a partner account offers a dashboard to every customer that gives it access, as a store listing with
visibility: customers. Customers find it withGET /v1/store/listings?kind=dashboard_templateand add a private copy withPOST /v1/store/listings/{id}/install.
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
- Order: frames are handled in order, so you can send
subscriberight afterauth. - Revocation: if your access is revoked, the server sends
closedwith reasonrevoked. - Reconnecting: use the jittered backoff in the contract and resume from your last cursor.
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:
X-Meryxon-Event,X-Meryxon-Event-Id(the body'sid),X-Meryxon-Delivery;X-Meryxon-TimestampandX-Meryxon-Signature: sha256=<hex>, an HMAC-SHA256 of"<timestamp>.<body>"with the subscription's secret.
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')}`)));
- At least once: answer 2xx quickly and dedupe by the event
id; it stays the same on retries and redeliveries. - Retries: anything other than 2xx, or no answer within 10 seconds, is retried after 30 s, doubling to at most an hour, for 24 hours. Then the delivery is
failed(the dead-letter list). No redirects are followed. - Turned off: a subscription failing for 3 days (
WEBHOOK_DISABLE_AFTER_HOURS) is turned off withdisabledReason: failing, and its waiting deliveries fail.PATCH /v1/webhooks/{id}with{"enabled":true}turns it back on. - Delivery log:
GET /v1/webhooks/{id}/deliveries?status=failed(30 days).POST …/deliveries/{deliveryId}/redeliversends the same event again.POST /v1/webhooks/{id}/testsends awebhook.testevent. - Secret rotation:
POST /v1/webhooks/{id}/rotate-secretreturns a new secret. For 24 hoursX-Meryxon-Signaturecarries two comma-separated signatures, new first, so you can switch over without missing anything. - Addresses: HTTPS only; addresses that resolve to private, loopback or link-local networks are refused when saving and again before each send.
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" }
- 404 rather than 403: something in another account, or something you can't see, is a 404, so its existence never leaks.
- 503
dependency_unavailable: safe to retry; idempotent requests can be repeated with the same key.
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.