GTM engineering · lesson 3 of 8
Receive webhooks you can trust
A webhook address is public: anyone who finds it can post to it. A receiver you can trust checks who signed each delivery, when, and whether it has seen it before.
You end with
One subscribed address that verifies every delivery, ignores repeats, answers at once and has passed a test ping.
Do this
- 1
Subscribe the address
POST /v1/webhooks with the HTTPS address and the events it wants. Store the secret from the answer in a credential or secret manager straight away.
- 2
Verify over the raw body
Recompute the HMAC from the timestamp and the exact bytes received, before any JSON parsing, and compare in constant time. A parsed and re-serialised body will not match.
- 3
Refuse stale deliveries
Reject a timestamp more than five minutes from your clock, so a captured delivery cannot be sent again later.
- 4
Drop repeats
Keep the Outlevo-Event-Id of what you handled. When the same id arrives again, answer 200 and do nothing.
- 5
Answer first, work after
Return 2xx as soon as the delivery is verified and stored, then post to chat or write to the CRM. A slow answer looks like a failure and comes back as a retry.
- 6
Test it, then rotate
Send a test ping and check it verifies. Rotate the secret when someone with access leaves, and swap it in the receiver within the overlap.
// Node 18+, Express. Mount on the raw body: the signature is over the exact bytes.
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
const SECRET = process.env.OUTLEVO_WEBHOOK_SECRET; // from the subscribe answer, shown once
const seen = new Set(); // use your database in production
function verified(header = '', body) {
const parts = header.split(',').map((p) => p.trim().split('='));
const t = Number(parts.find(([k]) => k === 't')?.[1]);
const sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v);
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300) return false; // stale: refuse
const want = Buffer.from(createHmac('sha256', SECRET).update(`${t}.${body}`).digest('hex'));
return sigs.some((v) => v.length === want.length && timingSafeEqual(Buffer.from(v), want));
}
const app = express();
app.post('/outlevo', express.raw({ type: 'application/json' }), (req, res) => {
const body = req.body.toString('utf8');
if (!verified(req.get('Outlevo-Signature'), body)) return res.sendStatus(401);
const id = req.get('Outlevo-Event-Id');
if (seen.has(id)) return res.sendStatus(200); // a retry of something already handled
seen.add(id);
res.sendStatus(200); // answer first, work after
queueMicrotask(() => handle(JSON.parse(body)));
});
function handle(event) {
if (event.type === 'meeting.booked') { /* post to chat, create the deal */ }
}
app.listen(3000);How Outlevo handles it
What the API and the webhooks do for this step, so your workflow does not have to.
- A webhook address must be HTTPS on port 443 and resolve only to public internet addresses; Outlevo checks this when you subscribe and again before every delivery.
- The signing secret is in the answer to the subscribe call, and only there.
- Every delivery carries an Outlevo-Signature header with a Unix timestamp (t) and an HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with your secret (v1).
- Every delivery carries an Outlevo-Event-Id header that stays the same when the delivery is retried.
- A delivery that does not get a 2xx answer within 10 seconds is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours, then marked failed.
- A test call sends one signed webhook.test delivery at once and answers with the status code your endpoint returned.
- Rotating the secret returns a new one; for 24 hours each delivery carries a signature for the old secret and one for the new, and either verifies.
- A delivered webhook uses 1 credit; a delivery that fails uses none.
Your worksheet
Fill in one row per address. The row below is an example (illustrative).
| Address | Events | Secret stored in | Verifies signature | Drops repeats | Test ping passed |
|---|---|---|---|---|---|
| (example) https://n8n.example.com/webhook/meetings | meeting.booked | n8n Crypto credential | Yes | Yes | Yes |
Common mistakes
- Checking the signature against parsed JSON instead of the raw body.
- No timestamp check, so an old delivery replays.
- Doing the work before answering, so slow CRM calls turn into retries and duplicates.
- Keeping the secret in the workflow's code or a sheet.
Workflows to import
Ready n8n workflows for this step. Each carries a note with its credentials, the scopes its key needs and the subscribe call.
Build it against fake data first
A test key works on a sandbox of fake companies: no credits used, no email sent.