Setting up and managing webhook integrations
Webhooks allow LTVboost to send real-time notifications to your applications when events occur.
app.post('/webhooks/ltvboost', (req, res) => {
const event = req.body;
// Verify signature
const signature = req.headers['x-ltvboost-signature'];
if (!verifySignature(signature, req.body)) {
return res.status(401).send('Invalid signature');
}
// Process event
switch (event.type) {
case 'response.created':
handleNewResponse(event.data);
break;
case 'action.sent':
handleActionSent(event.data);
break;
}
res.status(200).send('OK');
});
curl -X POST https://api.ltvboost.com/v1/webhooks \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/ltvboost",
"events": ["response.created", "action.sent"],
"secret": "your-webhook-secret"
}'
All webhooks include an HMAC-SHA256 signature for verification:
const crypto = require('crypto');
function verifySignature(signature, payload) {
const expectedSignature = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(payload)
.digest('hex');
return signature === `sha256=${expectedSignature}`;
}