How to work with Webhook notifications

A webhook is a way to automatically send event data from the system to an external service or your server.
For example, if a vehicle exceeds the speed limit, the system can automatically send a request to the URL you specify and pass information about the event.

How webhook notifications work

1. You specify the URL address — where the data should be sent
2. When the notification is triggered, the system sends a POST request with JSON
3. Your server receives the data and processes it as needed
Before you start, make sure that:
— the URL is correct and accessible
— the server responds with code 200 (OK)
— if the server does not respond or returns an error, the address will be temporarily added to a blacklist\

How to set up a webhook

1. Go to the notification creation or editing page
2. In the Type and name section, select Webhook as the delivery method
3. To configure webhook notifications, click the edit field — the Webhook details window will open, where you can set the data sending parameters
In the Webhook details window, you will see three fields:
How to work with Webhook notifications
1. URL
Enter the address to which the data will be sent.
2. Header
This field specifies the format of the transmitted data. By default, the required value is already set:
["ContentType: application/json"]
3. Body
This is the data that will be sent. By default, the following template is used:
{
 "agent_id": "%AGENTID%",
 "vehiclenumber": "%VEHNUM%",
 "ts": "%TS%",
 "lat": "%LAT%",
 "lon": "%LON%",
 "speed": "%SPEED%",
 "data": "%DATA%",
 "zone": "%ZONE%",
 "driver": "%DRIVER%"
}
4. Variables for the request body
You can modify or extend the request body using the allowed placeholders listed on the right.
Make sure to follow the required format: "value": "%VALUE%". If the syntax is incorrect, the webhook will not work.
Allowed placeholders
  Placeholder
  What it sends
  %ACCOUNTID%
  Account ID
  %AGENTID%
  Object ID
  %VEHNUM%
  Vehicle number
  %TS%
  Timestamp
  %DATETIME%
  Date and time
  %LAT%
  Latitude
  %LON%
  Longitude
  %SPEED%
  Speed
  %ODO%
  Mileage (from sensor)
  %DATA%
  Notification data
  %ZONE%
  Geofence
  %ZONE_ID%
  First geofence ID
  %ZONE_NAME%
  First geofence name
  %DRIVER%
  Driver
  %MAXSPEED%
  Maximum speed (for overspeed notifications)
  %DUR% 
  Overspeed duration
  %SPEEDLIMIT% 
  Configured speed limit (Speed Control)
 

How to insert a sensor value

If you need to send data from a specific sensor:
1. Open the Sensors tab
2. Copy the exact sensor name
How to work with Webhook notifications
3. Return to the webhook settings window and insert the variable into the Body field in the following format: %Sensor Name%
For example, if the sensor is named Fuel sensor status, enter: %Fuel sensor status%.
 

How to get raw data

You can also send raw data directly from the device:
1. Go to the Sensors tracing tab
2. Find the parameter in the Raw data column
3. Insert it into the Body field in the webhook window in the following format: %Parameter Name%
For example, if the parameter is named Valid, enter: %Valid%
 

Request example

When the notification is triggered, your server will receive data in approximately the following format:
{
 "agent_id": 4328,
 "ts": 1545254055,
 "data":  ["У286НМ 67", "Parkingdur", "2", "1", "мм"]
}
The data set depends on which variables you specified in the request body and which notification type is configured.