Webhooks
WRAPA sends a POST with a JSON event to your HTTPS endpoint when something changes — a member is enrolled, a claim decision is made, an invoice is issued or paid. Return any 2xx within 10 seconds; failed deliveries are retried with backoff for 24 hours, and you can redeliver past events from the workspace.
Verify every delivery
Each request carries Wrapa-Signature: t=<unix seconds>,v1=<hex>. Compute an HMAC-SHA256 of "<t>.<raw body>" with your endpoint’s signing secret, compare it in constant time, and reject anything older than five minutes. During a secret rotation the header can carry two v1 values — accept either.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(header, rawBody, secret, now = Date.now() / 1000) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const t = Number(parts.t);
if (!t || Math.abs(now - t) > 300) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
return header
.split(',')
.filter((p) => p.startsWith('v1='))
.some((p) => {
const given = Buffer.from(p.slice(3), 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
});
}import hashlib, hmac, time
def verify(header: str, raw_body: bytes, secret: str) -> bool:
parts = [p.split("=", 1) for p in header.split(",")]
t = next((int(v) for k, v in parts if k == "t"), 0)
if abs(time.time() - t) > 300:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return any(k == "v1" and hmac.compare_digest(v, expected) for k, v in parts)Good practice
- Verify against the raw body bytes, before parsing the JSON.
- Use the event
idto ignore duplicates: delivery is at least once. - Acknowledge fast and do slow work in the background.