# Webhooks

> Real-time events and signature verification.

Source: https://developers.converzap.com/en/webhooks

Outgoing webhooks send inbox events to your URL in real time (**Enterprise** plan feature). Set them up in the app (**Settings → Webhooks**) or via the API (`POST /v1/webhooks`).

## Events

| Event | When |
|---|---|
| `message.received` | the contact sent a message |
| `message.sent` | the business sent one (agent, AI agent, campaign, automation or phone) |
| `message.status_updated` | delivered, read or failed |
| `conversation.assigned` | the conversation got an assignee |
| `conversation.awaiting_human` | the AI agent handed off to the team |
| `conversation.resolved` / `conversation.reopened` | status changed |
| `deal.stage_changed` | the deal moved to another funnel stage |
| `automation.step` | an automation's "Call webhook" step |
| `test` | the "Send test" button or `POST /v1/webhooks/{id}/test` |

## Format

```json
{
  "id": "0b6c…",
  "event": "message.received",
  "created_at": "2026-10-16T12:00:00Z",
  "api_version": "v1",
  "workspace_id": "6049…",
  "attempt": 1,
  "data": {
    "message": { "id": "1234", "wamid": "wamid.…", "direction": "inbound", "author": "contact", "type": "text", "text": "Hi!", "status": null, "created_at": "…" },
    "conversation": { "id": "…", "channel": { "phone_number_id": "…" }, "contact": { "id": "…", "phone": "+5511…", "name": "Ana" }, "status": "open", "assignee": null, "labels": [], "awaiting_human": false }
  }
}
```

`deal.stage_changed` carries the deal and both stages:

```json
{
  "event": "deal.stage_changed",
  "data": {
    "deal": { "object": "deal", "id": "…", "title": "Clínica Sorriso", "pipeline_id": "…", "stage_id": "…", "contact_id": "…", "value": 1200, "owner_id": "…", "status": "open" },
    "from_stage": { "id": "…", "name": "New lead", "kind": "open" },
    "to_stage": { "id": "…", "name": "Proposal sent", "kind": "open" },
    "user_id": "…",
    "occurred_at": "…"
  }
}
```

Fields follow the API contract (`direction`, `author`, `status`…; `deal` is the same object as `GET /v1/deals`). Headers: `X-ConverZAP-Event`, `X-ConverZAP-Delivery` (delivery id) and `X-ConverZAP-Signature`.

## Verify the signature

`X-ConverZAP-Signature: t=<unix>,v1=<hex>`, where `v1 = HMAC-SHA256(secret, "<t>.<raw body>")`. Reject if `t` is more than 5 minutes off.

```javascript
import crypto from "node:crypto";
function verify(body, header, secret) {
  const p = Object.fromEntries(header.split(",").map((x) => x.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${p.t}.${body}`).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(p.v1));
}
```

Reply **2xx** within 10 s. Otherwise we retry after 1 min, 5 min, 30 min, 2 h, 6 h and 12 h; `410` stops retries; 20 consecutive failures pause the webhook. Deliveries may repeat and arrive out of order: dedupe by `id`. The log is at `GET /v1/webhooks/{id}/deliveries` for 30 days.
