> ## 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.

# Webhook events

> Every event NewLead sends, with its payload.

Each delivery is a JSON `POST`. The `event` key holds the event name, which also travels in the `X-Webhook-Event` header, and `occurred_at` holds the time of the event.

NewLead ignores the body of your response. Payloads can include keys that are not listed here: ignore the ones you do not recognize.

Events never fire for test leads or for test calls made from the dashboard.

## Event types

| Event | Agent | When it fires |
| - | - | - |
| [`call.started`](#call-started) | Voice | A call starts. |
| [`call.rejected`](#call-rejected) | Voice | A call is rejected before anyone handles it. |
| [`call.ended`](#call-ended) | Voice | A call ends. |
| [`call.analyzed`](#call-analyzed) | Voice | The variables extracted from a call are ready. |
| [`lead.created`](#lead-created) | Text | A new lead arrives. |
| [`lead.qualified`](#lead-qualified) | Text | A lead completes the qualification. |
| [`lead.appointment_booked`](#lead-appointment_booked) | Text | The agent books an appointment. |
| [`lead.handoff`](#lead-handoff) | Text | The agent notifies the team. |
| [`follow_up.sent`](#follow_up-sent) | Text | A follow-up message goes out. |
| [`message.received`](#message-received) | Text | A lead sends a message. |
| [`message.failed`](#message-failed) | Text | A message to a lead fails. |

## `call.started`

```json theme={null}
{
  "event": "call.started",
  "call_id": "00000000-0000-4000-8000-000000000001",
  "voice_agent_id": "00000000-0000-4000-8000-000000000002",
  "voice_agent_name": "Maria",
  "direction": "inbound",
  "from": "+34600111222",
  "to": "+34910000000",
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "started_at": "2026-11-13T09:00:00.000Z",
  "occurred_at": "2026-11-13T09:00:00.000Z"
}
```

`direction` is `inbound`, `outbound` or `web`.

## `call.rejected`

```json theme={null}
{
  "event": "call.rejected",
  "call_id": "00000000-0000-4000-8000-000000000005",
  "voice_agent_id": "00000000-0000-4000-8000-000000000002",
  "direction": "inbound",
  "from": "+34600111222",
  "to": "+34910000000",
  "status": "rejected",
  "end_reason": "rejected_balance",
  "rejected_at": "2026-11-13T10:15:00.000Z",
  "occurred_at": "2026-11-13T10:15:00.000Z"
}
```

`end_reason` says why, for example `rejected_balance` or `rejected_plan`. The list can grow.

## `call.ended`

```json expandable theme={null}
{
  "event": "call.ended",
  "call_id": "00000000-0000-4000-8000-000000000001",
  "voice_agent_id": "00000000-0000-4000-8000-000000000002",
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "text_agent_id": "00000000-0000-4000-8000-000000000004",
  "direction": "inbound",
  "from": "+34600111222",
  "to": "+34910000000",
  "status": "completed",
  "end_reason": "caller_hangup",
  "started_at": "2026-11-13T09:00:00.000Z",
  "ended_at": "2026-11-13T09:03:20.000Z",
  "duration_sec": 200,
  "occurred_at": "2026-11-13T09:03:20.000Z",
  "cost": {
    "usage": {
      "duration_sec": 200,
      "stt_minutes": 3.33,
      "tts_characters": 1840,
      "llm_tokens_input": 4210,
      "llm_tokens_output": 620,
      "llm_tokens_cached": 1024
    }
  },
  "recording_available": true,
  "recording_url": "https://rest.newlead.ai/v1/calls/00000000-0000-4000-8000-000000000001/recording",
  "transcript": [
    { "start_ms": 0, "end_ms": 1800, "role": "agent", "text": "Hi, this is Maria." },
    { "start_ms": 1900, "end_ms": 3600, "role": "user", "text": "Hi, I am calling about the apartment." }
  ]
}
```

**text\_agent\_id** `string | null`

The text agent of the call's lead. `null` if the call has no lead or the lead belongs to a voice agent with no text agent.

**cost** `object`

What the call consumed, in units. It never carries amounts.

**properties**

**usage.duration\_sec** `integer | null`

Call length in seconds.

**usage.stt\_minutes** `number | null`

Minutes of speech transcribed.

**usage.tts\_characters** `integer | null`

Characters of speech generated.

**usage.llm\_tokens\_input** `integer | null`

Input tokens.

**usage.llm\_tokens\_output** `integer | null`

Output tokens.

**usage.llm\_tokens\_cached** `integer | null`

Cached input tokens.

**recording\_url** `string | null`

`null` when `recording_available` is `false`. Otherwise, request it with a key from the subaccount: `GET /v1/calls/{call_id}/recording` redirects (`302`) to a signed link that is valid for one hour. Send the key in `Authorization: Bearer`, which is not forwarded when your client follows the redirect.

**recording\_available** `boolean`

`false` does not guarantee that the call has no recording. The recording can arrive just after this event, which is not sent again. To check, use `GET /v1/calls/{call_id}`.

**transcript** `array`

What was said, in order. `role` is `agent` or `user`. `GET /v1/calls/{call_id}` calls the same speaker `lead`.

## `call.analyzed`

```json theme={null}
{
  "event": "call.analyzed",
  "call_id": "00000000-0000-4000-8000-000000000001",
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "text_agent_id": "00000000-0000-4000-8000-000000000004",
  "analyzed_at": "2026-11-13T09:04:10.000Z",
  "occurred_at": "2026-11-13T09:04:10.000Z",
  "variables": {
    "budget": { "value": "300000", "confidence": 0.92 }
  }
}
```

`variables` holds every extracted variable with its `confidence`, from 0 to 1. `lead_id` is `null` if the call has no lead, and `text_agent_id` follows the same rule as in `call.ended`.

This event is not sent if the agent declares no variables, if the call has no transcript or if the analysis fails. To know that a call finished, use `call.ended`.

## `lead.created`

Fires once per lead, on any channel: WhatsApp, Instagram, web chat, a call, a Lead Ads form, an email, the API or a template sent to a new phone. It also fires when a conversation closes and the same person starts another one, with a new lead and the same `contact_id`.

```json expandable theme={null}
{
  "event": "lead.created",
  "occurred_at": "2026-11-13T09:00:01.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  }
}
```

## `lead.qualified`

Fires when the lead answers the last required question and that answer does not disqualify them. It fires again only if the team reopens the qualification and the lead completes it again.

```json expandable theme={null}
{
  "event": "lead.qualified",
  "occurred_at": "2026-11-13T09:12:40.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": {
      "status": "completed",
      "completed_at": "2026-11-13T09:12:40.000Z",
      "answers": [
        { "question_id": "q1", "question": "Is your mortgage approved?", "value": true, "value_label": null },
        { "question_id": "q2", "question": "What are you looking for?", "value": "buy", "value_label": "Buy" }
      ]
    }
  }
}
```

## `lead.appointment_booked`

Fires once per appointment the agent books, in a chat or a call.

```json expandable theme={null}
{
  "event": "lead.appointment_booked",
  "occurred_at": "2026-11-13T09:20:05.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  },
  "appointment": {
    "event_id": "7k2f9q0d1s",
    "title": "Viewing with Ana Ferrer",
    "starts_at": "2026-11-15T10:00:00.000Z",
    "ends_at": "2026-11-15T10:30:00.000Z",
    "timezone": "Europe/Madrid",
    "location": "1 Main Street, Madrid",
    "meet_link": null
  }
}
```

`appointment.event_id` is the ID of the calendar event. `timezone` is the IANA time zone of the agent. `location` and `meet_link` can be `null`.

## `lead.handoff`

Fires once per notice the agent sends to the team.

```json expandable theme={null}
{
  "event": "lead.handoff",
  "occurred_at": "2026-11-13T09:25:00.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  },
  "handoff": {
    "notification_id": "00000000-0000-4000-8000-000000000008",
    "reason": "human_requested",
    "message": "The lead wants to talk to a person about financing.",
    "requires_human": true
  }
}
```

| `handoff.reason` | `requires_human` |
| - | - |
| `human_requested`, `angry`, `distrust`, `no_info`, `cancel_change`, `out_of_scope`, `qualification_declined`, `other` | `true` |
| `appointment`, `qualified`, `disqualified` | `false` |

## `follow_up.sent`

Fires when a follow-up message goes out to the lead.

```json expandable theme={null}
{
  "event": "follow_up.sent",
  "occurred_at": "2026-11-14T10:00:00.000Z",
  "text_agent_id": "00000000-0000-4000-8000-000000000004",
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "phone_number": "34600111222",
  "follow_up_number": 1,
  "execution_id": "00000000-0000-4000-8000-000000000009",
  "message": "Hi Ana, did you get a chance to look at the apartment?",
  "status": "sent",
  "timestamp": "2026-11-14T10:00:00.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  }
}
```

`phone_number` has no leading `+`. `lead.phone` does.

## `message.received`

Fires once per message a lead sends to the agent, on WhatsApp, Instagram or the web chat. A message with an attachment fires once the attachment has been processed, usually a few seconds later, so `message.attachments` lists it. If the attachment can't be processed, the event still fires without it: `attachments` is empty, and `text` is `null` when there was no caption.

```json expandable theme={null}
{
  "event": "message.received",
  "occurred_at": "2026-11-13T09:30:02.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  },
  "message": {
    "object": "message",
    "id": "00000000-0000-4000-8000-00000000000e",
    "lead_id": "00000000-0000-4000-8000-000000000003",
    "direction": "inbound",
    "sender": "lead",
    "origin": "lead",
    "type": "text",
    "text": "Is the apartment still available?",
    "template": null,
    "attachments": [],
    "reply_to_message_id": null,
    "status": "received",
    "error": null,
    "created_at": "2026-11-13T09:30:01.000Z",
    "sent_at": null,
    "delivered_at": null,
    "read_at": null,
    "failed_at": null
  }
}
```

## `message.failed`

Fires when a message to the lead fails and NewLead will not retry it on its own: WhatsApp or Instagram refused it, WhatsApp reported it as failed later, or it could not be sent at all, for example because the 24-hour window closed and the agent has no approved template for it. The agent's automatic first message is retried a few times and fires only after the last attempt.

It fires once per failure. If someone retries the message from the dashboard and it fails again, you receive another `message.failed` with the same `message.id`. Messages canceled before they are sent, such as a scheduled follow-up after the lead replies, do not fire it.

After a temporary error, the agent may send the same reply or follow-up again as a new message, with another `message.id`. You can then receive `message.failed` for the first attempt even though the lead got the second one.

```json expandable theme={null}
{
  "event": "message.failed",
  "occurred_at": "2026-11-13T09:31:02.000Z",
  "lead": {
    "id": "00000000-0000-4000-8000-000000000003",
    "contact_id": "00000000-0000-4000-8000-000000000006",
    "text_agent_id": "00000000-0000-4000-8000-000000000004",
    "text_agent_name": "Maria",
    "subaccount_id": "00000000-0000-4000-8000-000000000007",
    "name": "Ana Ferrer",
    "phone": "+34600111222",
    "email": "ana@example.com",
    "username": null,
    "channel": "meta_ads",
    "source": {
      "type": "meta_lead_form",
      "lead_ad": { "form_id": "1234567890", "ad_id": "2345678901", "leadgen_id": "3456789012" }
    },
    "created_at": "2026-11-13T09:00:00.000Z",
    "variables": { "email": "ana@example.com", "budget": "300000" },
    "qualification": { "status": "not_started", "completed_at": null, "answers": [] }
  },
  "message": {
    "object": "message",
    "id": "00000000-0000-4000-8000-00000000000f",
    "lead_id": "00000000-0000-4000-8000-000000000003",
    "direction": "outbound",
    "sender": "agent",
    "origin": "ai",
    "type": "text",
    "text": "Hi Ana, would Thursday at 10:00 work for a viewing?",
    "template": null,
    "attachments": [],
    "reply_to_message_id": null,
    "status": "failed",
    "error": { "code": 131026, "category": "recipient_not_reachable" },
    "created_at": "2026-11-13T09:31:00.000Z",
    "sent_at": null,
    "delivered_at": null,
    "read_at": null,
    "failed_at": "2026-11-13T09:31:02.000Z"
  }
}
```

`message.error.code` is the error code WhatsApp or Instagram returned, and `category` groups it, for example `recipient_not_reachable` or `template_paused`. The list can grow. Both are `null` when there is no provider error code, for example when the message could not be sent at all.

## The `message` object

`message.received` and `message.failed` carry the message as [`GET /v1/messages/{message_id}`](https://docs.newlead.ai/api-reference/messages/retrieve-a-message) returns it, read when the event fires. Attachments come without a download URL. A voice note or an audio carries `transcription`, the text of what the lead said; it is `null` for other attachments or when it could not be transcribed.

## The `lead` object

Every `lead.*`, `message.*` and `follow_up.sent` event carries the same `lead` object, read when the event fires. You can create or update a contact from any of them.

**id** `string`

The lead ID.

**contact\_id** `string`

The person. All the leads of one person across the channels and agents of a subaccount share it.

**text\_agent\_id** `string | null`

The text agent. `null` if the lead belongs to a voice agent with no text agent.

**text\_agent\_name** `string | null`

The name of the text agent, with the same rule.

**subaccount\_id** `string | null`

The subaccount of the agent.

**name** `string | null`

The name of the lead.

**phone** `string | null`

The phone number in E.164, with a leading `+`.

**email** `string | null`

The email address found in the lead's variables.

**username** `string | null`

The Instagram username, or a WhatsApp username when there is no phone.

**channel** `string`

`whatsapp`, `instagram`, `webchat`, `email`, `meta_ads` or `voice`.

**source** `object`

Where the lead came from.

**properties**

**type** `string | null`

`gmail`, `outlook`, `whatsapp`, `instagram`, `webchat`, `manual` or `meta_lead_form`. `null` for leads created by the API, a template or a call.

**lead\_ad** `object | null`

`form_id`, `ad_id` and `leadgen_id`. Present only when `type` is `meta_lead_form`.

**created\_at** `string`

When the lead was created.

**variables** `object`

Form fields, values extracted by the agent and values written through the API.

**qualification** `object`

The state of the qualification.

**properties**

**status** `string`

`not_started`, `in_progress`, `completed`, `disqualified` or `skipped`.

**completed\_at** `string | null`

When the qualification was completed.

**answers** `array`

The questions that apply to the lead and have an answer, in dashboard order. `value` is `null` if the lead declined to answer, and `value_label` is the label of the chosen option.

## Event times

Use `occurred_at` to order events. To order the messages of a conversation, use `message.created_at`: a message with an attachment fires a few seconds late, after any text the lead sent next. `occurred_at` matches these fields:

| Event | `occurred_at` equals |
| - | - |
| `call.started` | `started_at` |
| `call.rejected` | `rejected_at` |
| `call.ended` | `ended_at`, or `started_at` if `ended_at` is empty |
| `call.analyzed` | `analyzed_at` |
| `follow_up.sent` | `timestamp` |
| `lead.created`, `lead.qualified`, `lead.appointment_booked`, `lead.handoff`, `message.received`, `message.failed` | The moment the event fired |


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