Connected Workers Alerts

The Connected Workers Alerts API covers two things: the alert rules you define (thresholds that watch a sensor or an asset) and the alerts they raise (the incidents you read back on the Operations dashboard). Rules are evaluated automatically every time a reading arrives — through the Sensors push API, the MQTT bridge, or a scheduled poll — so an alert opens the moment a value breaches a rule and resolves when it recovers.

  • Alert rule — a threshold: an operator (gt, lt, outside_range, …), a value (or a low/high range), a severity, and a target (a sensorId or a cwAssetId). A rule with no target can never fire and is rejected.
  • Alert — a raised incident. It has a severity, a status (openacknowledgedresolved), the triggering value, and links back to the sensor/asset.
Rule 9  "High pump temp"  ·  operator: gt  ·  value: 80  ·  severity: critical  ·  target: sensor 42

        ▼  reading 83.1 arrives
Alert 500  status: open  ·  severity: critical  ·  triggerValue: 83.1  ·  sensor 42 / asset 1001

Base URL & auth

Every endpoint is scoped to a workspace and served under:

https://api.treedis.com/v2/api/workspaces/{workspaceId}/operations

All endpoints require authentication (OAuth2 Bearer token or X-API-Key), and the caller must have access to the workspace. Generate OAuth credentials in the Treedis admin under Settings → General → Advanced.

Authentication How to obtain and send an OAuth2 access token or API key.

Endpoints

Method Path (under /v2/api/workspaces/{workspaceId}/operations) Purpose
GET /alert-rules List alert rules
POST /alert-rules Create an alert rule
PATCH /alert-rules/{ruleId} Update an alert rule
DELETE /alert-rules/{ruleId} Delete an alert rule
GET /alerts List raised alerts (the incident feed)

Alert rules

List

GET /v2/api/workspaces/{workspaceId}/operations/alert-rules

curl "https://api.treedis.com/v2/api/workspaces/7/operations/alert-rules" \
  -H "Authorization: Bearer your-access-token"

Create

POST /v2/api/workspaces/{workspaceId}/operations/alert-rules

Field Type Notes
name string Required. Rule name.
operator enum Required. gt · gte · lt · lte · eq · neq · outside_range · stale.
severity enum Required. info · warning · critical.
sensorId number Target a single sensor. One of sensorId / cwAssetId is required.
cwAssetId number Target an asset (applies to every sensor bound to it).
value number The threshold. For outside_range, this is the low bound.
valueHigh number The high bound for outside_range.
durationSeconds number Sustain time before the rule fires (0 = immediate).
enabled boolean Defaults to true.
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/operations/alert-rules" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "High pump temp",
    "sensorId": 42,
    "operator": "gt",
    "value": 80,
    "severity": "critical"
  }'
{
  "success": true, "code": 200, "message": "Success",
  "data": {
    "rule": {
      "id": 9, "workspaceId": 7, "name": "High pump temp",
      "sensorId": 42, "cwAssetId": null, "operator": "gt",
      "value": 80, "valueHigh": null, "durationSeconds": 0,
      "severity": "critical", "enabled": true
    }
  }
}

The stale operator is time‑based (a sensor that stopped reporting); the connectivity job owns those alerts, so you don't supply a value for it. A rule with neither sensorId nor cwAssetId returns 400.

Update & delete

PATCH …/alert-rules/{ruleId} accepts the same fields — send only what changes (e.g. { "enabled": false } to pause a rule). DELETE …/alert-rules/{ruleId} removes it.

curl -X PATCH "https://api.treedis.com/v2/api/workspaces/7/operations/alert-rules/9" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{ "value": 85, "enabled": true }'

curl -X DELETE "https://api.treedis.com/v2/api/workspaces/7/operations/alert-rules/9" \
  -H "Authorization: Bearer your-access-token"

Reading raised alerts

GET /v2/api/workspaces/{workspaceId}/operations/alerts returns the incident feed. Filter with ?status= (open · acknowledged · resolved), ?severity=, ?cwAssetId=, ?cwLocationId=, and page with ?page= / ?limit=.

curl "https://api.treedis.com/v2/api/workspaces/7/operations/alerts?status=open&severity=critical" \
  -H "Authorization: Bearer your-access-token"
{
  "success": true, "code": 200, "message": "Success",
  "data": {
    "alerts": [
      {
        "id": 500, "severity": "critical", "status": "open",
        "sensorId": 42, "cwAssetId": 1001, "assetName": "Centrifugal Pump",
        "triggerValue": 83.1, "message": "High pump temp", "triggerAt": "2026-07-08T09:02:00Z"
      }
    ],
    "total": 1
  }
}

Pushing alerts directly

If your source system already computes its own alerts, push them alongside readings on the Sensors readings endpoint via the alerts[] array. Each alert is keyed by a stable externalRef so re‑sending is idempotent — status: "open" opens it (once), status: "resolved" closes it.

curl -X POST "https://api.treedis.com/v2/api/workspaces/7/operations/sensors/readings" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{
    "alerts": [
      {
        "externalRef": "scada-evt-8842",
        "sensorRef": "pump-a-temp",
        "severity": "critical",
        "status": "open",
        "message": "Overheat trip"
      }
    ]
  }'

Errors

Errors use the standard envelope with success: false:

{ "success": false, "code": 400, "message": "A threshold rule must target a sensorId or a cwAssetId" }
Status When
400 Validation failed, or a rule with no sensorId/cwAssetId target
404 Rule not found in this workspace

See the Connected Workers Alerts tag in the API Reference for the full request and response schemas, and the Sensors guide for registering sensors and pushing their data.