Webhook Security
Every webhook delivery includes an X-Signature header containing an HMAC-SHA256 hash of the request body, signed with your webhook's signing secret.
Verification Steps
- Extract the
X-Signatureheader from the incoming request - Compute the HMAC-SHA256 hash of the raw request body using your signing secret
- Compare the computed hash with the received signature using a timing-safe comparison
Code Examples
python
import hmacimport hashlibdef verify_webhook(body: bytes, signature: str, secret: str) -> bool:expected = hmac.new(secret.encode('utf-8'),body,hashlib.sha256).hexdigest()return hmac.compare_digest(expected, signature)# In your webhook handler:# body = request.get_data()# signature = request.headers.get('X-Signature')# is_valid = verify_webhook(body, signature, 'whsec_your_secret')
Event Payload Examples
export.created
json
{"event": "export.created","status": "processing","platform": "youtube","message_id": "msg_abc123"}
export.finished
json
{"event": "export.finished","status": "done","comments_count": 150,"download_url": "https://exportcomments.com/exports/12345.xlsx"}
export.failed
json
{"event": "export.failed","status": "failed","error_message": "Video not found or is private"}
Best Practices
- Always verify signatures using
hash_equals()or timing-safe comparison to prevent timing attacks - Use
message_idfor idempotency to avoid processing duplicate deliveries - Return 200 immediately and process the webhook payload asynchronously
- Auto-suspension: Webhooks are suspended after 30 consecutive delivery failures. Re-enable via the toggle endpoint after fixing your endpoint