Last updated

Alerts Guide

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.

Step 1: Get Your API Key

  1. Create your account and log in.
  2. Navigate to your dashboard to retrieve your API key or, depending on your representative, you may have been sent a key.
  3. If you don't have an API key, please contact your representative.

Your API key is required to authenticate all API requests.


Step 2: Retrieve a List of Alerts

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.

Example Request

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 to true to retrieve only unresolved alerts.
  • resolved: Set to true to retrieve only resolved alerts.
  • space.id: Filter by space ID.
  • alertRule.id: Filter by a specific alert rule.

Example Request with Filters

curl -X GET "https://api.wia.io/v1/alerts?unresolved=true&space.id=spc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"

Response Example

[
  {
    "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.


Step 3: Retrieve Details of a Specific Alert

If you have an alert ID, you can fetch detailed information about that specific alert.

Example Request

curl -X GET "https://api.wia.io/v1/alerts/{id}" \
-H "Authorization: Bearer YOUR_API_KEY"

Replace {id} with the actual alert ID.

Response Example

{
  "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.


Step 4: Resolve an Alert

Once an alert has been addressed, you can update its resolution status.

Example Request

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.

Response Example

{
  "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.