PT EN

Regras de alarme

URL base: $BUSINESS_API

O objecto

idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional
O objecto
{
  "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "critical",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ],
  "active": true
}

Listar regras de alarme

Registos

GET /alarm-rules

Returns the tenant's alarm rules, both active and inactive, newest first, with cursor pagination (limit defaults to 20, at most 100). Each rule carries its source, comparison, threshold, clear threshold, severity and whether it is currently evaluated.

Parâmetros

sourcestring · consulta · opcional

Return only rules that watch this source: telemetry (sensor readings) or quality (water quality sample results); omit to return both.

limitinteger · consulta · opcional

Maximum resources to return (default 20, maximum 100).

afterstring · consulta · opcional

Opaque cursor returned by the previous page.

Devolve

200 OK

Mostrar atributos
dataarray of AlarmRule · opcional
Mostrar atributos filhos
idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional
has_moreboolean · opcional
next_cursorstring · opcional

Erros 400 · 403

Permissões business:monitoring:read · Funções: admin, analyst, field_supervisor, operations, owner, viewer

curl -X GET "$BUSINESS_API/alarm-rules" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "data": [
    {
      "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
      "name": "Ana Matsinhe",
      "source": "telemetry",
      "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
      "parameter": "parameter",
      "comparison": "above",
      "threshold": 1,
      "clear_threshold": 1,
      "severity": "critical",
      "event_type": "event type",
      "notify_phones": [
        "+258841234567"
      ],
      "active": true
    }
  ],
  "has_more": true,
  "next_cursor": "next cursor"
}

Criar uma regra de alarme

Registos

POST /alarm-rules

A telemetry rule needs a sensor_id that exists in the tenant, and a quality rule needs a known water quality parameter. comparison must be above or below; an alarm opens when a value crosses threshold and closes automatically only when a value returns past clear_threshold, which defaults to threshold and must sit on the safe side of it. severity defaults to warning (critical, warning or info) and event_type to alarm.opened; the rule is created active and returns 201, with 400 for any failed check.

Corpo application/json

namestring · obrigatório
sourcestring · obrigatório

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · obrigatório

um de above, below

thresholdnumber · obrigatório
clear_thresholdnumber · opcional
severitystring · opcional
event_typestring · opcional
notify_phonesarray of string · opcional

Devolve

201 OK

Mostrar atributos
idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional

Erros 400 · 403

Permissões business:alarms:manage · Funções: admin, operations, owner

curl -X POST "$BUSINESS_API/alarm-rules" \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "severity",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ]
}'
Resposta 201
{
  "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "critical",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ],
  "active": true
}

Obter uma regra de alarme

Registos

GET /alarm-rules/{id}

Returns one alarm rule of the tenant with its thresholds, severity, notification phones and active flag. Answers 404 when the rule does not exist in the caller's tenant.

Parâmetros

idstring · caminho · obrigatório

Identifier of the alarm rule, as returned when it was created (prefix mrl_).

Devolve

200 OK

Mostrar atributos
idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional

Erros 400 · 403

Permissões business:monitoring:read · Funções: admin, analyst, field_supervisor, operations, owner, viewer

curl -X GET "$BUSINESS_API/alarm-rules/{id}" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "critical",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ],
  "active": true
}

Activar uma regra de alarme

Registos

POST /alarm-rules/{id}/activate

Marks the rule active so new telemetry readings or quality results are evaluated against it again, and returns the updated rule. The call is idempotent: activating an active rule only refreshes its update time. Existing alarms are not changed.

Parâmetros

idstring · caminho · obrigatório

Identifier of the alarm rule to activate (prefix mrl_).

Devolve

200 OK

Mostrar atributos
idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional

Erros 400 · 403

Permissões business:alarms:manage · Funções: admin, operations, owner

curl -X POST "$BUSINESS_API/alarm-rules/{id}/activate" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "critical",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ],
  "active": true
}

Desactivar uma regra de alarme

Registos

POST /alarm-rules/{id}/deactivate

Marks the rule inactive so incoming readings and results no longer open, update or auto-clear alarms for it, and returns the updated rule. Alarms it already opened stay as they are and can still be acknowledged or resolved by hand. The call is idempotent.

Parâmetros

idstring · caminho · obrigatório

Identifier of the alarm rule to deactivate (prefix mrl_).

Devolve

200 OK

Mostrar atributos
idstring · opcional
namestring · opcional
sourcestring · opcional

um de telemetry, quality

sensor_idstring · opcional
parameterstring · opcional
comparisonstring · opcional

um de above, below

thresholdnumber · opcional
clear_thresholdnumber · opcional
severitystring · opcional

um de critical, warning, info

event_typestring · opcional
notify_phonesarray of string · opcional
activeboolean · opcional

Erros 400 · 403

Permissões business:alarms:manage · Funções: admin, operations, owner

curl -X POST "$BUSINESS_API/alarm-rules/{id}/deactivate" \
  -H "Authorization: Bearer sk_test_..."
Resposta 200
{
  "id": "ala_2Go3hsIph0iVZogl5Q41rKAV1E4",
  "name": "Ana Matsinhe",
  "source": "telemetry",
  "sensor_id": "sen_28o3p46TDQsRdq8pzycV5cIxbMg",
  "parameter": "parameter",
  "comparison": "above",
  "threshold": 1,
  "clear_threshold": 1,
  "severity": "critical",
  "event_type": "event type",
  "notify_phones": [
    "+258841234567"
  ],
  "active": true
}