Webhooks

Signature verification

Every webhook carries a WhatPro-Signature header: t is the time it was sent (Unix seconds) and v1 the HMAC-SHA256 of "t.raw_body" with your signing secret, in hex.

http
WhatPro-Signature: t=1793782800,v1=5f2b8c0d…e91a
  1. Read the raw request body, before parsing the JSON.

  2. Compute HMAC-SHA256(signing_secret, t + "." + raw_body) in hex.

  3. Compare it with v1 in constant time, and refuse a t older than 5 minutes.

import crypto from "node:crypto";
import express from "express";

const app = express();
// Read the RAW body: the signature is over the exact bytes Yudoo sent.
app.post("/yudoo/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("WhatPro-Signature") ?? "";
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto
    .createHmac("sha256", process.env.YUDOO_SIGNING_SECRET)
    .update(`${t}.${req.body}`)
    .digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
  if (!fresh || !v1 || !crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1))) {
    return res.status(400).send("bad signature");
  }
  const event = JSON.parse(req.body);
  // event.type: "order.confirmed" | "order.cancelled" | "webhook.test"
  res.sendStatus(200);
});

The webhook headers keep the WhatPro- prefix (WhatPro-Signature, WhatPro-Event, WhatPro-Delivery): Yudoo was called WhatPro, and the names stay so existing integrations keep working.

Stuck, or need a field we don't have yet? Our team answers on WhatsApp.

Ask us on WhatsAppOpen the Yudoo app