Verify the signature
Copies this page as Markdown with context, so an AI can walk you through your case step by step.
Anyone can send a POST to your URL. The signature proves we sent it and nobody changed it.
Where the secret is
In Alerts and on-call → Channels, each webhook shows its Signing secret below it. Every channel has a different one. Keep it as an environment variable in your app, never in the code.
How it’s signed
The X-Ganyant-Signature header is the HMAC-SHA256, in hex, of the exact body you receive, using the secret as the key.
The important part: compute the signature over the raw body, before parsing it as JSON. If your framework already parsed it and you turn it back into text, spacing or order can change and the signature won’t match.
Node.js
import crypto from 'node:crypto';
export function verify(rawBody, signature, secret) {
const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(signature, 'hex'));
}
With Express, use express.raw({ type: 'application/json' }) on that route to get the raw body.
Python
import hmac, hashlib
def verify(raw_body: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
In Flask, the raw body is request.get_data(); in Django, request.body.
PHP
$raw = file_get_contents('php://input');
$expected = hash_hmac('sha256', $raw, getenv('GANYANT_SECRET'));
if (!hash_equals($expected, $_SERVER['HTTP_X_GANYANT_SIGNATURE'] ?? '')) {
http_response_code(401);
exit;
}
Go
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(rawBody)
expected := hex.EncodeToString(mac.Sum(nil))
ok := hmac.Equal([]byte(expected), []byte(r.Header.Get("X-Ganyant-Signature")))
Prevent replays
Besides the signature, reject events whose sent_at (Unix seconds) is more than 5 minutes old. That way, if someone captures a valid webhook, they can’t send it again later.
Test
Click Test next to the channel: you get a test event signed exactly like real ones.