Webhook Secrets
Overview
To ensure security and authenticity, Cashless signs all webhook requests. Verify that requests came from Cashless by checking the signature in the webhook headers.
Setting up Webhook Signatures
- Generate a webhook secret in your developer dashboard. (Developers > API Keys)
- Store this secret securely — you'll need it to verify incoming webhooks.
- Cashless will include this signature in the
X-Webhook-Signatureheader of all webhook requests.
Verifying Signatures
When you receive a webhook:
- Get the signature from the
X-Webhook-Signatureheader. - Compare this value with your stored webhook secret.
- Only process the webhook if the signatures match.
Example in Node.js:
app.post('/webhook', (req, res) => {
const signature = req.headers['x-webhook-signature'];
const webhookSecret = process.env.WEBHOOK_SECRET; // Your stored secret
if (signature !== webhookSecret) {
return res.status(401).send('Invalid signature');
}
// Process webhook...
});Security Best Practices
- Always verify the signature of incoming webhooks.
- Keep your webhook secret secure and never commit it to version control.
- Rotate your webhook secret periodically.
- Use HTTPS endpoints for receiving webhooks.
- Implement timeout handling for webhook processing.
Updated about 2 months ago
