Welcome to the Wia Alerts API guide! Alerts provide critical information about system anomalies, such as devices going offline or specific alert rules being triggered. This guide will help you use the Alerts API to monitor and resolve alerts effectively.
- Create your account and log in.
- Navigate to your dashboard to retrieve your API key or, depending on your representative, you may have been sent a key.
- If you don't have an API key, please contact your representative.
Your API key is required to authenticate all API requests.
The first step is to retrieve a list of alerts in your system. You can filter by resolution status, associated product, space, or other parameters.
Use the following curl command to retrieve all alerts:
curl -X GET "https://api.wia.io/v1/alerts" \
-H "Authorization: Bearer YOUR_API_KEY"You can also include optional query parameters to refine the results, such as:
unresolved: Set totrueto retrieve only unresolved alerts.resolved: Set totrueto retrieve only resolved alerts.space.id: Filter by space ID.alertRule.id: Filter by a specific alert rule.
curl -X GET "https://api.wia.io/v1/alerts?unresolved=true&space.id=spc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"[
{
"id": "alt_abcdef12345678",
"note": "Temperature threshold exceeded",
"firstSeenAt": "2024-12-10T08:00:00Z",
"resolvedAt": null,
"acknowledgedAt": null,
"device": {
"id": "dev_abc123",
"name": "Temperature Sensor"
}
},
{
"id": "alt_ghijk12345678",
"note": "Device went offline",
"firstSeenAt": "2024-12-09T12:00:00Z",
"resolvedAt": "2024-12-10T09:00:00Z",
"acknowledgedAt": "2024-12-10T08:30:00Z",
"device": {
"id": "dev_def456",
"name": "Smart Meter"
}
}
]This response provides a list of alerts with their details, such as timestamps, notes, and associated devices.
If you have an alert ID, you can fetch detailed information about that specific alert.
curl -X GET "https://api.wia.io/v1/alerts/{id}" \
-H "Authorization: Bearer YOUR_API_KEY"Replace {id} with the actual alert ID.
{
"id": "alt_abcdef12345678",
"note": "Temperature threshold exceeded",
"firstSeenAt": "2024-12-10T08:00:00Z",
"lastSeenAt": "2024-12-10T08:15:00Z",
"resolvedAt": null,
"acknowledgedAt": null,
"device": {
"id": "dev_abc123",
"name": "Temperature Sensor"
},
"alertRule": {
"id": "altRule_001",
"name": "High Temperature Alert"
}
}This response provides detailed information about the alert, including its timestamps, associated device, and alert rule.
Once an alert has been addressed, you can update its resolution status.
curl -X PUT "https://api.wia.io/v1/alerts/{id}/resolve" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"resolvedAt": 1702195200000
}'resolvedAt: The timestamp (in milliseconds) when the alert was resolved.
Replace {id} with the alert ID.
{
"id": "alt_abcdef12345678",
"note": "Temperature threshold exceeded",
"resolvedAt": "2024-12-10T10:00:00Z",
"acknowledgedAt": "2024-12-10T08:30:00Z",
"device": {
"id": "dev_abc123",
"name": "Temperature Sensor"
}
}This response confirms that the alert has been resolved.