Webhook Secrets
Set a shared webhook secret in your HoneyCoin dashboard and use it to verify incoming webhook requests.
Setting up Webhook Signatures
You create and set the webhook secret. HoneyCoin does not generate a webhook secret for you to copy.
- Create a strong random secret. For example, you can run
openssl rand -hex 32. - In the HoneyCoin dashboard, go to Developers > API Keys.
- Enter your secret in the Webhook Secrets field for the appropriate environment and select Save.
- Store the same secret securely in your server-side environment or secrets manager.
HoneyCoin stores the secret and sends the same value in the X-Webhook-Signature header of webhook requests. Sandbox and production secrets are configured separately.
Verifying Signatures
When you receive a webhook, you should:
- Get the signature from the
X-Webhook-Signatureheader. - Compare this value with the secret you created and stored.
- Only process the webhook if the signatures match.
Here's an example of verifying a webhook 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 9 days ago
