Webhook tester
Log in as the owner or an admin of the number, or paste an API key of the number (scope webhooks:manage) and enter the number above. Until then: samples and verify code only.
Send to a URL
A contact was made or changed through the API (upsert, patch, consent; not imports), or turned marketing messages back on in WhatsApp.
BodyUnchanged = the API's own sample of that type. At most 16 KB.
Secret, format, custom headers
Test URL
A temporary URL that keeps what is posted to it (1 hour, 50 requests). Put it in a webhook or send to it above; requests show here live.
Saved webhooks
Verify code
import crypto from "node:crypto";
// rawBody: the body exactly as received (Buffer or string), eg express.raw({ type: "application/json" })
export function verifyWebhook(rawBody, header, secret, toleranceSeconds = 300) {
const t = /(?:^|,)\s*t=(\d+)/.exec(header ?? "")?.[1];
const v1 = [...(header ?? "").matchAll(/(?:^|,)\s*v1=([0-9a-f]+)/g)].map((m) => m[1]); // every v1=: two while an old secret is kept
if (!t || v1.length === 0 || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(t + ".").update(rawBody).digest("hex");
return v1.some((v) => v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
}
// const ok = verifyWebhook(req.body, req.get("X-App2email-Signature"), process.env.WEBHOOK_SECRET); import hashlib, hmac, re, time
def verify_webhook(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
t = re.search(r"(?:^|,)\s*t=(\d+)", header or "")
v1 = re.findall(r"(?:^|,)\s*v1=([0-9a-f]+)", header or "") # every v1=: two while an old secret is kept
if not t or not v1 or abs(time.time() - int(t.group(1))) > tolerance:
return False
expected = hmac.new(secret.encode(), t.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(v, expected) for v in v1)
# ok = verify_webhook(request.get_data(), request.headers.get("X-App2email-Signature"), WEBHOOK_SECRET) <?php
function verify_webhook(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {
if (!preg_match('/(?:^|,)\s*t=(\d+)/', $header, $t)) return false;
preg_match_all('/(?:^|,)\s*v1=([0-9a-f]+)/', $header, $m); // every v1=: two while an old secret is kept
if (!$m[1] || abs(time() - (int)$t[1]) > $tolerance) return false;
$expected = hash_hmac('sha256', $t[1] . '.' . $rawBody, $secret);
foreach ($m[1] as $v) if (hash_equals($expected, $v)) return true;
return false;
}
// $ok = verify_webhook(file_get_contents('php://input'), $_SERVER['HTTP_X_APP2EMAIL_SIGNATURE'] ?? '', getenv('WEBHOOK_SECRET'));