Webhooks

A webhook is an address of yours that we call when something happens, so nothing has to keep checking. Use them to wake an agent when a chat needs help, or to update your own records when one finishes.

Set one up

On the API page of the dashboard, under Webhooks, enter your address and pick the events. Or with the API:

curl https://api.refundhunter.io/api/webhooks \
  -H "Authorization: Bearer $CHATTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/chatter-webhook", "events": ["chat.completed", "chat.needs_help"] }'

The response includes a secret (starting whsec_). It is shown once. Keep it: you need it to verify requests.

The address must be public and start with https://. You can have up to 10.

Events

EventWhendata
chat.completedA chat finisheschat: the compact chat, with outcome and summary
chat.failedA chat could not runchat
chat.needs_helpThe AI is waiting for your answerchat, with helpRequest
chat.messageNew messages in a chatchatId, messages
order.updatedAn order changesorder

chat.message is busy. Subscribe to it only if you need the conversation as it happens.

What we send

A POST with a JSON body:

{
  "id": "0c9d6d3e-5f0b-4a53-9d0a-1c2b3a4d5e6f",
  "type": "chat.completed",
  "createdAt": "2026-12-01T15:42:10.000Z",
  "data": {
    "chat": {
      "id": "8b0c6c0e-...",
      "name": "BBY01-806912345678",
      "status": "completed",
      "outcome": "resolved",
      "summary": "Rep approved a full refund of $129.99 to the original payment method.",
      "orderNumber": "BBY01-806912345678",
      "needsHelp": false,
      "messageCount": 14
    }
  }
}

And these headers:

HeaderValue
X-Chatter-EventThe event type
X-Chatter-DeliveryThe delivery id, the same as id in the body
X-Chatter-Signaturet=<timestamp>,v1=<signature>

Verify the signature

Anyone could send a request to your address. Check the signature before trusting one. It is an HMAC-SHA256 of <timestamp>.<raw body> using your secret.

import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromChatter(secret, rawBody, signatureHeader) {
  const parts = Object.fromEntries(signatureHeader.split(',').map((p) => p.split('=')));
  const age = Math.abs(Date.now() / 1000 - Number(parts.t));
  if (!parts.v1 || !(age < 300)) return false; // ignore anything older than 5 minutes
  const expected = createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex');
  return expected.length === parts.v1.length && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}

Use the raw request body exactly as received, before any JSON parsing.

Answering, retries and switching off

  • Answer with any 2xx status within 10 seconds. Do slow work after answering.
  • Anything else counts as a failure and is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours.
  • A retry carries the same id. Use it to ignore an event you have already handled.
  • If deliveries keep failing through all their retries, the webhook is switched off. Turn it back on from the dashboard or with PATCH /api/webhooks/{id} and { "enabled": true }.
  • Redirects are not followed.

Test and inspect

POST /api/webhooks/{id}/test (or Send test in the dashboard) sends a webhook.test event. GET /api/webhooks/{id}/deliveries lists the last 25 deliveries with the status your address returned and any error.