The Thermalog API lets your own systems read your monitoring data: your sites, their sensors, readings and alarms. Webhooks tell your systems the moment an alarm changes, so you don’t have to poll.
The API is read-only. It works for sites with a Thermalog gateway, not for free or demo sites. It is built for server-to-server use: call it from your backend, never from a web page or app that other people can open.
- Base URL:
https://dashboard.thermalog.com.au/api/v1 - Interactive reference: /api/v1/docs, with every field of every response
- OpenAPI document: /api/v1/openapi.json, to generate a client in your language
The reference is built from the running API, so it always matches what is live. This guide explains how the pieces fit together. If the two ever disagree, the reference is right.
On this page: Getting started · API keys · Authentication · Rate limits · Endpoints · Pagination · Errors · Webhooks · Changelog
Getting started
- Sign in to the Thermalog dashboard as the Admin of a site with a Thermalog gateway.
- Open Settings → You → API access and create a key. Pick the sites it can read.
- Copy the key straight away. It is shown once and we cannot show it again.
- Check that it works:
export THERMALOG_API_KEY='tl_xxxxxxxxxxxx.your-secret'
curl -s https://dashboard.thermalog.com.au/api/v1/me \
-H "Authorization: Bearer $THERMALOG_API_KEY"
Keep the key out of source control. Store it the way you store a password, for example in an environment variable or a secrets manager.
API keys
- Who can create keys. You need the Admin role at a site to give a key access to it. Managers and staff cannot create keys.
- Keys belong to you. A key belongs to the Admin who created it, not to the business. If your account is deleted, your keys stop working.
- Sites. A key either names its sites or reads all of your sites:
- A key that names its sites keeps reading each one while you are an Admin or Manager there.
- An all-sites key reads every site you are the Admin of, including sites you become the Admin of later.
- Leaving a site, or becoming a plain user there, stops both kinds of key reading it. A site that is no longer on a Thermalog gateway plan cannot be read either.
- Shown once. We store only a fingerprint (hash) of the secret part of the key, so nobody at Thermalog can read it back. If you lose a key, rotate it or create a new one.
- Read-only. Every key in v1 has the
readscope. Nothing you do with a key can change your sites, sensors or settings. - Expiry. A key can have an expiry date up to two years ahead, or none.
- Rotation. Rotating gives you a new key. The old one keeps working for up to 24 hours (never past its own expiry date) so you can swap it over without downtime. After that it answers
401 API_KEY_EXPIRED. - Revoking. Revoking stops a key straight away. Revoking the new key after a rotation does not stop the old one during its 24 hours. If a secret has leaked, revoke both.
- Password changes. Changing your password, or signing out on every device, does not revoke your API keys. They are a separate credential. Revoke them on the API access page if you need to.
- Limits. Up to 20 active keys and 10 webhook endpoints per account.
- Usage. The API access page shows when each key was last used and how many requests it made in the last 24 hours and 30 days.
Every key starts with tl_, so a secret scanner can be set up to find one that has been committed or pasted somewhere it shouldn’t be. If a key leaks, revoke it.
Authentication
Send the key in the Authorization header of every request:
Authorization: Bearer tl_<publicId>.<secret>
- Send the header once. A request with more than one
Authorizationheader is refused. - A bad, expired or revoked key gets a
401(see Errors). The response never says whether the key’s id exists. - Your dashboard sign-in does not work on the API, and an API key does not work on the dashboard.
- No browser origin is allowed except Thermalog’s own dashboard, so your web pages cannot call the API. Call it from your server, never from a web page, so the key stays secret.
Rate limits
| Limit | Applies to |
|---|---|
| 600 requests a minute | Each key, on every route except readings |
| 120 requests a minute | Each key, on the readings route |
| 3,000 requests a minute | All keys together |
| 1,200 requests a minute | Each IP address, on each route |
A readings request counts against the readings limit and the all-keys limit, not against the 600. The all-keys limit is shared by every customer, so in a very busy minute you can get a 429 before your own limit.
Every response to a valid key carries:
X-RateLimit-Limit: your key’s limit for this route, per minuteX-RateLimit-Remaining: requests left in the current minuteX-RateLimit-Reset: seconds until the window resets
Over a limit, you get 429 with code RATE_LIMITED and a Retry-After header in seconds. Wait that long, then try again.
In front of the API, our edge also refuses bursts of more than 20 requests a second from one address. That 429 has no JSON body and no Retry-After, so treat any 429 the same way: wait a few seconds and try again. The helper below waits 5 seconds when Retry-After is missing.
Two more 503 answers can come back, and they need different handling:
503 BUSY: the API is handling as many requests as it can right now. It sendsRetry-After(2 seconds); wait that long and try again.503 QUERY_TIMEOUT: your request took longer than 5 seconds to answer. Sending it again will not help. Change the request: ask for a shorter range or a longer interval.
A simple way to respect all of this in Python:
import os
import time
import requests
BASE = "https://dashboard.thermalog.com.au/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['THERMALOG_API_KEY']}"
def get(path, params=None):
for _ in range(5):
resp = session.get(BASE + path, params=params, timeout=30)
retry_after = resp.headers.get("Retry-After")
# 429, or 503 BUSY (which sends Retry-After). A 503 QUERY_TIMEOUT has no
# Retry-After and is raised below: change the request instead.
if resp.status_code == 429 or (resp.status_code == 503 and retry_after):
time.sleep(int(retry_after or "5"))
continue
resp.raise_for_status()
return resp.json()
resp.raise_for_status()
print(get("/me"))
The Python examples below use this get helper.
Endpoints
All routes are GET. Query parameters are strict: a parameter the route does not know is refused with 400 INVALID_REQUEST, so a typo cannot be silently ignored.
Times are ISO 8601. Responses give them in UTC. When you send from or to, always include Z or a UTC offset, for example 2026-10-01T00:00:00Z or 2026-10-01T10:00:00+10:00.
Responses contain ids, names, readings, limits and times. They never contain anyone’s email address or phone number, or the hardware addresses of your devices.
Replace 123 (a site id) and 456 (a sensor id) in the examples with ids from your own /sites and /sensors responses.
GET /me
The key making the request: its name, scopes, expiry, rate limits and the sites it can read right now. A cheap way to check that a key works.
curl -s https://dashboard.thermalog.com.au/api/v1/me \
-H "Authorization: Bearer $THERMALOG_API_KEY"
{
"name": "Building management system",
"prefix": "tl_abcdefgh2345.Xy9_",
"scopes": ["read"],
"allSites": false,
"expiresAt": null,
"createdAt": "2026-10-12T02:30:00.000Z",
"sites": [{ "siteId": 123, "name": "Main kitchen" }],
"rateLimits": { "perMinute": 600, "readingsPerMinute": 120 }
}
prefix is the start of the key, as the dashboard shows it. expiresAt is null for a key that never expires.
GET /sites
The sites this key can read, with each site’s time zone, gateway state, sensor counts and open alarm counts.
curl -s https://dashboard.thermalog.com.au/api/v1/sites \
-H "Authorization: Bearer $THERMALOG_API_KEY"
sites = get("/sites")["sites"]
{
"sites": [
{
"siteId": 123,
"name": "Main kitchen",
"timezone": "Australia/Sydney",
"gatewayType": "hub",
"gatewayOnline": true,
"lastReadingAt": "2026-10-12T03:14:00.000Z",
"sensors": { "online": 6, "total": 6 },
"alarms": { "open": 1, "muted": 0, "unacknowledged": 1 }
}
]
}
gatewayTypeishubortablet, ornullwhen the site has no gateway yet.sensors.totalcounts the site’s temperature sensors.sensors.onlinecounts those heard from in the last 20 minutes, and is 0 while the gateway is offline.alarms.opencounts open temperature, humidity and door alarms, muted ones included.mutedandunacknowledgedare subsets of it;unacknowledgedmeans neither muted nor acknowledged by anyone.
GET /sites/{siteId}/sensors
Every temperature, humidity and door sensor on the site, with its latest reading, limits and open alarms.
curl -s https://dashboard.thermalog.com.au/api/v1/sites/123/sensors \
-H "Authorization: Bearer $THERMALOG_API_KEY"
sensors = get("/sites/123/sensors")["sensors"]
{
"siteId": 123,
"sensors": [
{
"id": 456,
"unitId": 2201,
"name": "Walk-in cool room",
"type": "temperature",
"unitOfMeasure": "°C",
"latestValue": 6.2,
"latestAt": "2026-10-12T03:14:00.000Z",
"online": true,
"profileName": "Cool room",
"limits": { "min": 0, "max": 5 },
"openAlarms": [
{
"id": 88123,
"category": "temperature",
"level": "caution",
"openedAt": "2026-10-12T03:02:00.000Z",
"muted": false
}
]
},
{
"id": 789,
"unitId": 2201,
"name": "Walk-in cool room",
"type": "door",
"unitOfMeasure": null,
"latestValue": 0,
"latestAt": "2026-10-12T02:58:41.000Z",
"online": true,
"profileName": null,
"limits": null,
"openAlarms": []
}
]
}
typeistemperature,humidityordoor. A temperature and humidity sensor is two sensors on one unit.unitIdis the unit (fridge, freezer, room) the sensor is on.- A sensor’s
idstays the same for the life of the sensor on its unit, through a gateway or sensor replacement, so it is safe to store. unitOfMeasureis°Cor%, andnullfor a door. A door’slatestValueis 1 for open and 0 for closed.online: a temperature or humidity sensor heard from in the last 20 minutes while the gateway is online. For a door, the gateway is online and the sensor has no offline alarm.limitscome from the sensor’s equipment profile (profileName). They arenullfor a door or a sensor that is not monitored./sitesand/sensorsare refreshed at most every 15 seconds. Polling more often returns the same data.
GET /sites/{siteId}/sensors/{sensorId}/readings
A sensor’s readings from from (inclusive) to to (exclusive). Leave to out for now, and from out for 24 hours before to. Choose the shape with interval.
| Parameter | Values | Default |
|---|---|---|
from |
ISO 8601 time with Z or an offset |
24 hours before to |
to |
ISO 8601 time with Z or an offset |
now |
interval |
1m, 5m, 15m, 1h, 1d or raw |
15m |
cursor |
raw only: the nextCursor of the previous page |
|
limit |
raw only: readings per page, 1 to 1,000 |
1,000 |
Bucketed readings. With interval set to 1m, 5m, 15m, 1h or 1d, you get one entry per bucket in buckets:
curl -s -G https://dashboard.thermalog.com.au/api/v1/sites/123/sensors/456/readings \
-H "Authorization: Bearer $THERMALOG_API_KEY" \
--data-urlencode "from=2026-10-01T00:00:00Z" \
--data-urlencode "to=2026-10-08T00:00:00Z" \
-d interval=1h
week = get("/sites/123/sensors/456/readings", {
"from": "2026-10-01T00:00:00Z",
"to": "2026-10-08T00:00:00Z",
"interval": "1h",
})
for bucket in week["buckets"]:
print(bucket["at"], bucket["avg"], bucket["min"], bucket["max"])
{
"sensorId": 456,
"type": "temperature",
"unitOfMeasure": "°C",
"interval": "1h",
"from": "2026-10-01T00:00:00.000Z",
"to": "2026-10-08T00:00:00.000Z",
"timezone": "Australia/Sydney",
"buckets": [
{ "at": "2026-10-01T00:00:00.000Z", "avg": 3.4, "min": 2.9, "max": 4.1, "count": 30 },
{ "at": "2026-10-01T01:00:00.000Z", "avg": 3.6, "min": 3.1, "max": 5.8, "count": 30 }
],
"readings": [],
"nextCursor": null
}
atis the start of the bucket, andcountis the number of readings in it. The minimum and maximum show a short excursion that an average alone would hide.- Buckets with no readings are left out.
1dbuckets are days in the site’s time zone (timezone). The other intervals are aligned to UTC.
Raw readings. With interval=raw you get every stored reading in readings, up to 1,000 a page. When there are more, follow nextCursor; see Pagination.
curl -s -G https://dashboard.thermalog.com.au/api/v1/sites/123/sensors/456/readings \
-H "Authorization: Bearer $THERMALOG_API_KEY" \
--data-urlencode "from=2026-10-07T00:00:00Z" \
--data-urlencode "to=2026-10-08T00:00:00Z" \
-d interval=raw \
-d limit=2
With limit=2 to keep the example short:
{
"sensorId": 456,
"type": "temperature",
"unitOfMeasure": "°C",
"interval": "raw",
"from": "2026-10-07T00:00:00.000Z",
"to": "2026-10-08T00:00:00.000Z",
"timezone": "Australia/Sydney",
"buckets": [],
"readings": [
{ "at": "2026-10-07T00:01:12.000Z", "value": 3.4 },
{ "at": "2026-10-07T00:03:12.000Z", "value": 3.5 }
],
"nextCursor": "eyJ0IjoiMjAyNi0xMC0wN1QwMDowMzoxMi4wMDBaIn0"
}
Every raw reading in a range, page by page, in Python:
def raw_readings(site_id, sensor_id, start, end):
# Send the same from and to on every page.
params = {"from": start, "to": end, "interval": "raw"}
while True:
page = get(f"/sites/{site_id}/sensors/{sensor_id}/readings", params)
yield from page["readings"]
if page["nextCursor"] is None:
return
params["cursor"] = page["nextCursor"]
for reading in raw_readings(123, 456, "2026-10-07T00:00:00Z", "2026-10-08T00:00:00Z"):
print(reading["at"], reading["value"])
Door sensors. A door has no temperature, so its readings are its changes of state. Whatever interval you send, a door answers "interval": "raw" with every change in readings (value 1 for opened, 0 for closed), all in one response with nextCursor set to null. The range limit still follows the interval you send, so leave interval out to read up to 31 days of a door at once.
door = get("/sites/123/sensors/789/readings", {
"from": "2026-10-11T00:00:00Z",
"to": "2026-10-12T00:00:00Z",
})
for change in door["readings"]:
print(change["at"], "opened" if change["value"] == 1 else "closed")
{
"sensorId": 789,
"type": "door",
"unitOfMeasure": null,
"interval": "raw",
"from": "2026-10-11T00:00:00.000Z",
"to": "2026-10-12T00:00:00.000Z",
"timezone": "Australia/Sydney",
"buckets": [],
"readings": [
{ "at": "2026-10-11T21:05:09.000Z", "value": 1 },
{ "at": "2026-10-11T21:06:40.000Z", "value": 0 }
],
"nextCursor": null
}
Range limits.
- Bucketed: up to 31 days per request, and no more than 10,000 buckets (a week of
1mbuckets is too many; use5m). - Raw: up to 7 days per request.
- Longer ranges, or too many buckets, are refused with
400 RANGE_TOO_LARGE. Split them into several requests. frommust be beforeto, or you get400 INVALID_RANGE.
Readings requests count against the readings limit of 120 a minute per key and the all-keys limit of 3,000 a minute, not against the 600 a minute that covers the other routes.
GET /sites/{siteId}/alarms
The alarms opened at a site from from (inclusive) to to (exclusive), newest first. A window can be up to 92 days.
| Parameter | Values | Default |
|---|---|---|
from |
ISO 8601 time with Z or an offset |
7 days before to |
to |
ISO 8601 time with Z or an offset |
now |
status |
open or closed |
both |
cursor |
the nextCursor of the previous page |
|
limit |
alarms per page, 1 to 200 | 100 |
curl -s -G https://dashboard.thermalog.com.au/api/v1/sites/123/alarms \
-H "Authorization: Bearer $THERMALOG_API_KEY" \
-d status=open
recent_open_alarms = get("/sites/123/alarms", {"status": "open"})["alarms"]
status=open returns the alarms still open that were opened inside the window, so with the default window an alarm opened 8 days ago and still open is missing. To see everything open now, read each sensor’s openAlarms from /sensors, plus gatewayOnline for each site from /sites: a gateway outage is not on any sensor (webhooks send it as gateway.offline and gateway.online). Or set from up to 92 days before to and follow nextCursor.
{
"siteId": 123,
"from": "2026-10-05T03:15:00.000Z",
"to": "2026-10-12T03:15:00.000Z",
"alarms": [
{
"id": 88123,
"siteId": 123,
"category": "temperature",
"level": "caution",
"status": "open",
"sensorId": 456,
"unitId": 2201,
"sensorName": "Walk-in cool room",
"openedAt": "2026-10-12T03:02:00.000Z",
"mutedAt": null,
"closedAt": null,
"closeReason": null
}
],
"nextCursor": null
}
categoryistemperature,humidityordoor(out of limits or left open),sensor(the sensor stopped reporting) orgateway(the site’s hub or tablet went offline).levelis the worst the alarm reached:warning,cautionorinfo.statusisopenorclosed. A muted alarm is still open;mutedAtsays since when.sensorId,unitIdandsensorNamearenullfor a gateway alarm.closeReasonsays why the alarm ended, and isnullwhile it is open. See the reference for its values.- Energy-use alerts are not included.
Pagination
Raw readings and alarms come in pages. A response with more results after it has a nextCursor. Send it back unchanged as the cursor parameter to get the next page. When nextCursor is null, you have the last page.
Send the same from, to and other parameters on every page. If you leave from or to out, they default to times relative to now, which move between one page and the next. Pass fixed times when you page.
Cursors are opaque. Don’t build or edit one: a malformed cursor, or one we did not hand out, may be refused with 400 INVALID_CURSOR. So is any cursor sent with bucketed readings or to a door, which have no pages.
Errors
Every error has the same JSON body:
{ "statusCode": 404, "code": "SITE_NOT_FOUND", "message": "Site not found." }
Branch on code, not on message; messages are written for people and may change. A 400 INVALID_REQUEST usually carries details, a list of what is wrong with each parameter:
{
"statusCode": 400,
"code": "INVALID_REQUEST",
"message": "The request is not valid. See details.",
"details": ["property foo should not exist"]
}
| Code | Status | Meaning |
|---|---|---|
INVALID_API_KEY |
401 | The key is missing, malformed or wrong, or its owner’s account is gone |
API_KEY_EXPIRED |
401 | The key has passed its expiry date, or its grace period after a rotation has ended |
API_KEY_REVOKED |
401 | The key has been revoked |
INSUFFICIENT_SCOPE |
403 | The key’s scope does not allow this request |
KEY_SITE_NOT_ALLOWED |
403 | The site is on the key, but the key’s owner is no longer an Admin or Manager there |
PAID_SITE_REQUIRED |
403 | The site has no Thermalog gateway plan (a free or demo site) |
FORBIDDEN |
403 | Refused, without a more specific code |
SITE_NOT_FOUND |
404 | The key does not read this site. We don’t say whether it exists, so one customer cannot discover another’s sites |
SENSOR_NOT_FOUND |
404 | The sensor is not on this site |
NOT_FOUND |
404 | Not found, without a more specific code |
INVALID_REQUEST |
400 | A parameter is missing, malformed or unknown. Usually with details |
INVALID_RANGE |
400 | from is not before to |
RANGE_TOO_LARGE |
400 | The window is longer than the route allows, or makes more than 10,000 buckets. See range limits |
INVALID_CURSOR |
400 | The cursor is malformed or not one we handed out, or this request has no pages |
RATE_LIMITED |
429 | Over a rate limit. Wait for Retry-After |
BUSY |
503 | The API is at capacity. Wait for Retry-After |
QUERY_TIMEOUT |
503 | The request took longer than 5 seconds. Ask for less data |
INTERNAL |
500 | Something went wrong on our side. We are notified automatically |
Webhooks
A webhook sends an HTTPS POST to your server when something happens at your sites. You manage webhooks in Settings → You → API access, the same place as your keys. Add a webhook, choose its events and sites, and copy its signing secret. The secret starts with whsec_ and is shown in full once; after that the dashboard shows its last four characters.
Webhooks are sent the moment an alarm changes. Email, SMS and push alerts to people can be held back or grouped: grace periods, quiet hours, a pause before an all-clear. Webhooks skip all of that. So your system may hear about a short alarm that never reached anyone’s phone. Alarms that a tablet uploads later from its history do not send webhooks.
Use the webhook’s Test button to receive a ping event. You don’t subscribe to ping: a test is sent whatever events you chose. A test is refused while the webhook is turned off.
Events
| Event | Sent when |
|---|---|
alarm.opened |
A temperature, humidity or door alarm opens |
alarm.escalated |
An alarm’s level rises, for example from caution to warning |
alarm.muted |
An alarm is muted |
alarm.unmuted |
A muted alarm is unmuted |
alarm.closed |
An alarm ends |
door.left_open |
A door alarm opens (sent as well as its alarm.opened) |
door.closed |
A door alarm ends (sent as well as its alarm.closed) |
sensor.offline |
A sensor stops reporting |
sensor.online |
A sensor starts reporting again |
gateway.offline |
The site’s hub or tablet goes offline. One event per outage |
gateway.online |
The hub or tablet comes back |
ping |
A test sent from the dashboard |
A door alarm sends both alarm.opened and door.left_open, so subscribe to whichever suits you.
Many sensors at once. When a whole gateway goes offline, many sensors can go offline together. Past 50 sensor events at one site in a minute, the rest are not sent one by one. Once that minute ends, the sensors that went offline come as one sensor.offline with a count of how many they were, and any sensor.online among them is dropped. So to track each sensor’s state, take its next sensor.offline or sensor.online, or GET /sites/{siteId}/sensors, as the truth.
Payload
Every event has the same shape. alarm is the alarm as this change left it, with the same fields as its entry in GET /sites/{siteId}/alarms, so you can use one parser for both. sensor.name is the name of the unit the sensor is on, as in /sensors.
{
"id": "evt_3b241101-e2bb-4255-8caf-4136c566a962",
"type": "alarm.closed",
"createdAt": "2026-10-12T01:02:03.000Z",
"apiVersion": "v1",
"data": {
"site": { "id": 1300, "name": "Main Street" },
"alarm": {
"id": 41,
"siteId": 1300,
"category": "temperature",
"level": "warning",
"status": "closed",
"sensorId": 3,
"unitId": 4,
"sensorName": "Walk-in freezer",
"openedAt": "2026-10-12T00:00:00.000Z",
"mutedAt": "2026-10-12T00:30:00.000Z",
"closedAt": "2026-10-12T01:00:00.000Z",
"closeReason": "telemetry_in_range"
},
"sensor": { "id": 3, "name": "Walk-in freezer", "kind": "temperature" }
}
}
idis unique per event and the same on every retry.createdAtis when Thermalog recorded the event.sensor.kindistemperature,humidityordoor.- A gateway event has
"sensor": null, and itsalarmhas the categorygatewaywithsensorId,unitIdandsensorNameset tonull. - A summary of sensors gone offline has
"alarm": null,"sensor": nulland acount. ItscreatedAtis when the summary was built:
{
"id": "evt_9c5e7a2d-1f3b-4c8e-a6d4-2b7f0e1c3a59",
"type": "sensor.offline",
"createdAt": "2026-10-12T02:15:00.000Z",
"apiVersion": "v1",
"data": {
"site": { "id": 1300, "name": "Main Street" },
"alarm": null,
"sensor": null,
"count": 37
}
}
- A
pinghassite,alarmandsensorallnull. - Payloads carry site and sensor names, values, times and ids, never personal details. The reference lists every field under “Webhooks (events you receive)”.
Each request carries these headers:
| Header | Value |
|---|---|
Content-Type |
application/json |
User-Agent |
Thermalog-Webhooks/1 |
X-Thermalog-Event |
The event type, for example alarm.closed |
X-Thermalog-Event-Id |
The event’s id, for example evt_3b241101-… |
X-Thermalog-Delivery |
This delivery’s number. Retries of the delivery keep the same number |
X-Thermalog-Signature |
t=<unix seconds>,v1=<signature> (see below) |
Verifying signatures
Check every request before you trust it. v1 is the hex HMAC-SHA256 of <t>.<body>, keyed with your webhook’s signing secret, where t is the timestamp from the same header and body is the raw request body. Use the secret exactly as the dashboard showed it, the whole whsec_… text.
- Read
tand everyv1value fromX-Thermalog-Signature. Accept the request if anyv1matches. - Compute the HMAC over the raw bytes of the body, before any JSON parsing. Re-encoded JSON will not match.
- Compare in constant time.
- Refuse a
tmore than 5 minutes from your clock, so an old request cannot be replayed. Every attempt, retries included, is signed afresh with the time it was sent.
Node.js (Express):
const crypto = require('node:crypto');
const express = require('express');
const SECRET = process.env.THERMALOG_WEBHOOK_SECRET;
const TOLERANCE_SECONDS = 5 * 60;
function verifySignature(secret, header, rawBody, now = Date.now() / 1000) {
if (!header) return false;
let t = null;
const signatures = [];
for (const part of header.split(',')) {
const [key, value] = part.trim().split('=');
if (key === 't') t = Number(value);
else if (key === 'v1' && value) signatures.push(value);
}
if (!Number.isInteger(t) || signatures.length === 0) return false;
if (Math.abs(now - t) > TOLERANCE_SECONDS) return false;
const expected = crypto
.createHmac('sha256', secret)
.update(`${t}.`)
.update(rawBody)
.digest();
return signatures.some((sig) => {
const given = Buffer.from(sig, 'hex');
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
const app = express();
app.post('/thermalog/webhook', express.raw({ type: '*/*' }), (req, res) => {
if (!verifySignature(SECRET, req.get('X-Thermalog-Signature'), req.body)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
res.sendStatus(204); // reply first, then do the work
console.log(event.type, event.id);
});
app.listen(3000);
Python (Flask):
import hashlib
import hmac
import json
import os
import time
from flask import Flask, abort, request
SECRET = os.environ["THERMALOG_WEBHOOK_SECRET"]
TOLERANCE_SECONDS = 5 * 60
def verify_signature(secret: str, header: str, raw_body: bytes, now=None) -> bool:
t = None
signatures = []
for part in (header or "").split(","):
key, _, value = part.strip().partition("=")
if key == "t":
t = value
elif key == "v1" and value:
signatures.append(value)
if t is None or not t.isdecimal() or not signatures:
return False
if now is None:
now = time.time()
if abs(now - int(t)) > TOLERANCE_SECONDS:
return False
expected = hmac.new(
secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256
).hexdigest()
return any(hmac.compare_digest(expected.encode(), sig.encode()) for sig in signatures)
app = Flask(__name__)
@app.post("/thermalog/webhook")
def thermalog_webhook():
raw_body = request.get_data()
if not verify_signature(SECRET, request.headers.get("X-Thermalog-Signature", ""), raw_body):
abort(400)
event = json.loads(raw_body)
print(event["type"], event["id"])
return "", 204
Test vector. Check your code against these known-good values before you go live:
| Input | Value |
|---|---|
| Secret | whsec_test_secret_do_not_use |
t |
1760000000 |
| Body | {"id":"evt_00000000-0000-4000-8000-000000000000","type":"ping"} |
| Header | t=1760000000,v1=7879b987cd64c991bee068279b73f04b8997719cb53a26930f474459a15b883b |
Add these lines below the code above. They pass “now” as 1760000000, so the 5-minute check holds, and must print true and True:
const body = Buffer.from('{"id":"evt_00000000-0000-4000-8000-000000000000","type":"ping"}');
const header = 't=1760000000,v1=7879b987cd64c991bee068279b73f04b8997719cb53a26930f474459a15b883b';
console.log(verifySignature('whsec_test_secret_do_not_use', header, body, 1760000000));
body = b'{"id":"evt_00000000-0000-4000-8000-000000000000","type":"ping"}'
header = "t=1760000000,v1=7879b987cd64c991bee068279b73f04b8997719cb53a26930f474459a15b883b"
print(verify_signature("whsec_test_secret_do_not_use", header, body, now=1760000000))
Rotating the secret replaces it at once, with no overlap: from then on every delivery is signed with the new secret only, and the old one no longer verifies. Put the new secret into your receiver straight away. Any delivery your receiver refuses in the meantime is retried on the schedule below.
Delivery and retries
- Reply fast. Answer with any
2xxstatus within 10 seconds. Do slow work after you reply, or in a queue. Anything else is a failed attempt, a redirect (3xx) included: redirects are not followed. We read at most 16 KB of your reply and discard it. - Retries. A failed delivery is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours. If that last try fails too, the delivery is given up on.
- At least once. The same event can reach you more than once, for example when your server handled it but the reply was lost. Store each event’s
idand ignore one you have already handled. - Order. Events come in no set order. Use
createdAtto put them in order. - Backlog. If 1,000 deliveries are already waiting for one webhook, new events for it are dropped until it catches up.
- Turned off automatically. A webhook is turned off, and its owner emailed, after 20 deliveries in a row are given up on, or after 24 hours of continuous failure. A failure more than 13 hours after the one before starts a new run, so occasional failures on quiet days never add up to 24 hours.
- Turning a webhook off, by hand or automatically, means what it had waiting is not sent. Turning it on again clears its failures, and you can then retry the deliveries that were waiting when it was turned off. Events while it is off are not kept for it.
- Delivery history. The dashboard lists each webhook’s recent deliveries, newest first, with their status, attempt count and last error. You can retry a failed or given-up delivery from there.
- Ownership. Like a key, a webhook belongs to the Admin who created it and follows the same site rules: it only receives events for sites its owner could read with a key.
Webhook URLs
- The URL must use
https, on port 443 or 8443, with no user name or password in it, and be at most 2,048 characters. - Thermalog’s own hosts and their subdomains are refused, and so are the addresses they resolve to.
- Every address the host resolves to must be public: private, loopback, link-local (cloud metadata), carrier-grade NAT, multicast, reserved and documentation ranges are refused, as are IPv4 addresses wrapped in IPv6.
- This is checked again before every attempt, and the request goes to the address that was checked, not to a fresh DNS answer.
Changelog
v1 (12 October 2026). The first release of the Thermalog API: API keys; read access to sites, sensors, readings and alarms; and webhooks for alarm, door, sensor and gateway events, signed with HMAC-SHA256.
Questions or a feature you need? Email info@thermalog.com.au.