Why Verify Signatures?
Anyone can send a POST request to your webhook URL. Without signature verification, an attacker could send fakepayment.success events to your endpoint — causing you to fulfill orders that were never actually paid.
CWMPay signs every webhook request using HMAC-SHA256. Always verify this signature before processing.
How It Works
- CWMPay generates a signature by running HMAC-SHA256 on the request payload using your Webhook Secret
- The signature is sent in the
X-CWMPay-Signatureheader - Your server generates the same signature using the same secret
- If both signatures match — the request is genuine
Getting Your Webhook Secret
- Login to app.cwmpay.in
- Go to Webhooks section
- Set your webhook URL and save
- Your Webhook Secret will be displayed once — copy and store it safely
Verification Examples
Important Notes
Use timing-safe comparison
Use timing-safe comparison
Always use
crypto.timingSafeEqual() (Node.js) or hmac.compare_digest() (Python) instead of === for signature comparison. Regular string comparison is vulnerable to timing attacks.Use raw body for verification
Use raw body for verification
Verify the signature against the raw JSON string — not a parsed and re-serialized object. JSON key ordering may differ and cause signature mismatch.
Store secret in environment variables
Store secret in environment variables
Next Steps
Webhooks Overview
Learn about webhook events and payload
Error Reference
View all error codes

