Outgoing Webhooks
Outgoing Webhooks allow you to connect data and events coming from Datacake to other systems.

What are webhooks

A webhook pushes real-time notifications from Datacake to your app. Datacake uses HTTPS to send these notifications to your app as a JSON payload. You can then use these notifications to execute actions in your backend systems.

Use cases

Sync device measurements to your system

You can create a webhook that listens to "measurement recorded" events and stores them in your external database.

Act on raw data from payload decoders

Sometimes, payload decoders return more data than is stored in the time-series database. You can use webhooks to trigger actions based on this information, without paying for storage.

Get started

You can find the Webhooks settings in the "Integrations" section.
Get started by clicking the "Add Webhook" button. You will be presented with a form that asks for the following information:
  • Endpoint URL -> The URL that receives the events. One good service for testing is https://webhook.site/
  • Description -> An optional description
  • Events to send -> You can choose which events should trigger the webhook
Enter your data and click "Create Webhook". Your endpoint should now start receiving data.

Events

In the settings of your outgoing webhook, you can define one or more events that will trigger the webhook and forward data. Learn more about what the differences are and why you want to use them.

Decoder output

This is the raw output from a device payload decoder as can also be seen in a device debug view, including:
  • Decoder returned data
  • Console Log
  • Device Information (LoRaWAN or Particle device types)
An example output looks like the following:
1
{
2
"data": {
3
"log": null,
4
"device": null,
5
"result": [
6
{
7
"field": "TOWER_LOCATION",
8
"value": "(34.492523,136.171631)",
9
"device": "dev:864475044240892"
10
},
11
{
12
"field": "DEVICE_LOCATION",
13
"value": "(34.4823475,136.16275390624997)",
14
"device": "dev:864475044240892"
15
},
16
{
17
"field": "RSSI",
18
"device": "dev:864475044240892"
19
},
20
{
21
"field": "BARS",
22
"device": "dev:864475044240892"
23
},
24
{
25
"field": "VOLTAGE",
26
"device": "dev:864475044240892"
27
},
28
{
29
"field": "CARD_TEMPERATURE",
30
"device": "dev:864475044240892"
31
},
32
{
33
"field": "ORIENTATION",
34
"device": "dev:864475044240892"
35
},
36
{
37
"field": "PM1",
38
"value": 3.4,
39
"device": "dev:864475044240892"
40
},
41
{
42
"field": "PM25",
43
"value": 4.88,
44
"device": "dev:864475044240892"
45
},
46
{
47
"field": "PM10",
48
"value": 4.88,
49
"device": "dev:864475044240892"
50
},
51
{
52
"field": "TEMPERATURE",
53
"value": 10.616931,
54
"device": "dev:864475044240892"
55
},
56
{
57
"field": "PRESSURE",
58
"value": 95909.72,
59
"device": "dev:864475044240892"
60
},
61
{
62
"field": "HUMIDITY",
63
"value": 59.889774,
64
"device": "dev:864475044240892"
65
}
66
],
67
"product": "ef6275c7-3e9b-4134-9bef-24bc276a9592",
68
"execution_time": 664535
69
},
70
"event": "decoder_output"
71
}
Copied!

Advanced usage

Usually, decoders on Datacake return an array of dictionaries where each dictionary holds the measurement information, device serial (not on LoRaWAN and Particle devices), and the field identifier.
However, as the outgoing webhook does transport any information coming from a decoder you could also include additional information here that is not readable for the Datacake backend but can be used by your systems.

Device measurements

This event type is triggered only on new measurement values recorded on the database. This does not necessarily contain all the data of all fields on a device as it only holds the fields that are being inserted on the last message received by your device.
So if your device does receive a single field message per MQTT for example, this only contains the latest field data.
The webhook data would look like the following:
1
{
2
"data": [
3
{
4
"field": "TOWER_LOCATION",
5
"value": "(26.2319375,-81.742609375)",
6
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
7
"timestamp": 1647852979
8
},
9
{
10
"field": "DEVICE_LOCATION",
11
"value": "(26.237302500000006,-81.74094921875)",
12
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
13
"timestamp": 1647852979
14
},
15
{
16
"field": "ORIENTATION",
17
"value": "",
18
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
19
"timestamp": 1647852980
20
},
21
{
22
"field": "PM1",
23
"value": 0.14084508,
24
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
25
"timestamp": 1647852980
26
},
27
{
28
"field": "PM10",
29
"value": 0.8309859,
30
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
31
"timestamp": 1647852981
32
},
33
{
34
"field": "TEMPERATURE",
35
"value": 19.141228,
36
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
37
"timestamp": 1647852981
38
},
39
{
40
"field": "PRESSURE",
41
"value": 102081.35,
42
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
43
"timestamp": 1647852981
44
},
45
{
46
"field": "HUMIDITY",
47
"value": 66.95572,
48
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
49
"timestamp": 1647852981
50
},
51
{
52
"field": "PM25",
53
"value": 0.28169015,
54
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
55
"timestamp": 1647852980
56
},
57
{
58
"field": "TOWER_LOCATION",
59
"value": "(26.2319375,-81.742609375)",
60
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
61
"timestamp": 1647852984
62
},
63
{
64
"field": "DEVICE_LOCATION",
65
"value": "(26.237302500000006,-81.74094921875)",
66
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
67
"timestamp": 1647852984
68
},
69
{
70
"field": "ORIENTATION",
71
"value": "",
72
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
73
"timestamp": 1647852986
74
},
75
{
76
"field": "PM25",
77
"value": 0.16901408,
78
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
79
"timestamp": 1647852986
80
},
81
{
82
"field": "PM10",
83
"value": 0.5492958,
84
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
85
"timestamp": 1647852986
86
},
87
{
88
"field": "TEMPERATURE",
89
"value": 19.0143,
90
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
91
"timestamp": 1647852986
92
},
93
{
94
"field": "PRESSURE",
95
"value": 102088.086,
96
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
97
"timestamp": 1647852986
98
},
99
{
100
"field": "HUMIDITY",
101
"value": 66.58315,
102
"device": "f7384fd1-9e7f-4540-b4ed-5fa5810bcc27",
103
"timestamp": 1647852987
104
}
105
],
106
"event": "device_measurement"
107
}
Copied!
This event is triggered whenever a downlink is sent to a LoRaWAN or MQTT device. It will trigger both on manual and automatic (via rules) downlinks. The structure is as follows:
1
{
2
"data": {
3
"meta": {
4
"type": "lorawan",
5
"fport": 1,
6
"downlink": "a6895656-8198-41fe-9c0e-f49074311190"
7
},
8
"device": "a52e6324-2cf9-4534-b523-819d94299414",
9
"payload": "AQI=",
10
"product_id": "4e8e8623-18c4-4798-9877-699058a00e24",
11
"product_slug": "temperatur-dach"
12
},
13
"event": "downlink"
14
}
Copied!

Troubleshooting

The list of webhooks contains useful debugging information, such as a chart of the number of requests in the last seven days and the error rate.
Click on one of your webhooks to see a list of the last requests as well as the response from your server.