# Webhooks > Get a signed POST when mail arrives, a message is sent, a send needs approval, or a domain changes. Source: https://dropline.cleforyx.com/docs/developers/webhooks · Section: Developers · All docs: https://dropline.cleforyx.com/llms.txt ## Create a webhook 1. **Create it with a token that has `webhooks.manage`** ```bash curl -X POST https://dropline.cleforyx.com/api/v1/webhooks \ -H "Authorization: Bearer $DROPLINE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com/hooks/dropline","events":["message.received","message.sent"]}' ``` 2. **Save the secret** The response includes `secret` (`whsec_…`). It is shown **once**. Rotate it any time with `POST /webhooks/{id}/rotate-secret`; the old one stops working at once. 3. **Send a test** `POST /webhooks/{id}/test` sends a `ping` event to your URL. Subscribe to `["*"]` for every event. Add `mailbox_ids` to limit mail events to some mailboxes. Webhooks per plan: Free 0, Plus 2, Pro 10, Business 30. ## URL rules - `https://` only, with no credentials in the URL. - No localhost, `.local`, `.internal`, or private, link-local or loopback IPs. This is checked again when we connect, so DNS can’t be used to reach internal hosts. - Redirects are not followed. ## Events | Event | When | `data` | | --- | --- | --- | | `message.received` | New mail in INBOX (checked about every minute) | `mailbox_id, mailbox, folder, uid, message_id, from {name, address}, to [], subject, date, snippet, has_attachments` | | `message.sent` | A message left through SMTP, from any path (app, API, MCP, agent) | `mailbox_id, mailbox, send_id, message_id, to [addresses], subject, via (web \| api \| mcp \| agent)` | | `approval.requested` | An API or MCP send is waiting for approval | `approval_id, mailbox_id, token, to [], subject` | | `domain.verified` | A domain’s records check out (sending enabled) | `domain_id, domain, status, sending, receiving` | | `domain.degraded` | A previously active domain’s records broke | same as `domain.verified` | | `agent.run.completed` | An AI agent handled a new message | `agent_id, agent, mailbox_id, uid, from, subject, decision (drafted \| replied \| skipped \| escalated), reason` | | `ping` | `POST /webhooks/{id}/test` | `webhook_id` | > [!NOTE] > `message.received` starts from the moment the hook exists. Older mail isn’t replayed. ## Delivery We `POST` to your URL with `Content-Type: application/json` and these headers: | Header | Value | | --- | --- | | `X-Dropline-Event` | The event type, e.g. `message.received` | | `X-Dropline-Event-Id` | The event’s id. The same across retries and redeliveries: use it to de-duplicate. | | `X-Dropline-Delivery` | This delivery’s id | | `X-Dropline-Signature` | `t=,v1=` | | `User-Agent` | `Dropline-Webhooks/1.0` | Body: ```json { "id": "6c1d…", "type": "message.received", "created_at": "2026-10-30T12:00:00.000Z", "data": { "mailbox_id": "…", "mailbox": "ama@example.com", "folder": "INBOX", "uid": 4471, "message_id": "<…@example.com>", "from": { "name": "Kofi Mensah", "address": "kofi@example.com" }, "to": ["ama@example.com"], "subject": "Order #4471 delivery", "date": "2026-10-30T11:59:42.000Z", "snippet": "Can I change the address to East Legon?", "has_attachments": false } } ``` ## Verify the signature Compute `HMAC_SHA256(secret, ".")` as hex and compare it with `v1` in constant time. Reject if `t` is more than 5 minutes old. Use the **raw** request body, before any JSON parsing. Node: ```js import { createHmac, timingSafeEqual } from 'node:crypto'; export function verify(rawBody, header, secret, toleranceSec = 300) { const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? ''); if (!m) return false; const [, t, v1] = m; if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSec) return false; const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex'); return timingSafeEqual(Buffer.from(expected), Buffer.from(v1)); } ``` Python: ```python import hmac, hashlib, re, time def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool: m = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", header or "") if not m: return False t, v1 = m.groups() if abs(time.time() - int(t)) > tolerance: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, v1) ``` ## Retries and switching off - Respond with any **2xx within 10 seconds**. - Anything else, or a timeout, is retried **7 more times** with growing gaps: after 30 s, then 1, 2, 4, 8, 16 and 32 minutes (about an hour in all). Each attempt is signed fresh, so `t` is always current. - Delivery order isn’t guaranteed. - After **20 deliveries in a row** fail every retry, the hook is switched off and you get an email. Turn it back on with `PATCH /webhooks/{id}` and `{"active": true}`; that also resets the failure count. See the last 50 deliveries with `GET /webhooks/{id}/deliveries`, and send one again with `POST /webhooks/{id}/deliveries/{delivery_id}/redeliver` (same `event_id`). > [!WARNING] > Return 2xx quickly and do slow work afterwards. A handler that takes longer than 10 seconds counts as a failure, even if it eventually succeeds. --- Previous: [REST API reference](https://dropline.cleforyx.com/docs/developers/api.md) · Next: [MCP server](https://dropline.cleforyx.com/docs/developers/mcp.md)