> ## Documentation Index
> Fetch the complete documentation index at: https://octanist.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Get lead events from Octanist as they happen: new leads, status changes and updates, signed with HMAC-SHA256 and retried for up to two days.

Webhooks send lead events to your own systems as they happen, so a CRM or another integration stays in sync without polling `GET /api/leads`.

Octanist sends a signed `POST` request to your URL for each event your endpoint subscribes to. Add endpoints in **Settings → API / MCP → Webhooks**, or with the [webhook endpoints API](https://octanist.com/docs/api-reference/endpoint/create-webhook.md).

## Events

| Event | Sent when |
| - | - |
| `lead.created` | A new lead comes in from any source: the pixel, forms, calls, the API, a CSV import, a connector or the app. |
| `lead.status_changed` | The lead's status changes between `open`, `qualified`, `won` and `lost`, including a reopen to `open`. |
| `lead.updated` | Name, email, phone, external ID, custom data, value, label, lost reason or won conversion changes, without a status change. |

One change sends one event. When a single update changes the status and the value together, you get one `lead.status_changed` event, and its `changes` list both. Subscribe to both `lead.status_changed` and `lead.updated` to hear about every change.

Changes that do not change anything (an update with the same email, say) send no event. Notes added to a lead, in the app or with `note` on an update, are activity entries and send no event either.

## Payload

Every event has the same shape:

```json theme={null}
{
  "id": "evt_4f1c2b9e7d6a4c3b8e2f1a0d9c8b7a6e",
  "type": "lead.status_changed",
  "createdAt": "2026-11-30T10:00:00.000Z",
  "organizationId": "org_abc123",
  "source": {
    "type": "api",
    "apiKeyId": "6f0c3a52-0c4e-4f63-9d8e-3f3b2a1c9e10"
  },
  "data": {
    "lead": {
      "id": "lead_abc123",
      "externalId": "CRM-1042",
      "name": "Jane Doe",
      "email": "jane@example.com",
      "status": "won",
      "value": 1200,
      "...": "the same fields as GET /api/leads/{id}"
    },
    "changes": {
      "status": { "from": "qualified", "to": "won" },
      "value": { "from": null, "to": 1200 }
    }
  }
}
```

| Field | Description |
| - | - |
| `id` | Unique event ID. Use it to ignore an event you already handled: a retry sends the same ID. |
| `type` | The event type. |
| `createdAt` | When the change happened. |
| `source.type` | Where the change came from: `app` (a user in Octanist), `api` (the REST API, MCP and Zapier), `manual` (a lead added in the app), `import` (CSV import), `bulk_update` (CSV update), a lead source such as `pixel`, `gtm`, `wordpress`, `meta` or `call`, or a CRM integration such as `zoho`, `odoo` or `pipedrive`. |
| `source.apiKeyId` | The API key that made the change, for changes through the API or MCP with an API key. |
| `source.userId` | The Octanist user, for changes made in the app. |
| `data.lead` | The lead after the change, in the same shape as [Get Lead](https://octanist.com/docs/api-reference/endpoint/get-lead.md). |
| `data.changes` | For `lead.status_changed` and `lead.updated`: each changed field with its old and new value. `status` uses `open`, `qualified`, `won` and `lost`. |

> [!TIP]
>
> **Avoid sync loops.** When your CRM updates a lead through the API, Octanist sends that change back as an event. Compare `source.apiKeyId` with the ID of your CRM's own API key and skip those events.

Events can arrive out of order, for example when one is retried. Compare `createdAt` (or `data.lead.updatedAt`) with what you have before you overwrite newer data.

## Verify the signature

Each request carries three headers, following the [Standard Webhooks](https://www.standardwebhooks.com) spec:

| Header | Example |
| - | - |
| `webhook-id` | `evt_4f1c2b9e7d6a4c3b8e2f1a0d9c8b7a6e` |
| `webhook-timestamp` | `1764496800` (Unix seconds) |
| `webhook-signature` | `v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=` |

The signature is the Base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed with the Base64-decoded part of your signing secret after `whsec_`. Check it on the raw request body, before you parse the JSON, and reject requests whose timestamp is more than five minutes old.

The open-source Standard Webhooks libraries do this for you (`npm install standardwebhooks`, `pip install standardwebhooks`, and others):

```javascript Node.js (library) theme={null}
import { Webhook } from 'standardwebhooks';

const wh = new Webhook(process.env.OCTANIST_WEBHOOK_SECRET); // whsec_...

app.post('/webhooks/octanist', express.raw({ type: 'application/json' }), (req, res) => {
  let event;
  try {
    event = wh.verify(req.body.toString(), req.headers);
  } catch {
    return res.status(400).send('Invalid signature');
  }
  // event.type, event.data.lead, event.data.changes
  res.sendStatus(200);
});
```

```javascript Node.js (no library) theme={null}
import { createHmac, timingSafeEqual } from 'node:crypto';

function verifyOctanistWebhook(rawBody, headers, secret) {
  const id = headers['webhook-id'];
  const timestamp = headers['webhook-timestamp'];
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;

  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = createHmac('sha256', key)
    .update(`${id}.${timestamp}.${rawBody}`)
    .digest('base64');

  return headers['webhook-signature']
    .split(' ')
    .some((signature) => {
      const [version, value] = signature.split(',');
      return (
        version === 'v1' &&
        value.length === expected.length &&
        timingSafeEqual(Buffer.from(value), Buffer.from(expected))
      );
    });
}
```

```python Python theme={null}
import base64, hashlib, hmac, time

def verify_octanist_webhook(raw_body: bytes, headers, secret: str) -> bool:
    msg_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > 300:
        return False

    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{msg_id}.{timestamp}.".encode() + raw_body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()

    return any(
        hmac.compare_digest(value, expected)
        for version, _, value in (s.partition(",") for s in headers["webhook-signature"].split(" "))
        if version == "v1"
    )
```

The signing secret is shown once when you add the endpoint. Admins can show it again, or roll it, from the endpoint's menu in Settings. Rolling makes the old secret stop working at once.

## Responding and retries

Answer with any `2xx` status within 10 seconds. Do the slow work after you respond, for example in a queue. Octanist reads at most the first 1 KB of your response body and shows it in the delivery log.

Octanist retries an event when your endpoint answers with another status, does not answer in time, or cannot be reached. Retries follow after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours: 8 attempts over about two days. After that the delivery is marked as failed. You can send it again from the delivery log.

Some answers are handled differently:

* **`410 Gone`** turns the endpoint off. Use it when an integration (such as a Zapier REST hook) no longer wants events. Turn it back on in Settings or with `PATCH /api/webhooks/{id}` and `"enabled": true`.
* **Redirects (`3xx`)** are not followed and count as a failure. Use the final URL.

## Requirements for the URL

* It must use `https://`.
* It must point to a public server: hosts that are or resolve to private, loopback or link-local addresses (such as `localhost`, `10.0.0.0/8` or `192.168.0.0/16`) are refused.
* An organization can have up to 10 endpoints.

## Delivery log and testing

Every endpoint has a delivery log in **Settings → API / MCP → Webhooks → Deliveries**: each event with its status, the HTTP response, the number of attempts and the exact body that was sent. Deliveries are kept for 30 days. The same log is available through [List Webhook Deliveries](https://octanist.com/docs/api-reference/endpoint/webhook-deliveries.md).

**Send ping** in the endpoint's menu, or [Ping Webhook Endpoint](https://octanist.com/docs/api-reference/endpoint/ping-webhook.md), sends a `webhook.ping` event right away, so you can check your URL and signature check before real events arrive. Pings are not retried.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.