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

# Webhooks

> Receive lead, message and call events at your URL.

When something happens on an agent, NewLead sends a signed `POST` request to the URLs you register. Text agents send [lead and message events](https://docs.newlead.ai/webhook-events.md) and voice agents send [call events](https://docs.newlead.ai/webhook-events.md).

## Set up an endpoint

**1. Create the endpoint**

An endpoint belongs to one agent: send `text_agent_id` or `voice_agent_id`, and the events it listens for.

```bash theme={null}
curl -X POST https://rest.newlead.ai/v1/webhook_endpoints \
  -H "Authorization: Bearer $NEWLEAD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: crm-endpoint-001" \
  -d '{
    "text_agent_id": "<TEXT_AGENT_ID>",
    "url": "https://crm.example.com/webhooks/newlead",
    "events": ["lead.created", "lead.qualified"]
  }'
```

```json theme={null}
{
  "object": "webhook_endpoint",
  "id": "00000000-0000-4000-8000-00000000000c",
  "url": "https://crm.example.com/webhooks/newlead",
  "events": ["lead.created", "lead.qualified"],
  "text_agent_id": "00000000-0000-4000-8000-000000000004",
  "voice_agent_id": null,
  "description": null,
  "active": true,
  "last_success_at": null,
  "last_failure_at": null,
  "consecutive_failures": 0,
  "created_at": "2026-11-13T09:00:00.000Z",
  "secret": "whsec_0000000000000000000000000000000000000000000000000000000000000000"
}
```

> [!WARNING]
>
> Store `secret` now. The API returns it only in this response, and you need it to verify every delivery.

**2. Verify the signature**

Check each delivery with the secret before you trust it. See [Verify webhook signatures](https://docs.newlead.ai/webhook-signatures.md).

**3. Send a test event**

```bash theme={null}
curl -X POST https://rest.newlead.ai/v1/webhook_endpoints/<WEBHOOK_ENDPOINT_ID>/test \
  -H "Authorization: Bearer $NEWLEAD_API_KEY"
```

The API returns `202` with the queued delivery. The event carries fictional data and is signed like a real one.

```json theme={null}
{
  "object": "webhook_delivery",
  "id": "00000000-0000-4000-8000-00000000000d",
  "webhook_endpoint_id": "00000000-0000-4000-8000-00000000000c",
  "event": "lead.created",
  "status": "pending",
  "attempts": 0,
  "response_status": null,
  "failure_reason": null,
  "created_at": "2026-11-13T09:05:00.000Z",
  "delivered_at": null
}
```

You can also manage endpoints in the agent's **Webhooks** panel in the dashboard.

### Endpoint rules

* URLs must use `https` and cannot point to a private address.
* Each agent can have up to 3 active endpoints. Another one returns `409 webhook_endpoint_limit_reached`, also when you reactivate a paused endpoint. Pause or delete one first.
* Endpoints that an agency creates on an agent count toward those 3, even if your subaccount key cannot see them.

### Manage endpoints

| Method | Path | Description |
| - | - | - |
| `GET` | `/v1/webhook_endpoints` | List endpoints |
| `POST` | `/v1/webhook_endpoints` | Create an endpoint |
| `GET` | `/v1/webhook_endpoints/{webhook_endpoint_id}` | Retrieve an endpoint |
| `PATCH` | `/v1/webhook_endpoints/{webhook_endpoint_id}` | Change `url`, `events`, `description` or `active` |
| `DELETE` | `/v1/webhook_endpoints/{webhook_endpoint_id}` | Delete an endpoint |
| `POST` | `/v1/webhook_endpoints/{webhook_endpoint_id}/test` | Send a test event |
| `GET` | `/v1/webhook_endpoints/{webhook_endpoint_id}/deliveries` | List deliveries from the last 30 days |

## What your endpoint must do

* Respond with a `2xx` status within 10 seconds. Do slow work after you respond.
* Respond directly. Redirects are not followed and count as failures.
* [Verify the signature](https://docs.newlead.ai/webhook-signatures.md) of each delivery.
* Deduplicate on the `X-Webhook-Delivery` header. Its value is the same on every retry of a delivery.
* Do not rely on arrival order. Sort by `occurred_at`, which every event carries.
* Ignore keys you do not recognize. New keys can appear at any time.

## Delivery and retries

A delivery that does not get a `2xx` response within 10 seconds is retried, including after a `4xx` response. It gets 13 attempts in total over about 34 hours, with exponential waits starting at 30 seconds:

| Attempt | Wait before the attempt |
| - | - |
| 1 | None |
| 2 to 8 | 30 seconds, then 1, 2, 4, 8, 16 and 32 minutes |
| 9 to 13 | About 1, 2, 4, 8.5 and 17 hours |

After the last attempt, the delivery is marked `failed`.

After 20 failed deliveries in a row, the endpoint pauses itself and `active` becomes `false`. A successful delivery resets that count, and so does reactivating the endpoint with `PATCH` and `active: true`. Test deliveries do not count, and a test delivery is sent once: it is not retried.

> [!WARNING]
>
> A paused endpoint receives nothing, and the events it misses are not sent when you reactivate it. A retry that comes due while the endpoint is paused is canceled. If you reactivate the endpoint first, pending retries are still sent.

## Debug deliveries

`GET /v1/webhook_endpoints/{webhook_endpoint_id}/deliveries` lists each delivery for 30 days, newest first, with its `status`, `attempts`, `response_status` and `failure_reason`. It does not include the body sent or your server's response.

| `failure_reason` | Meaning |
| - | - |
| `http_error` | Your server responded outside `2xx`. See `response_status`. |
| `redirect_not_followed` | Your server responded with a redirect. |
| `timeout` | No response within 10 seconds. |
| `connection_failed` | The connection failed because of DNS, TLS or a private address. |
| `not_attempted` | The endpoint was paused or deleted before the delivery was sent or retried. |

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| The signature does not match | The body was parsed before verification, or the secret belongs to another endpoint | Verify the raw body with the secret of this endpoint |
| `failure_reason` is `timeout` | Your server takes more than 10 seconds | Respond first and process the event afterward |
| `failure_reason` is `redirect_not_followed` | The URL redirects | Register the final URL |
| The same event arrives twice | A retry reached your server after a timeout | Deduplicate on `X-Webhook-Delivery` |
| `active` is `false` | 20 failed deliveries in a row, or someone paused the endpoint | Fix the cause and send `PATCH` with `active: true` |
| The test returns `409 webhook_endpoint_disabled` | The endpoint is paused | Reactivate it first |
| You lost the secret | The API shows it only once | Delete the endpoint and create a new one |


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