# Events & webhooks

> Receive quote.ready, policy.bound and policy.status_changed as HMAC-signed HTTP webhooks or over an MCP event stream.

Kinro tells your server when quotes are ready for a partner session, a policy binds, or a policy is cancelled. Both partner paths use these events: embedded partners to update their product, brokers to update their own client records. Webhook deliveries include the `lead_id`. When exactly one of your external customer records matches the lead, the webhook also includes its `external_id`.

To receive webhooks, give your Kinro contact an HTTPS endpoint for each environment (`test` and `live`). Kinro sends you a `whsec_*` signing secret for each.

You can consume events in two ways:

1. **Signed HTTP webhooks** pushed to your backend (`quote.ready`, `policy.bound`, `policy.status_changed`).
2. **Real-time MCP SSE streams** over `GET https://api.kinro.com/mcp`.

Both mechanisms isolate sandbox events from live events. Webhooks use a bounded series of delivery attempts after each persisted event. Use the SSE replay cursor to recover from a disconnected stream.

## Supported webhook events

| Event type | When it fires | Key fields |
| --- | --- | --- |
| `quote.ready` | One or more carrier quotes are ready for a partner session | `lead_id`, `quotes` with `quote_id`, `carrier`, premium in cents and `checkout_url`. The sandbox sample describes a single quote. |
| `policy.bound` | A policy bind is confirmed | `lead_id`, `policy_id`, `policy_number`, `status`, `carrier`, `line_of_business`, `effective_date`, `expiration_date` |
| `policy.status_changed` | A live policy is cancelled, or a sandbox policy changes status | `lead_id`, `policy_id`, `policy_number`, `previous_status`, `status`, `carrier`, `cancellation_effective_date` when available |

### Example webhook payloads

Every webhook POST body shares this top-level envelope:

```json
{
  "id": "evt_m8k2p9_a1b2c3d4e5f6",
  "type": "policy.bound",
  "created_at": "2026-11-29T18:42:10.000Z",
  "data": {
    "lead_id": "b9011f24-6a12-4c72-9b88-100000060331",
    "external_id": "acct_12345",
    "environment": "live",
    "policy_id": "88e1d930-4f10-4a8e-b711-000000000042",
    "policy_number": "GL-2026-908412",
    "status": "active",
    "carrier": "Carrier Name",
    "line_of_business": "general_liability",
    "effective_date": "2026-12-01",
    "expiration_date": "2027-12-01"
  }
}
```

Example `policy.status_changed` payload:

```json
{
  "id": "evt_m8k9z1_9876543210ab",
  "type": "policy.status_changed",
  "created_at": "2026-12-15T14:05:00.000Z",
  "data": {
    "lead_id": "b9011f24-6a12-4c72-9b88-100000060331",
    "external_id": "acct_12345",
    "environment": "live",
    "policy_id": "88e1d930-4f10-4a8e-b711-000000000042",
    "policy_number": "GL-2026-908412",
    "previous_status": "active",
    "status": "cancelled",
    "cancellation_effective_date": "2026-12-31"
  }
}
```

## Verifying webhook signatures

Each webhook endpoint is configured with a `whsec_*` signing secret and sends these headers:

- `X-Kinro-Event` — event type (e.g. `policy.bound`)
- `X-Kinro-Delivery` — unique delivery ID
- `X-Kinro-Signature` — `t=<unix_timestamp>,v1=<hmac_sha256_hex>`

Compute the HMAC-SHA256 digest of `${timestamp}.${rawBody}` using your `whsec_*` secret and compare in constant time:

```js
import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyKinroWebhook(rawBody, signatureHeader, secret) {
  if (typeof signatureHeader !== "string") return false;
  const match = /^t=(\d+),v1=([a-f0-9]{64})$/.exec(signatureHeader);
  if (!match) return false;
  const [, timestamp, signature] = match;

  const ageSeconds = Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp));
  if (!Number.isSafeInteger(ageSeconds) || ageSeconds > 300) return false;

  const expected = createHmac("sha256", secret)
    .update(`${timestamp}.`)
    .update(rawBody)
    .digest();
  return timingSafeEqual(Buffer.from(signature, "hex"), expected);
}
```

Return any `2xx` HTTP status within 10 seconds to acknowledge receipt. Timeouts, connection failures, `408`, `429` and server errors are retried with a delay between attempts. Handle deliveries idempotently using the top-level `id` (`evt_...`). Use a public HTTPS hostname on the default port and serve the endpoint directly.

## Real-time MCP SSE stream

If you prefer a streaming connection instead of (or alongside) HTTP webhooks, open an authenticated SSE stream on `GET https://api.kinro.com/mcp`:

```bash
curl -N https://api.kinro.com/mcp \
  -H "Authorization: Bearer $KINRO_PARTNER_TOKEN" \
  -H "Accept: text/event-stream"
```

- Filter to a single lead or session with `?lead_id=<uuid>` or `?session_id=<uuid>`, or omit both to stream events for your environment. Use a lead filter or the unfiltered stream for live policy events.
- On reconnect, pass your last received event ID in `Last-Event-ID` to replay missed events.
- If a stream connection returns `429`, honor `Retry-After` or fall back to `get_kinro_messages` with `wait: true`.

---

Source: https://kinro.com/docs/events-webhooks. All Kinro docs: https://kinro.com/docs/llms.txt
