Skip to main content

Alert rules

6 operations at https://api.zaitrack.app. Request and response bodies are JSON with camelCase keys; ids are UUIDs; times are RFC 3339 in UTC.

Every operation needs an API key, a personal access token or an OAuth access token unless it says otherwise. An Idempotency-Key is replayed for 24 hours; see Idempotency. Errors are application/problem+json; see Errors.

List alert rules​

GET /v1/alert-rules

  • Scope: alerts:read or alerts:*
  • Rate class: read (100 per second and 360,000 per hour)
  • Idempotency-Key: not used
  • Audited: no
  • Step-up MFA: no

Request​

No body.

Response​

200: fields the handler writes, taken from its source.

FieldTypeNotes
itemsarray of object
items[].idstringomitted when empty
items[].namestring
items[].kindstring
items[].severitystring
items[].enabledbooleanomitted when empty
items[].paramsobject
items[].params.thresholdKphnumberomitted when empty
items[].params.minDurationSecintegeromitted when empty
items[].params.minMinutesintegeromitted when empty
items[].params.minVoltsnumberomitted when empty
items[].params.geofenceIdstring (UUID)omitted when empty
items[].params.geofenceCategorystringomitted when empty
items[].params.onstringomitted when empty
items[].params.minDefectstringomitted when empty
items[].params.minSeveritystringomitted when empty
items[].params.eventsarray of stringomitted when empty
items[].params.vehicleLimitbooleanomitted when empty
items[].vehicleIdsarray of string
items[].ackBeforeResolveboolean
items[].windowobject
items[].window.modestringomitted when empty
items[].window.spansarray of objectomitted when empty
items[].window.spans[].dayinteger
items[].window.spans[].startstring
items[].window.spans[].endstring
items[].throttleobject
items[].throttle.maxintegeromitted when empty
items[].throttle.perMinutesintegeromitted when empty
items[].driverIdsarray of string
items[].geofenceIdsarray of string
items[].titleTemplatestring
items[].createdAtstringomitted when empty
items[].updatedAtstringomitted when empty
items[].versionintegeromitted when empty

Example​

curl "https://api.zaitrack.app/v1/alert-rules" \
-H "Authorization: Bearer zk_test_…"

Create an alert rule​

POST /v1/alert-rules

  • Scope: rules:write or rules:*
  • Rate class: write (50 per second and 36,000 per hour)
  • Idempotency-Key: optional
  • Audited: low risk
  • Step-up MFA: no

Request​

Fields the handler reads, taken from its source.

FieldTypeNotes
idstringoptional
namestring
kindstring
severitystring
enabledbooleanoptional
paramsobject
params.thresholdKphnumberoptional
params.minDurationSecintegeroptional
params.minMinutesintegeroptional
params.minVoltsnumberoptional
params.geofenceIdstring (UUID)optional
params.geofenceCategorystringoptional
params.onstringoptional
params.minDefectstringoptional
params.minSeveritystringoptional
params.eventsarray of stringoptional
params.vehicleLimitbooleanoptional
vehicleIdsarray of string
ackBeforeResolveboolean
windowobject
window.modestringoptional
window.spansarray of objectoptional
window.spans[].dayinteger
window.spans[].startstring
window.spans[].endstring
throttleobject
throttle.maxintegeroptional
throttle.perMinutesintegeroptional
driverIdsarray of string
geofenceIdsarray of string
titleTemplatestring
createdAtstringoptional
updatedAtstringoptional
versionintegeroptional

Response​

201: fields the handler writes, taken from its source.

FieldTypeNotes
idstringomitted when empty
namestring
kindstring
severitystring
enabledbooleanomitted when empty
paramsobject
params.thresholdKphnumberomitted when empty
params.minDurationSecintegeromitted when empty
params.minMinutesintegeromitted when empty
params.minVoltsnumberomitted when empty
params.geofenceIdstring (UUID)omitted when empty
params.geofenceCategorystringomitted when empty
params.onstringomitted when empty
params.minDefectstringomitted when empty
params.minSeveritystringomitted when empty
params.eventsarray of stringomitted when empty
params.vehicleLimitbooleanomitted when empty
vehicleIdsarray of string
ackBeforeResolveboolean
windowobject
window.modestringomitted when empty
window.spansarray of objectomitted when empty
window.spans[].dayinteger
window.spans[].startstring
window.spans[].endstring
throttleobject
throttle.maxintegeromitted when empty
throttle.perMinutesintegeromitted when empty
driverIdsarray of string
geofenceIdsarray of string
titleTemplatestring
createdAtstringomitted when empty
updatedAtstringomitted when empty
versionintegeromitted when empty

Example​

Every field is sent with a placeholder value: replace them with yours.

curl -X POST "https://api.zaitrack.app/v1/alert-rules" \
-H "Authorization: Bearer zk_test_…" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"id": "…", "name": "…", "kind": "…", "severity": "…", "enabled": false, "params": {"thresholdKph": 0, "minDurationSec": 0, "minMinutes": 0, "minVolts": 0, "geofenceId": "00000000-0000-0000-0000-000000000000", "geofenceCategory": "…", "on": "…", "minDefect": "…", "minSeverity": "…", "events": [], "vehicleLimit": false}, "vehicleIds": [], "ackBeforeResolve": false, "window": {"mode": "…", "spans": []}, "throttle": {"max": 0, "perMinutes": 0}, "driverIds": [], "geofenceIds": [], "titleTemplate": "…", "createdAt": "…", "updatedAt": "…", "version": 0}'

Get an alert rule​

