Configure Device Events Use Case
Use this example as a model to create webhooks that alert you of device events as they occur for the devices in your deployment.
For this use case, let’s say you want to receive a webhook notification anytime a device,
such as an access point (AP), disconnects from the cloud for longer than the configured
threshold. To configure this notification, you must configure the Device
Events
webhook. See Create Webhooks from the API or Add a Webhook in the Juniper Mist
Portal for steps on how to create webhooks.
It is useful to receive notifications for Device Events
because it brings
the exact device and its respective issue to your attention. When a device goes offline, for
example, every time that event triggers, the cloud sends a webhook notification directly to a
hosted system. The system can parse events and use this event as a trigger to run
automations.
Device Events
webhook topic,
you will be notified of any events that affect APs, gateways, and switches. This topic
includes events such as ap_offline
, device_down
,
switch_down
, device_restarted
,
gateway_down
, and switch_restarted
.Continuing with the example, anytime a device goes offline, Juniper Mist will create a webhook POST to the specified URL. The incoming request payload contains details such as the org_id, site_id, mac, device_name, and timestamp of the event. The JSON payload looks like this:
curl -X POST \ --url 'https://api.mist.com/webhook_example/_device_events_' \ -H 'Content-Type: application/json' \ --data-raw '{ "events": [ { "ap": "5c5b350e55c8", "ap_name": "ap_name6", "audit_id": "78c04fa6-cfb4-46a0-9aa5-3681ba4f3897", "device_name": "device_name4", "device_type": "ap", "ev_type": "notice", "mac": "mac2", "reason": "device offline", "site_name": "office", "text": "offline", "type": "ap_offline" } ], "topic": "device_events" }'