Skip to content
Documentation
Hevia for developers

Signature check

HMAC-SHA256 over the timestamp and the raw body, with a five-minute tolerance.

Every delivery carries Hevia-Signature: t=<unix seconds>,v1=<hex> where

Text
v1 = HMAC-SHA256(secret, "<t>.<raw body>")

and secret is the whsec_… value shown once when the subscription was created.

  1. Read the raw bytes of the body. Re-serialised JSON has different bytes and never matches.
  2. Parse t and v1 from the header.
  3. Reject the request when t is more than 300 seconds away from now (replays).
  4. Compute the HMAC and compare it in constant time.
import { constructEvent, WebhookSignatureError } from "@hevia/sdk";

// rawBody: the request body exactly as received (string or Buffer)
try {
  const event = constructEvent(rawBody, req.headers["hevia-signature"], process.env.HEVIA_WEBHOOK_SECRET!);
  if (event.livemode && event.type === "deal.won") await queue.add(event);
} catch (err) {
  if (err instanceof WebhookSignatureError) return res.status(400).end();
  throw err;
}
Tip

A full receiver with Express is in the guide Receive and verify a webhook.

Generated from the product's own registries, so the reference matches the API.