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:- Extract the signature from the
X-SendPost-Signatureheader - Read the raw request body (as bytes/string, before any JSON parsing)
- Compute HMAC-SHA256 of the request body using your Account API Key as the secret
- Hex-encode the computed signature
- Compare the computed signature with the header value using a constant-time comparison
Code Examples
JavaScript (Node.js)
Python
Go
Ruby
Java (Spring Boot)
PHP
Important Considerations
Request Body Handling
- 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
TheX-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
- Always verify signatures before processing webhook data
- Use constant-time comparison to prevent timing attacks
- Store your API key securely (environment variables, secret management services)
- Log verification failures for security monitoring
- Reject requests without signatures immediately
Example Webhook Payload
Here’s an example of a webhook request with signature headers: Headers: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.