Recover
...
API Reference
Resources
Webhook Signature Verification
3min
overview code examples that can be used to verify a webhook signature using a signing key python \# python import json import hashlib import hmac from time import time def verify webhook signature(body dict, headers dict, signing key str) > bool 	now = int(time()) 	payload = json dumps(body, separators=(",", " ")) 	incoming signature = headers get("x butter webhook signature") 	expires at = headers get("x butter webhook expires") 	message = f"{payload}+{expires at}" encode("utf 8") 	signature = hmac new(signing key encode("utf 8"), message, hashlib sha256) hexdigest() 	if signature != incoming signature 	 return false 	if expires at < now 	 return false 	return true javascript // javascript const crypto = require('crypto'); function verifywebhooksignature(body, headers, signingkey) { 	const now = math floor(new date() gettime()/1000); 	const payload = json stringify(body); 	const expiresat = headers\["x butter webhook expires"]; 	const incomingsignature = headers\["x butter webhook signature"]; 	const hmac = crypto createhmac('sha256', signingkey); 	const data = hmac update(buffer from(`${json stringify(body)}+${expiresat}`)); 	const signature = data digest('hex'); 	if(signature != incomingsignature) return false; 	if(expiresat < now) return false; 	return true; }