PlatformXeDocs
Get API Key

Signature Verification

Verify webhook payload authenticity using HMAC-SHA256 signatures and prevent replay attacks.

Every webhook delivery is signed with your endpoint's secret. Verify the signature before you trust the payload.

Signature headers

A v2 delivery (recipient endpoint) carries the canonical X-Caldera-* headers and, during the migration period, the legacy X-Webhook-* pair:

HeaderDescription
X-Caldera-Signaturesha256= followed by the hex HMAC-SHA256 signature
X-Caldera-TimestampUnix timestamp (seconds) when the payload was signed
X-Caldera-Delivery-IdUnique delivery id (an opaque string - do not assume a UUID), for deduplication
X-Webhook-Signature, X-Webhook-TimestampLegacy copies of the signature and timestamp; deprecated
X-Webhook-IdThe event id (event_id, 1-200 visible ASCII characters), the same on every attempt and redelivery of the event
X-Webhook-EventThe event type
User-AgentPlatformX-Webhooks/2.0

A v1 delivery (untargeted caller endpoint) carries X-Webhook-Signature, X-Webhook-Timestamp, X-Webhook-Event (the event type) and X-Webhook-Id (the delivery id), with User-Agent: PlatformX-Webhooks/1.0. The signature algorithm is the same. Since 2026-10-25 a v1 delivery also carries X-Caldera-Signature, X-Caldera-Timestamp and X-Caldera-Delivery-Id with the same values; move your verifier to them. The legacy X-Webhook-Signature / X-Webhook-Timestamp pair is sent until 2027-04-30, then only X-Caldera-*.

Earlier versions of this page documented X-Event-Signature / X-Event-Timestamp / X-Event-Type / X-Event-Id. Those headers are only sent on direct escalation dispatches, never on the deliveries of a webhook you registered. Use the X-Caldera-* (v2) or X-Webhook-* (v1) headers above.

How signatures work

  1. Take the timestamp (the X-Caldera-Timestamp value) and the raw request body exactly as received.
  2. Join them with a dot: {timestamp}.{rawBody}.
  3. Compute HMAC-SHA256 of that string with your webhook secret and hex-encode it.
  4. The header value is sha256= plus that hex string.
X-Caldera-Signature = "sha256=" + hex(HMAC-SHA256(secret, "{timestamp}.{rawBody}"))

The body is the JSON { "event": "...", "event_id": "...", "timestamp": 1760000000, "data": { ... } }.

Verify with @caldera/keys-service

verifyWebhook checks the headers, the replay window and the signature in constant time, and accepts several secrets so you can rotate without downtime:

import { verifyWebhook } from '@caldera/keys-service';

// Pass the RAW body as a string; never a re-serialised object.
const verdict = verifyWebhook({
  secrets: [process.env.WEBHOOK_SECRET!],   // add the previous secret during a rotation
  body: rawBody,
  headers: request.headers,                 // plain record or Web Headers; names are case-insensitive
  toleranceSec: 300,                        // default 300, applied in both directions
});

if (!verdict.ok) {
  // verdict.reason: 'MISSING' | 'BAD_TIMESTAMP' | 'STALE' | 'MISMATCH'
  return new Response('invalid signature', { status: 401 });
}
// verdict.deliveryId: the unsigned X-Caldera-Delivery-Id (or null)

verifyWebhook reads the canonical X-Caldera-* headers first and falls back to the legacy X-Webhook-* pair, so one verifier handles v1 and v2 deliveries.

Verification without the package (Node.js)

import { createHmac, timingSafeEqual } from 'crypto';

function verify(rawBody: string, signature: string, timestamp: string, secret: string): boolean {
  const signedTime = parseInt(timestamp, 10);
  if (!Number.isFinite(signedTime) || Math.abs(Date.now() / 1000 - signedTime) > 300) return false;

  const expected = 'sha256=' + createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
  const a = Buffer.from(expected);
  const b = Buffer.from(signature);
  return a.length === b.length && timingSafeEqual(a, b);
}

Express handler

import express from 'express';
import { verifyWebhook } from '@caldera/keys-service';

const app = express();

app.post('/webhooks/platformxe', express.raw({ type: 'application/json' }), (req, res) => {
  const rawBody = req.body.toString('utf-8');
  const verdict = verifyWebhook({
    secrets: [process.env.WEBHOOK_SECRET!],
    body: rawBody,
    headers: req.headers,
  });
  if (!verdict.ok) return res.status(401).json({ error: 'Invalid signature' });

  const event = JSON.parse(rawBody);
  // Apply the event's state; see "Idempotent receivers" below.
  res.status(200).json({ received: true });
});

Replay protection

The signed timestamp enables replay protection. Reject a delivery whose timestamp is outside the window (default 5 minutes, in both directions, so a clock running ahead is refused too). verifyWebhook does this for you (STALE).

Idempotent receivers

The delivery id header is not signed: it can be forged. Use it only to skip an exact redelivery after the signature verified and the event was handled successfully. Do not rely on it for correctness. Write handlers to be state-idempotent: apply the state the event describes, so a retry, a redelivery or a duplicate has no further effect.

The signing secret

The secret is returned once, in the response that creates the endpoint or rotates its secret. It is never returned by a list or get, and PlatformXe cannot show it again. Keep it in your secrets manager. Rotate it with POST /api/v1/webhooks/:id/rotate; the old secret stops verifying immediately, so deploy the new one first or accept both during the switch.

Always compare signatures in constant time (timingSafeEqual, or verifyWebhook). Standard string comparison (===) is vulnerable to timing attacks.