n8n
From Premium
n8n website
(provider’s site, opens in a new window)
In n8n the node "Webhook" receives events from here and the node "HTTP Request" calls the API. This works in n8n Cloud and self-hosted, as long as the webhook address is reachable from the internet over HTTPS.
Receive events and check the signature:
- Create a workflow with the node "Webhook", method POST, and copy the "Production URL".
- Add the address under Settings, Webhooks and note the secret, it is shown only once.
- In the webhook node, switch on "Raw Body" under "Options" and attach a "Code" node with the example below. Self-hosted,
NODE_FUNCTION_ALLOW_BUILTIN=cryptomust be set.
const crypto = require('crypto');
const secret = 'whsec_YOUR_SECRET';
const header = $json.headers['x-horaka-signature'] ?? '';
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const body = Buffer.from($binary.data.data, 'base64').toString('utf8');
const expected = crypto
.createHmac('sha256', secret)
.update(`${parts.t}.${body}`)
.digest('hex');
if (expected !== parts.v1) {
throw new Error('Signature does not match');
}
return [{ json: JSON.parse(body) }];
Control the timer from a workflow:
- Under Settings, API and devices, add a device or a token with the permission "Trigger".
- In n8n, create a credential of the type "Header Auth": name
Authorization, valueBearerand your token. - Add the node "HTTP Request" and enter the values below.
Method: POST
URL: https://api.horaka.com/v1/track/toggle
Authentication: Generic Credential Type, Header Auth
Send Body: on, Body Content Type JSON
JSON: {"project": "PROJECT"}