# Pre-call webhook: look up the caller before the agent answers

> Have Ladoo ask your server about each call as it rings, then give the agent the caller's name, account details and a note, or block or transfer the call before it's answered.

Source: https://tryladoo.com/docs/developers/pre-call-webhook · Updated 2026-11-21

A pre-call webhook is an https address of yours that Ladoo calls when a call rings, before the agent says a word. Your server looks the caller up in your own system and answers with what the agent should know: their name, details like their plan or account status, and a short note. It can also ask Ladoo to block the call or put it through to a number.

Each agent has its own pre-call webhook. If your server is slow, fails or sends back something Ladoo can't read, the call goes on as if there were no webhook.

## What Ladoo sends

A JSON `POST`, signed like [webhook events](https://tryladoo.com/docs/developers/webhook-events#check-the-signature):

```json
{
  "call_id": "8c2f6a1e-4b3d-4e5f-9a8b-7c6d5e4f3a2b",
  "agent_id": "3e1d2c4b-5a6f-4b7c-8d9e-0f1a2b3c4d5e",
  "kind": "live",
  "from": "+15125550199",
  "to": "+15125550100",
  "person": {
    "id": "6a5b4c3d-2e1f-4a0b-9c8d-7e6f5a4b3c2d",
    "name": "Sam Demo",
    "email": "sam@example.com"
  }
}
```

- `call_id` is the id the call will have in Ladoo: `GET /v1/calls/{call_id}` and the `call.*` webhook events use it.
- `kind` is `live` for a phone call and `test` for a test call from the dashboard.
- `from` is the caller in E.164, or null when caller ID is withheld. `to` is the Ladoo number they called (null on a test).
- `person` is the caller when they're already in your People, else null.

The request has the `Ladoo-Signature` header (`t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">`) and `Ladoo-Call-Id`. Check the signature with the agent's pre-call signing secret before you trust the request.

## What to answer

Answer `200` with JSON, within **1 second**. Every field is optional, and `{}` changes nothing:

```json
{
  "variables": { "plan": "gold", "open_tickets": 2, "vip": true },
  "caller": { "name": "Sam Demo" },
  "note_for_agent": "Sam's last service visit was on Nov 3. Their warranty runs to March.",
  "route": "default"
}
```

- `variables`: up to 30 values (text up to 500 characters, numbers or true/false) your workflow can use like the business's own settings: `{{plan}}` in prompts and greetings, and in conditions. Names start with a letter and use letters, digits and `_`. A name the agent already has, like `business_name`, keeps the agent's value.
- `caller`: `name` and `first_name`. The agent gets `{{caller_name}}` and `{{caller_first_name}}`, and opens with its greeting for returning callers.
- `note_for_agent`: up to 1,000 characters. The agent reads it as information about the caller. It can't change the agent's rules or its AI notice.
- `route`:
  - `default` (or left out): the agent answers as usual.
  - `block`: Ladoo ends the call without answering. The call shows in Calls as blocked, with "Blocked by the agent's pre-call webhook". It isn't billed.
  - `transfer:+15125550123`: Ladoo puts the call through to that number without the agent answering, and the call shows as transferred. If the number doesn't pick up, the call ends and isn't billed. The number must be one a workflow's transfer step could dial: in the US or Canada, not premium, and not a Ladoo number, the number called or the caller.

  `block` and `transfer:` apply only to phone calls. A test call always reaches the agent.

A reply that isn't JSON, is larger than 16 KB, or breaks one of the rules above is ignored as a whole, and so is any answer other than a 2xx. Ladoo doesn't retry a pre-call webhook and doesn't follow redirects.

## Keep it fast

The caller is waiting while Ladoo waits for you. Look the caller up by phone number in an index or cache, and answer as soon as you have what you need. Do slower work, like writing to another system, after you've answered, or from the [`call.started`](https://tryladoo.com/docs/developers/webhook-events#call-events) event.

## Set it up

```bash
curl -X PUT https://api.tryladoo.com/v1/agents/$AGENT_ID/pre-call-webhook \
  -H "Authorization: Bearer $LADOO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://hooks.example.com/ladoo/ring"}'
```

The address must be https on port 443, on a public host. The first time you set one, the response has the signing secret, `whsec_…`. It's shown only then, so store it. Changing the address keeps the secret.

- `POST /v1/agents/{id}/pre-call-webhook/rotate-secret` makes a new secret and returns it once. The old one stops working at once.
- `PUT` with `{"url": null}` turns the webhook off and deletes its secret.
- `GET /v1/agents/{id}` shows the address under `pre_call_webhook`, never the secret.

Both need an API key with the `agents:write` and `webhooks:write` scopes, so only admins can change it, as for webhook endpoints: it sends callers' details out.
