Skip to content

Verifying signatures

Every webhook NuacemOne sends, workflow events and transcript deliveries alike, is signed the same way. Check the signature before you trust the body.

Each request has two headers:

Header Value
X-VoiceCX-Timestamp The Unix time in seconds when the request was signed, for example 1763889302.
X-VoiceCX-Signature v1= followed by 64 lower-case hex characters.

The signature is:

v1= hex( HMAC-SHA256( key = signing secret, message = "<timestamp>." + raw body bytes ) )

To verify:

  1. Take the raw request body, exactly as received. Do not parse and re-serialise it.
  2. Build "<timestamp>." from the timestamp header, and append the raw body.
  3. Compute the HMAC-SHA256 with your signing secret, as lower-case hex, and prefix v1=.
  4. Compare it with the header using a constant-time comparison. The header may hold more than one comma-separated signature; accept the request if any v1= value matches.
  5. Reject the request if the timestamp is more than 5 minutes from your clock. This stops an old, captured request from being replayed.

The same scheme, with your workspace’s inbound secret, signs requests you send to a signed workflow hook.

const crypto = require('node:crypto');
function verifySignature(secret, rawBody, timestamp, signatureHeader, toleranceSeconds = 300) {
const ts = Number.parseInt(timestamp, 10);
if (!Number.isFinite(ts) || Math.abs(Date.now() / 1000 - ts) > toleranceSeconds) return false;
const expected = Buffer.from(
'v1=' + crypto.createHmac('sha256', secret).update(`${ts}.`).update(rawBody).digest('hex'),
);
return String(signatureHeader || '').split(',').some((part) => {
const given = Buffer.from(part.trim());
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}

With Express, use express.raw() so req.body is the exact bytes that were signed:

const express = require('express');
const app = express();
app.post('/webhooks/nuacemone', express.raw({ type: 'application/json' }), (req, res) => {
const ok = verifySignature(process.env.NUACEMONE_WEBHOOK_SECRET, req.body,
req.get('X-VoiceCX-Timestamp'), req.get('X-VoiceCX-Signature'));
if (!ok) return res.sendStatus(401);
const event = JSON.parse(req.body.toString('utf8'));
queue.add(event); // do the work later
res.sendStatus(204); // answer quickly
});

The SDKs have the same check built in: NuacemOne.webhooks.verify(secret, rawBody, timestamp, signature) in Node and verify_webhook(secret, raw_body, timestamp, signature) in Python.

  • Verifying parsed JSON. Frameworks that parse JSON first lose the exact bytes. Read the raw body.
  • Wrong secret. Each workflow webhook endpoint and each transcript webhook destination has its own secret. Agents’ Transcript Webhooks use the workspace’s agent webhook secret.
  • Plain string comparison. Use crypto.timingSafeEqual or hmac.compare_digest.
  • Server clock drift. Keep your clock in sync (NTP), or valid requests will fail the 5-minute check.
  • Answer 2xx quickly, within a few seconds. Queue the work.
  • Deduplicate: workflow events on X-VoiceCX-Event-Id, transcripts on X-VoiceCX-Delivery. Retries resend the same id with a new timestamp and signature.
  • Retries follow a fixed schedule: see workflow event retries and transcript delivery retries.