Creating a webhook

This article shows you how to setup a webhook action to any system with a REST API

Using our configurable webhook action, you can connect triggers to any REST API in your business.

A webhook is an HTTP action, normally POST, that can perform an action like creating a ticket, sending a notification or updating a device firmware. You'll need to consult the documentation for the target system to understand the data they need.

Name

The name of this action.

URL

The URL of the target. This can be parameterised by any property from the device or the trigger by using the + icon.

Method

Options are: 

  • GET
  • POST
  • PUT
  • DELETE

The most likely choice will be POST

Headers

You can add multiple HTTP headers: common examples are 

content-type=application/json
Authorization=TOKEN 12345678901234567890

This can be parameterised by any property from the device or the trigger by using the + icon.

Body

The most common format for the body of the webhook POST will be JSON, although that is not mandatory. Again, all fields here can be parameterised by any property from the device or the trigger by using the + icon.

Here is an example:

{
"deviceid": "{{source.$id}}",
"Name": "{{source.stationName}}",
"State": "{{rule.state}}",
"Time": " {{date rule.$ts "HH:mm"}}"
}

Handlebars

The double curly brackets in the syntax above is from a templating language called Handlebars, which we use in actions. Handlebars has a rich syntax, and we also extend it using a library called Handlebars Helpers. The combination of these two allows for extremely advanced manipulation and formatting of the webhooks and actions.