Skip to main content

Overview

Every Daya Stocks webhook includes an X-Webhook-Signature header carrying an HMAC-SHA256 signature of the raw request body with a sha256= prefix. Always verify this signature to confirm the request came from Daya.
Never process an unverified webhook. Without verification, an attacker could post fake events to your endpoint.

Signature Header

The signing key is the 64-character hex secret returned when you create the webhook or rotate its secret. Store it securely; it is shown only at those two moments.

Additional Headers

Daya sends these headers with every delivery:

Verification Algorithm

1

Read the raw body

Capture the request body as raw bytes, before any JSON parsing.
2

Compute the HMAC

Compute HMAC-SHA256 over the raw body using your webhook secret, and hex-encode the result.
3

Strip the prefix

Remove the sha256= prefix from the X-Webhook-Signature header.
4

Compare in constant time

Compare your computed signature with the header value using a timing-safe comparison.

Implementation Examples

Important Notes

Compute the HMAC over the exact bytes Daya sent. Re-serializing parsed JSON changes whitespace and key order, which breaks the signature.
Plain string comparison leaks timing information. Use a constant-time comparison: crypto.timingSafeEqual() (Node.js), hmac.compare_digest() (Python), or hmac.Equal() (Go).
Rotation takes effect immediately and the new secret is shown only after rotation. Pause the webhook in the Dashboard, rotate and copy the secret, update your secret store and receiver, then re-enable delivery. Reconcile API state for the paused interval.
Store the secret in an environment variable or secret manager. Use a different secret per environment.

Next Steps

Webhooks Overview

Events, delivery, and retries

Rotate a Secret

Rotate signing secrets from your workspace’s Webhooks page.