Skip to content

Alerts API

Create and manage alert rules programmatically.

Get all alert rules.

GET /v1/alerts
ParameterTypeDescription
pagenumberPage number
limitnumberItems per page
device_idstringFilter by device
enabledbooleanFilter by status
Terminal window
curl -X GET "https://api.siliconwit.io/v1/alerts" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"success": true,
"data": [
{
"id": "alert_abc123",
"name": "High Temperature",
"device_id": "dev_abc123",
"condition": {
"field": "temperature",
"operator": "gt",
"value": 35
},
"actions": ["email"],
"enabled": true,
"created_at": "2024-01-01T00:00:00Z"
}
]
}

Create a new alert rule.

POST /v1/alerts
FieldTypeRequiredDescription
namestringYesAlert name
device_idstringYesDevice to monitor
conditionobjectYesTrigger condition
actionsarrayYesNotification actions
severitystringNoinfo, warning, critical
cooldownnumberNoSeconds between alerts
FieldTypeDescription
fieldstringData field to monitor
operatorstringgt, lt, eq, ne, between
valueanyThreshold value
durationnumberSustained seconds
Terminal window
curl -X POST "https://api.siliconwit.io/v1/alerts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "High Temperature Alert",
"device_id": "dev_abc123",
"condition": {
"field": "temperature",
"operator": "gt",
"value": 35,
"duration": 300
},
"actions": ["email", "webhook"],
"severity": "critical",
"cooldown": 3600
}'
{
"success": true,
"data": {
"id": "alert_xyz789",
"name": "High Temperature Alert",
"device_id": "dev_abc123",
"condition": {
"field": "temperature",
"operator": "gt",
"value": 35,
"duration": 300
},
"actions": ["email", "webhook"],
"severity": "critical",
"cooldown": 3600,
"enabled": true,
"created_at": "2024-01-15T15:00:00Z"
}
}

Modify an existing alert rule.

PUT /v1/alerts/:id
Terminal window
curl -X PUT "https://api.siliconwit.io/v1/alerts/alert_xyz789" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"condition": {
"field": "temperature",
"operator": "gt",
"value": 40
},
"enabled": true
}'

Remove an alert rule.

DELETE /v1/alerts/:id
Terminal window
curl -X DELETE "https://api.siliconwit.io/v1/alerts/alert_xyz789" \
-H "Authorization: Bearer YOUR_API_KEY"

Toggle alert status.

POST /v1/alerts/:id/enable
POST /v1/alerts/:id/disable
Terminal window
curl -X POST "https://api.siliconwit.io/v1/alerts/alert_xyz789/disable" \
-H "Authorization: Bearer YOUR_API_KEY"

Get triggered alert history.

GET /v1/alerts/history
ParameterTypeDescription
fromstringStart time
tostringEnd time
alert_idstringFilter by alert rule
device_idstringFilter by device
severitystringFilter by severity
acknowledgedbooleanFilter by ack status
Terminal window
curl -X GET "https://api.siliconwit.io/v1/alerts/history?\
from=2024-01-01&severity=critical" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"success": true,
"data": [
{
"id": "event_abc123",
"alert_id": "alert_xyz789",
"alert_name": "High Temperature Alert",
"device_id": "dev_abc123",
"device_name": "Office Sensor",
"condition": "temperature > 35",
"value": 38.5,
"severity": "critical",
"triggered_at": "2024-01-15T14:30:00Z",
"acknowledged": true,
"acknowledged_at": "2024-01-15T14:35:00Z",
"acknowledged_by": "[email protected]"
}
]
}

Mark an alert event as acknowledged.

POST /v1/alerts/history/:event_id/acknowledge
FieldTypeDescription
notestringOptional note
Terminal window
curl -X POST "https://api.siliconwit.io/v1/alerts/history/event_abc123/acknowledge" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"note": "Checked sensor, was near heat source"
}'
OperatorDescriptionExample
gtGreater than> 35
gteGreater than or equal>= 35
ltLess than< 10
lteLess than or equal<= 10
eqEquals= 100
neNot equals!= 0
betweenBetween range[20, 30]
outsideOutside rangenot [20, 30]
ActionDescriptionPlan
emailSend emailAll
smsSend SMSBusiness+
webhookCall URLAll
pushPush notificationComing soon

When using webhook action:

{
"alert_id": "alert_xyz789",
"alert_name": "High Temperature Alert",
"device_id": "dev_abc123",
"device_name": "Office Sensor",
"condition": "temperature > 35",
"current_value": 38.5,
"severity": "critical",
"triggered_at": "2024-01-15T14:30:00Z",
"dashboard_url": "https://siliconwit.io/dashboard/devices/dev_abc123"
}
CodeDescription
ALERT_NOT_FOUNDAlert ID doesn’t exist
INVALID_CONDITIONMalformed condition object
INVALID_OPERATORUnknown operator
DEVICE_NOT_FOUNDReferenced device doesn’t exist