Notifications
Notification rules are an object which controls when notifications are generated and how they are distributed (actions).
Notifications are a way of updating third party systems of particular events or event combinations. Notifications can be configured using either a browser or via the API.
Notifications operate on an event, and action when a set of conditions are met for that event.
Action Outputs are currently either a Dashboard notification, Slack notification or webhook notification (HTTP/HTTPS supported).
List all notification rules
To return a list of all of your notification rules:
GET /api/3/notification_rules
Example Response
[
    {
        "id": 6,
        "name": "Tamper Alert",
        "active": true,
        "conditions": [
            {
                "type": "door_controller_id",
                "type_description": "Channel",
                "value": "3050"
            },
            {
                "type": "door_controller_id",
                "type_description": "Channel",
                "value": "3048"
            }
        ],
        "events": [
            {
                "code": 90,
                "name": "Tamper detected"
            }
        ],
        "actions": [
            {
                "type": 0,
                "type_description": "POST to URL",
                "data": "https://www.example.com/doorflow/webhook"
            }
        ]
    }
]
Create a notification rule
POST /api/3/notification_rules
Example Request Payload
{
    "name": "New notification",
    "active": true,
    "match_event_codes": [
        1,
        2,
        3
    ],
    "match_controller_ids": [
        1056,
        2941
    ],
    "call_back_url": "https://www.example.com/doorflow/webhook",
    "match_action": "post_to_callback_url"
}
Example Response
{
    "id": 10,
    "name": "New notification",
    "active": true,
    "conditions": [
        {
            "type": "door_controller_id",
            "type_description": "Channel",
            "value": "1056"
        },
        {
            "type": "door_controller_id",
            "type_description": "Channel",
            "value": "2941"
        }
    ],
    "events": [
        {
            "code": 1,
            "name": "Channel started"
        },
        {
            "code": 2,
            "name": "Channel stopped"
        },
        {
            "code": 3,
            "name": "Channel contact lost"
        }
    ],
    "actions": [
        {
            "type": 0,
            "type_description": "POST to URL",
            "data": "https://www.example.com/doorflow/webhook"
        }
    ]
}
Note that the response will list the type of action matched where:
| type | POST attribute | POST value | description | 
|---|---|---|---|
| 0 | match_action | posttocallback_url | POST to URL | 
Update a notification rule
PUT /api/3/notification_rules/:id
{
    "name": "New notification rule name"
}
Example Response
[
    {
        "id": 6,
        "name": "New notification rule name",
        "active": true,
        "conditions": [
            {
                "type": "door_controller_id",
                "type_description": "Channel",
                "value": "3050"
            },
            {
                "type": "door_controller_id",
                "type_description": "Channel",
                "value": "3048"
            }
        ],
        "events": [
            {
                "code": 90,
                "name": "Tamper detected"
            }
        ],
        "actions": [
            {
                "type": 0,
                "type_description": "POST to URL",
                "data": "https://www.example.com/doorflow/webhook"
            }
        ]
    }
]
Delete a notification rule
DELETE /api/3/notification_rules/:id
Example Response
{ result: "ok" }