ChatSense
API & Webhooks webhooks eventos payload hmac

Webhooks: lista de eventos e estrutura do payload

Webhooks — receba eventos em tempo real

Como configurar

  1. Admin → Integrações → Webhooks → Novo Webhook
  2. URL de destino (deve aceitar POST e retornar 200)
  3. Selecione eventos e copie o Webhook Secret

Estrutura do payload

{
  "event": "message.created",
  "timestamp": "2025-06-27T14:30:00Z",
  "organization_id": "org_123",
  "data": {
    "id": "msg_456",
    "conversation_id": "conv_789",
    "content": "Olá!",
    "sender": { "type": "contact", "id": "ctt_321" }
  }
}

Verificação HMAC-SHA256

const sig = crypto
  .createHmac('sha256', webhookSecret)
  .update(rawBody)
  .digest('hex');
const valid = `sha256=${sig}` === req.headers['x-chatsense-signature'];

Política de retry

Em erro (não-2xx) ou timeout (>10s): 3 retentativas com backoff — 1min, 5min, 30min. Após 3 falhas, o webhook é desativado automaticamente e você recebe notificação por e-mail.