Webhooks

Documentation

Webhooks

Setting up and managing webhook integrations


Webhooks


Webhooks allow LTVboost to send real-time notifications to your applications when events occur.


Supported Events


Response Events

  • `response.created` - New quiz response received
  • `response.scored` - Response scored and outcome determined

  • Action Events

  • `action.queued` - Action added to processing queue
  • `action.sent` - Action successfully executed
  • `action.failed` - Action execution failed

  • Segment Events

  • `segment.updated` - Segment membership changed
  • `segment.ready` - Segment calculation completed

  • Setup


    1. Create Webhook Endpoint

    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');

    });


    2. Register Webhook

    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"

    }'


    Security


    Signature Verification

    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}`;

    }


    Retry Logic

  • Failed webhooks are retried with exponential backoff
  • Maximum 5 retry attempts
  • 24-hour retry window
  • Failed webhooks logged for debugging