Skip to content

Notifications

The platform records a notification history entry whenever it sends a status or threshold alert, or when alert settings change. These endpoints read that history and switch email / WhatsApp / SMS alerts on or off for a device.

Responses use the standard {"success": ...} / {"failed": ...} envelope. Alarm thresholds are configured separately, see Alarms.

Notification history

GET/notification/history

Returns the user's notification history for a time range

Request

Auth: api_key (query param or cookie)

Request body:

The fields can be sent as query parameters or as a JSON body (query parameters win). Only entries belonging to the user are returned.

Field name Description Type
min_epoch_tm_sec Start of the range (epoch seconds) float
max_epoch_tm_sec [Optional] End of the range (epoch seconds). Defaults to the current time float
device_id [Optional] Only return entries for this device. All devices if not specified int

Request example:

https://spoilerinterface.com/interface/notification/history?api_key=8f14e45fceea167a5a36dedd4bea2543&min_epoch_tm_sec=1716163200&device_id=301659085216623

Response

{
    "success": [
        {
            "device_id": 301659085216623,
            "device_name": "Door sensor",
            "device_type": "sensor",
            "notification_message": "Door sensor status has changed to Offline. Email sent to user@example.com.",
            "notification_time": "2024-05-24T12:10:00"
        }
    ]
}

Field description

Field name Description Type
device_id ID of the device int
device_name Name of the device str
device_type Device type str
notification_message Message text str
notification_time Date-time of the notification, shifted by the user's time offset str

Enable or disable alerts

POST/notifications/{device_type}/{alert_type}/{action}

Enables or disables email, WhatsApp or SMS alerts for one device

Request

Auth: api_key (query param or cookie) and Device id + token ยท Content-type: application/json

Path parameters:

Parameter Values Description
device_type sensor, switch, batmon, met, gps, ws / workstation, ping / device, interface Type of the device. Matching is case-insensitive, except interface which must be lower case. Use interface (not dynamic) for dynamic interfaces
alert_type alerts (also alert, notifications) Email status/threshold alerts (notification_enabled)
whatsapp WhatsApp alerts (whatsapp_enabled)
sms SMS alerts (sms_enabled)
action enable, disable New state

Request body:

The device credentials can be sent as query parameters or as a JSON body.

Field name Description Type
device_id ID of the device int
device_token Token of the device str

Request example:

POST https://spoilerinterface.com/interface/notifications/sensor/whatsapp/enable?api_key=8f14e45fceea167a5a36dedd4bea2543

{
    "device_id": 301659085216623,
    "device_token": "df45ddddsdaewg56df6"
}

Response

{
    "success": "success"
}

A history entry such as Whatsapp notifications enabled is recorded for the device.

Failures: Missing device_id or device_token, Invalid device type., Invalid device information (id/token do not match), Invalid alert type or action.