[ BLOG POST ]

Verifying webhook signatures before you trust a payload

Webhooks are HMAC-signed. Verify the signature against the raw request body before you update any record.

Quick answer

Sendflit signs its webhooks with HMAC. To verify one, compute the HMAC of the raw request body with your webhook secret, compare it to the signature header using a constant-time comparison, and reject the request if they differ.

Key takeaways

  • Verify against the raw request body, before your framework parses it.

  • Use a constant-time comparison for the signature.

  • Reject and log any payload that fails verification.

Why must you verify webhook signatures?

A webhook endpoint is a public URL, and anyone can send a request to it. Without verification, a forged payload could mark real customers as bounced, unsubscribe them, or trigger your own workflows.

Sendflit signs its webhooks with HMAC. The signature is computed from the body using a secret, so only a sender that knows the secret can produce a valid one.

How do you verify a signature?

Read the raw request body before your framework parses it. Parsing the JSON first can change whitespace and break the check. Compute the HMAC with your webhook secret, compare it with the signature header using a constant-time comparison, and reject the request if they differ.

Return an error for any payload that fails verification, and log the attempt without storing the body.

What causes verification failures?

Repeated failures usually mean the secret was rotated on one side and not the other. Check that the secret in your configuration matches the one in the dashboard.

Parsing the body before verifying it is the other common cause. Keep the raw body available to your verification step.

Frequently asked questions

What is the HMAC signature for?

It proves that the webhook came from a sender that knows your secret, and that the body was not changed in transit.

Why verify against the raw body?

Parsing and re-serializing JSON can change the bytes, which makes the signature check fail even for genuine events.

What should I do with a payload that fails verification?

Reject it with an error response, log the attempt without storing the body, and do not update any records.

Last updated September 2026 by the Sendflit team.