GET /v1/alert-rules/{id}

  • Scope: alerts:read or alerts:*
  • Rate class: read (100 per second and 360,000 per hour)
  • Idempotency-Key: not used
  • Audited: no
  • Step-up MFA: no

Path parameters: id.

Request​

No body.

Response​

200: fields the handler writes, taken from its source.

The same fields as the response of Create an alert rule.

Example​

curl "https://api.zaitrack.app/v1/alert-rules/$ID" \
-H "Authorization: Bearer zk_test_…"

Update an alert rule​

PATCH /v1/alert-rules/{id}

  • Scope: rules:write or rules:*
  • Rate class: write (50 per second and 36,000 per hour)
  • Idempotency-Key: not used
  • Audited: low risk
  • Step-up MFA: no
  • If-Match: the version you read; a stale one is refused (412 or 409)

Path parameters: id.

Request​

Fields the handler reads, taken from its source.

FieldTypeNotes
namestringoptional
severitystringoptional
enabledbooleanoptional
paramsobjectoptional
params.thresholdKphnumberoptional
params.minDurationSecintegeroptional
params.minMinutesintegeroptional
params.minVoltsnumberoptional
params.geofenceIdstring (UUID)optional
params.geofenceCategorystringoptional
params.onstringoptional
params.minDefectstringoptional
params.minSeveritystringoptional
params.eventsarray of stringoptional
params.vehicleLimitbooleanoptional
vehicleIdsarray of stringoptional
ackBeforeResolvebooleanoptional
windowobjectoptional
window.modestringoptional
window.spansarray of objectoptional
window.spans[].dayinteger
window.spans[].startstring
window.spans[].endstring
throttleobjectoptional
throttle.maxintegeroptional
throttle.perMinutesintegeroptional
driverIdsarray of stringoptional
geofenceIdsarray of stringoptional
titleTemplatestringoptional

Response​

200: fields the handler writes, taken from its source.

The same fields as the response of Create an alert rule.

Example​

Every field is sent with a placeholder value: replace them with yours.

curl -X PATCH "https://api.zaitrack.app/v1/alert-rules/$ID" \
-H "Authorization: Bearer zk_test_…" \
-H 'If-Match: "3"' \
-H "Content-Type: application/json" \
-d '{"name": "…", "severity": "…"}'

Delete an alert rule​

DELETE /v1/alert-rules/{id}

  • Scope: rules:write or rules:*
  • Rate class: write (50 per second and 36,000 per hour)
  • Idempotency-Key: not used
  • Audited: low risk
  • Step-up MFA: no

Path parameters: id.

Request​

No body.

Response​

204: no body.

Example​

curl -X DELETE "https://api.zaitrack.app/v1/alert-rules/$ID" \
-H "Authorization: Bearer zk_test_…"

Dry-run an alert rule​

POST /v1/alert-rules:test

  • Scope: rules:read or rules:*
  • Rate class: read (100 per second and 360,000 per hour)
  • Idempotency-Key: not used
  • Audited: no
  • Step-up MFA: no

Request​

Fields the handler reads, taken from its source.

FieldTypeNotes
ruleIdstring
ruleobjectoptional
rule.idstringoptional
rule.namestring
rule.kindstring
rule.severitystring
rule.enabledbooleanoptional
rule.paramsobject
rule.params.thresholdKphnumberoptional
rule.params.minDurationSecintegeroptional
rule.params.minMinutesintegeroptional
rule.params.minVoltsnumberoptional
rule.params.geofenceIdstring (UUID)optional
rule.params.geofenceCategorystringoptional
rule.params.onstringoptional
rule.params.minDefectstringoptional
rule.params.minSeveritystringoptional
rule.params.eventsarray of stringoptional
rule.params.vehicleLimitbooleanoptional
rule.vehicleIdsarray of string
rule.ackBeforeResolveboolean
rule.windowobject
rule.window.modestringoptional
rule.window.spansarray of objectoptional
rule.window.spans[].dayinteger
rule.window.spans[].startstring
rule.window.spans[].endstring
rule.throttleobject
rule.throttle.maxintegeroptional
rule.throttle.perMinutesintegeroptional
rule.driverIdsarray of string
rule.geofenceIdsarray of string
rule.titleTemplatestring
rule.createdAtstringoptional
rule.updatedAtstringoptional
rule.versionintegeroptional
deviceIdstring
fromstring
tostring

Response​

200: fields the handler writes, taken from its source.

FieldTypeNotes
kind—
params—
pointsinteger
truncatedboolean
wouldAlert—
episodesarray of object
episodes[].startedAt—
episodes[].raisedAt—
episodes[].clearedAt—
episodes[].worst—
episodes[].heldBy—
episodes[].title—

Example​

Every field is sent with a placeholder value: replace them with yours.

curl -X POST "https://api.zaitrack.app/v1/alert-rules:test" \
-H "Authorization: Bearer zk_test_…" \
-H "Content-Type: application/json" \
-d '{"ruleId": "…", "rule": {"id": "…", "name": "…", "kind": "…", "severity": "…", "enabled": false, "params": {"thresholdKph": 0, "minDurationSec": 0, "minMinutes": 0, "minVolts": 0, "geofenceId": "00000000-0000-0000-0000-000000000000", "geofenceCategory": "…", "on": "…", "minDefect": "…", "minSeverity": "…", "events": [], "vehicleLimit": false}, "vehicleIds": [], "ackBeforeResolve": false, "window": {"mode": "…", "spans": []}, "throttle": {"max": 0, "perMinutes": 0}, "driverIds": [], "geofenceIds": [], "titleTemplate": "…", "createdAt": "…", "updatedAt": "…", "version": 0}, "deviceId": "…", "from": "…", "to": "…"}'