Learn how to verify webhook signatures to ensure requests are authentic and from Parchment.Documentation Index
Fetch the complete documentation index at: https://docs.parchmenthealth.io/llms.txt
Use this file to discover all available pages before exploring further.
Why Verify Signatures?
Webhook signature verification ensures that:- Webhooks are sent by Parchment, not a malicious actor
- The payload hasn’t been tampered with
- The webhook isn’t a replay attack (using timestamps)
How It Works
Parchment signs every webhook using HMAC SHA-256:- Creates a signed payload:
timestamp.json_body - Computes HMAC SHA-256 signature using your webhook secret
- Sends the signature in the
X-Webhook-Signatureheader - Your application verifies the signature matches
Signature Header Format
TheX-Webhook-Signature header contains:
t= Unix timestamp (seconds) when the webhook was sentv1= HMAC SHA-256 signature (hex-encoded)
Step-by-Step Verification
Step 1: Extract the Signature Header
Get theX-Webhook-Signature header from the request.
Step 2: Parse Timestamp and Signature
Split the header on commas and extract the timestamp (t) and signature (v1).
Step 3: Check Timestamp Tolerance
Verify the timestamp is within 5 minutes of the current time to prevent replay attacks.Step 4: Compute Expected Signature
Create the signed payload:timestamp.raw_json_body
Compute HMAC SHA-256 using your webhook secret.
Step 5: Compare Signatures
Use timing-safe comparison to compare the signatures.Implementation Examples
Testing Your Verification
Generate a Test Signature
Use this script to generate a test signature:Test with cURL
Common Issues
”Timestamp outside tolerance window”
Cause: The webhook timestamp is more than 5 minutes old. Solutions:- Ensure your server clock is synchronized (use NTP)
- Check for network delays
- Verify your server isn’t taking too long to process requests
”Signature mismatch”
Cause: The computed signature doesn’t match the provided signature. Solutions:- Ensure you’re using the correct webhook secret
- Verify you’re using the raw request body (not parsed JSON)
- Check you’re not modifying the body before verification
- Ensure proper UTF-8 encoding
”Invalid signature header format”
Cause: The signature header is malformed. Solutions:- Verify you’re reading the
X-Webhook-Signatureheader correctly - Check for any middleware that might be modifying headers
Security Best Practices
DO verify signatures before processing
DO use timing-safe comparison functions
DO check timestamp tolerance (prevent replay attacks)
DO store webhook secrets in a secrets manager (e.g. AWS Secrets Manager, HashiCorp Vault)
DO log verification failures for security monitoring
Troubleshooting Checklist
When debugging webhook verification:- Using HTTPS endpoint?
- Reading
X-Webhook-Signatureheader correctly? - Using raw request body (not parsed JSON)?
- Using correct webhook secret?
- Server clock synchronized?
- Timing-safe comparison implemented?
- Checking timestamp tolerance?
- Logging verification failures?
Next Steps
- Review webhook event types and payloads
- Contact support at hello@parchment.health

