How monitoring works
This guide describes how to use monitoring to listen for changes associated with subscribed businesses on Middesk’s Identity Platform.
Prerequisites
Before you begin:
- Ensure that you can authenticate against the Middesk API, create businesses, and ingest Middesk results with webhooks
Learn the monitoring lifecycle
Here’s the typical lifecycle of a business with monitoring enabled:
- A business gets created with the POST /businesses endpoint.
- The business is subscribed to monitoring.
- At some point in the future, a change to that business is detected. The business record updates.
- Middesk sends a webhook event to registered webhook endpoint(s).
- The client application ingests and evaluates the change in the business record.
Monitor businesses
Subscribe a business
You can enable monitoring on Middesk businesses using four different strategies.
With the API
With the Dashboard
Use the POST /monitor API to create, update, and delete business monitors for fine-grained control within your application.
Manually enable monitoring on a business with a completed business verification order on the Monitoring tab of the Middesk Dashboard.
Set up and listen for monitoring webhook events
Depending on the type of monitor that you want to listen for, register a new webhook with the corresponding event types selected.
Consume and evaluate monitoring events
Webhook requests contain a few top level fields:
-
data. Contains the event-specific payload and all the information about a monitoring event.Event payloads represent the change identified in the business record rather than full business object. For more granular control, use event payloads. -
id. The Middesk-generated identifier for the webhook. It’s useful for debugging. Use it to search for pertinent webhook logs on the Middesk webhooks page. -
type. The type of webhook provided. -
account_id. The Middesk-generated identifier for the account the webhook is sent for. Useful if you route traffic across multiple Middesk accounts.
While it’s possible to consume monitoring-specific payloads (example payloads), for typical use cases, it’s usually sufficient to retrieve the business associated with the event.
To retrieve the business associated with the event:
-
Access the business’s ID using the
data.object.business_idfield included in the webhook payload. -
Retrieve the Middesk business using the GET /businesses endpoint.
The response includes the full business record.