Documentation / API
Alerts
Alert rules (thresholds, ranges, equality, transitions, silence, debounce, reminders; on a device or a device selector), alert events and their acknowledgement, notification channels (email, signed webhook) and the webhook payload.
All paths are relative to https://apiv1.opensensorcloud.com/api/v1.
Alert rules
| Method and path | Role | Result |
|---|---|---|
GET /orgs/{orgId}/alert-rules |
member | array of rules |
POST /orgs/{orgId}/alert-rules |
editor | 201, the rule |
PUT /orgs/{orgId}/alert-rules/{id} |
editor | the rule (full replacement) |
DELETE /orgs/{orgId}/alert-rules/{id} |
editor | 204 |
{
"name": "Greenhouse too hot",
"target": { "type": "profile", "profileId": "9f10a175-…" },
"channelKey": "temperature",
"condition": { "kind": "above", "value": 30 },
"durationSeconds": 300,
"severity": "critical",
"enabled": true,
"channelIds": ["d05c4ebc-…"],
"remindEveryHours": 4
}
| Field | Rules |
|---|---|
name |
1 to 100 characters |
target |
{ "type": "device", "deviceId": "…" }, or a device selector { "type": "selector", "selector": … } with selector one of { "kind": "profile", "profileId": "…" }, { "kind": "attribute", "key": "site", "value": "Floirac" }, { "kind": "list", "deviceIds": ["…"] } (1 to 200) or { "kind": "all" }. Each device of the selector has its own alert; membership is checked on every message, so a device created or tagged later joins the rule and a deleted device leaves it. The older { "type": "profile", "profileId": "…" } is still accepted. 400 unknown_target if a device or profile is not in the organization |
channelKey |
monitored channel; required except for silence |
condition |
see below |
durationSeconds |
the condition must hold this long before the alert opens (0 to 86400, default 0; must be 0 for changes) |
severity |
info, warning (default), critical |
enabled |
default true |
channelIds |
up to 10 notification channels of the organization (400 unknown_channel otherwise) |
remindEveryHours |
1 to 168: notify again every N hours while the alert is open and not acknowledged; null (default) = never |
Conditions:
{ "kind": "above", "value": 30 }
{ "kind": "below", "value": 5 }
{ "kind": "outside", "min": 10, "max": 30 }
{ "kind": "equals", "value": true }
{ "kind": "silence", "minutes": 60 }
{ "kind": "becomes", "value": false, "resolveWhen": "otherwise" }
{ "kind": "changes", "holdSeconds": 0 }
equals accepts a number, a boolean or a text (up to 200 characters). silence: no message from the device for N minutes (1 to 10080), checked every minute. Responses add the rule id.
becomes and changes compare the value with the previous one received for the device (strictly: 1 and "1" differ):
| Condition | Opens | Resolves | Notified | First value seen |
|---|---|---|---|---|
becomes, resolveWhen: "otherwise" (default) |
value equal to value for durationSeconds |
when the value differs | opening and resolution | fires if equal |
becomes, resolveWhen: "never" |
same | at once (one occurrence; fires again after the value has differed) | opening only | fires if equal |
changes, holdSeconds 0 to 86400 (default 0) |
each value different from the previous one | holdSeconds after opening (at once when 0), or at the next change |
opening only | never fires |
Example: alert when a HidnSeek tracker leaves its zone: target { "type": "selector", "selector": { "kind": "profile", "profileId": "…" } }, channelKey "zone.inside" (a channel computed by the profile's transform), condition { "kind": "becomes", "value": false }.
Alert events
GET /orgs/{orgId}/alert-events?open=true
open=true returns only unresolved events; without it, the history (open and resolved).
[
{
"id": "36c5fec8-…", "ruleId": "47403491-…", "ruleName": "Greenhouse too hot", "severity": "critical",
"deviceId": "778a19de-…", "deviceName": "Greenhouse north", "channelKey": "temperature", "triggerValue": 36.5,
"startedAt": "2026-11-11T14:07:22.338Z", "resolvedAt": null,
"acknowledgedAt": null, "acknowledgedBy": null
}
]
An event opens when the condition has held for durationSeconds, and resolves when it no longer holds. A profile rule produces one event per device.
POST /orgs/{orgId}/alert-events/{id}/ack — editor
Acknowledges the event: acknowledgedAt / acknowledgedBy are set and reminders stop. The event stays open until the condition clears. 204.
Notification channels
| Method and path | Role | Result |
|---|---|---|
GET /orgs/{orgId}/notification-channels |
member | array of channels |
POST /orgs/{orgId}/notification-channels |
admin | 201, the channel |
DELETE /orgs/{orgId}/notification-channels/{id} |
admin | 204 |
Email:
{ "type": "email", "name": "On call", "to": ["oncall@example.com", "boss@example.com"], "locale": "en" }
to: 1 to 20 addresses; locale: language of the emails, fr (default) or en.
Webhook:
{ "type": "webhook", "name": "Ops", "url": "https://hooks.example.com/osc" }
The creation response of a webhook includes, once, its signing secret:
{ "id": "…", "type": "webhook", "name": "Ops", "url": "https://hooks.example.com/osc", "signingSecret": "…" }
Webhook payload
On each notification, the webhook receives a POST with a JSON body:
{
"v": 1,
"eventId": "36c5fec8-…",
"orgId": "7dd446ca-…",
"status": "firing",
"ruleName": "Greenhouse too hot",
"severity": "critical",
"deviceId": "778a19de-…",
"deviceName": "Greenhouse north",
"channelKey": "temperature",
"condition": { "kind": "above", "value": 30 },
"value": 36.5,
"at": "2026-11-11T14:07:22.338Z",
"condition_text": "temperature > 30",
"url": "https://www.opensensorcloud.com/orgs/7dd446ca-…/devices/778a19de-…"
}
status:firing(opened),resolved, orreminder. A reminder hasvalue: null,at= time of the reminder, andopenedAt= when the alert opened.previousValue(becomesandchangesonly): the value received beforevalue,nullfor the first value seen.location{ "lat", "lng" }: present when the message that raised the notification also carriedlatitude/longitude(or elsesigfox.lat/sigfox.lng).- The header
x-osc-signature: sha256=<hex>is the HMAC-SHA256 of the raw body with the signing secret. Verify it before trusting the call:
import { createHmac, timingSafeEqual } from 'node:crypto';
const expected = 'sha256=' + createHmac('sha256', secret).update(rawBody).digest('hex');
const ok = expected.length === signature.length && timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
Timeouts and retries of webhook calls: to verify.