Using external triggers and webhooks
Last modified: Friday June 09, 2023.
When creating a rule, you can configure an external trigger to activate and deactivate the rule.
- For example, you could arm an alarm system that sends data to a webhook in Alta Video that activates one or more rules.
- Disarming the alarm system could send data to the same webhook, deactivating the same rules if they are active.
- To activate or deactivate multiple rules at the same time, associate each rule with the same trigger in Alta Video.
To create an external trigger for a rule in Alta Video, see Activate and Deactivate rules from an external system.
For more information on creating webhooks, see Create webhooks to send Alta Video notifications.
Posting data to an external trigger webhook in Alta Video
To activate or deactivate an external trigger, send an HTTP POST request to the webhook URL associated with that trigger. The webhook URL is visible when the webhook is generated or renewed.
- The authorization header of the HTTP request must contain the unique bearer token associated with the trigger.
This header is of the format Authorization: Bearer TOKEN, where the token is displayed when the webhook is generated or renewed. - The body of the HTTP request must be a JSON object:
- To activate the trigger, send {"action":"activate"}
- To deactivate the trigger, send {"action":"deactivate"}
When an external trigger is activated, all rules in Alta Video that use that trigger become active. When an external trigger is deactivated, all rules associated with that trigger become inactivate.
Making an HTTP POST request to a webhook
Different options exist to make an HTTP POST, including the Linux command line tool cURL, software platforms such as Postman, and programmatically using the JavaScript Fetch API. The following example uses cURL.
Activating an Alta Video trigger using cURL
curl --location 'WEBHOOK_URL
'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer TOKEN_STRING
'
--data '{"action": "activate"}'
Deactivating an Alta Video trigger using cURL
curl --location 'WEBHOOK_URL
'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer TOKEN_STRING
'
--data '{"action": "deactivate"}'