Skip to main content

Overview

All Daya webhooks include an X-Daya-Signature header containing an HMAC-SHA256 signature of the payload. Always verify this signature to ensure the webhook came from Daya.
Never process unverified webhooks. Attackers could send fake webhooks to manipulate your system.

Signature Header

Verification Algorithm

  1. Get raw request body as string
  2. Compute HMAC-SHA256 using your webhook secret
  3. Compare computed signature with X-Daya-Signature header
  4. Use timing-safe comparison to prevent timing attacks

Implementation Examples

Important Notes

Critical: Compute HMAC on the raw request body before parsing JSON. Parsing changes whitespace and ordering, breaking the signature.
Regular string comparison (==) is vulnerable to timing attacks. Use constant-time comparison:
  • Node.js: crypto.timingSafeEqual()
  • Python: hmac.compare_digest()
  • Go: hmac.Equal()
  • PHP: hash_equals()
  • Store webhook secret in environment variables
  • Never commit secrets to version control
  • Rotate secrets regularly
  • Use different secrets for sandbox and production

Testing Verification

Generate test signatures for local testing:

Common Issues

Possible causes:
  • Using wrong webhook secret
  • Not using raw request body
  • Character encoding issues
Debug:
Cause: Parsing JSON before verificationFix: Always compute HMAC on raw body, then parse JSON

Next Steps

Webhook Overview

Learn about webhook delivery and event types

Webhook Events

Event schemas and payloads