Creating webhooks in XProtect
To create and configure a webhook, you should:
- Create the webhook URL.
- Create a webhook in Management Client.
- Create a rule to trigger the webhook in Management Client.
- Test the webhook rule and actions from XProtect (Optional).
1. Create the webhook URL
Generate or obtain the URL of the webserver or application you want to send event data to.
The URL must be static and secure as the URL will be registered in XProtect and used repeatedly to receive event data from XProtect.
If the URL of the webserver is updated, you must update the webhook URL in XProtect.
You can use http:// instead of https://, but using http:// through non-secure networks may expose event data in plain text. Using the more secure https:// is strongly recommended.
2. Create a webhook in Management Client
- In Management Client > Rules and Events > Webhooks, right-click Webhooks and select Add New…
- In Webhook Information:
- Name field: Enter a unique name for the webhook.
- Address field: Enter the URL for the webhook starting with https://. You can use http:// instead of https://, but using http:// through non-secure networks may expose event data in plain text. Using the more secure https:// is strongly recommended.
- Token (optional) field: Enter a token if you want to sign the webhooks requests.
- Click Save in the toolbar to save the new webhook.
3. Create a rule to trigger the webhook
- In Management Client > Rules and Events > Rules, right-click Rules and select Add Rule… to start the Manage Rule wizard at Step 1: Type of rule.
- In Step 1: Type of rule, specify a name and a description of the new rule in the Name and Description fields respectively.
- In the Select the rule type you want you to create pane, select Perform an action on <event>.
- In the Edit the rule description pane, click event and select an event.
- Click OK to create the event.
- Click Next to go to Step 2: Conditions.
- In Step 2: Conditions, apply any conditions relevant to the event you are creating.
- Click Next to go to Step 3: Actions.
- In Step 3: Actions, scroll down and select Send event info to <webhooks>.
- Click address on the Edit the rule description pane.
- Add a predefined webhook and click OK.
- Click Next to go to the wizard's third step.
- In Step 4: Stop criteria, click Finish to create the rule.
When the event you have created is triggered, an HTTP POST will be sent to the URL you configured in the Address field of the webhook specified for the event.
The payload (body) of the HTTP POST will contain event data from the event that triggered the rule.
Depending on your requirements, you may also have to set up a procedure on the webhook receiver to process the HTTP POST requests and react on the received event data.
4. Test the webhook from XProtect (Optional)
You should test the event to verify that the event triggers and performs the actions you define before utilizing the event and webhook in daily operations.
- Open Management Client > Rules and Events and select the event you want to test.
- Click Test Event to test the event.
- Verify that the actions defined for the event have been successfully performed, for example an email or SMS has been sent, scripts have been run, alarms have been updated, etc.