Skip to main content
SendPost includes HMAC-SHA256 signatures in all webhook requests, allowing you to verify that webhooks truly came from SendPost and that the payload hasn’t been altered in transit.

Overview

Every webhook request from SendPost includes signature headers that you can use to verify authenticity. The signature is computed using HMAC-SHA256 with your Account API Key as the secret, ensuring that only requests with the correct secret can generate valid signatures.

Webhook Headers

SendPost includes the following headers in every webhook request:

Example Webhook Request Headers

Verification Process

To verify a webhook request:
  1. Extract the signature from the X-SendPost-Signature header
  2. Read the raw request body (as bytes/string, before any JSON parsing)
  3. Compute HMAC-SHA256 of the request body using your Account API Key as the secret
  4. Hex-encode the computed signature
  5. Compare the computed signature with the header value using a constant-time comparison
If the signatures match, the webhook is authentic and unaltered.
Always use constant-time comparison when comparing signatures to prevent timing attacks. Never use simple string equality (== or ===).

Code Examples

JavaScript (Node.js)

Python

Go

Ruby

Java (Spring Boot)

PHP

Important Considerations

Request Body Handling

Critical: Always use the raw request body (as bytes/string) for signature verification, not the parsed JSON object. The signature is computed on the exact bytes sent by SendPost.
  • Do: Read the raw body before parsing JSON
  • Don’t: Parse JSON first and then try to verify the signature
  • Do: Preserve the exact byte sequence received
  • Don’t: Modify, prettify, or re-encode the body

Account API Key

The signature is computed using your Account API Key, not your Sub-Account API Key. Make sure you’re using the correct key for verification.

Retry Attempts

The X-SendPost-Webhook-Attempt header indicates which retry attempt this is. SendPost will retry failed webhook deliveries for up to 10 hours. Each retry will have the same payload but a different attempt number.

Security Best Practices

  1. Always verify signatures before processing webhook data
  2. Use constant-time comparison to prevent timing attacks
  3. Store your API key securely (environment variables, secret management services)
  4. Log verification failures for security monitoring
  5. Reject requests without signatures immediately

Example Webhook Payload

Here’s an example of a webhook request with signature headers: Headers:
Body:
The signature in X-SendPost-Signature is computed from the exact JSON body above using your Account API Key.
For more information about webhook events and payloads, see SendPost Webhook Object.