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

# Webhooks for finished calls

> Every finished call posted to your own system as signed JSON: outcome, summary, evaluation, collected data, variables, recording and cost

When a call ends, Lokutor can post it to an address of yours: what came of it, what was collected, how it was evaluated and what it cost. Phone, web and SDK calls of your agents all count, and so do phone calls no agent took (outside opening hours, or past your concurrent calls). It is off until you set an address.

## Set it up

1. In the [dashboard](https://app.lokutor.com), open [**Developers → Webhooks**](https://app.lokutor.com/developers?tab=webhooks) and set the **Address**: `https`, public, without a user and password in it. Every agent's calls go there.
2. An agent can have an address of its own, in its **Analysis → Webhook** (or [`webhook_url`](https://docs.lokutor.com/api-reference/agents) in the API). Its calls go there instead.
3. **Make** a signing secret and copy it: it is shown once. Without it you cannot tell our requests from anybody else's.
4. **Send a test**. It posts a made-up call, with `"test": true`, and shows how your system answered.

Admins and owners set the workspace's address and the secret; members change their agents' addresses, send tests and send deliveries again. The agent's options are `webhook_transcript` (adds what was said) and `webhook_staging` (staging calls are sent too, marked as such).

## When it arrives

Once the call has been saved and [analysed](https://docs.lokutor.com/pricing.md#after-a-call), usually a few seconds after it ends. An agent whose `analysis` is off is not analysed: its call is sent at once, with `null` where the analysis would be.

Nothing is sent for [simulated tests](https://docs.lokutor.com/guides/testing-agents.md), for a web session in which nothing was said, for a dialled call nobody answered, or for a session that is not one of your saved agents.

## What arrives

A `POST` with a JSON body.

```json theme={null}
{
  "event": "conversation.completed",
  "id": "9c2f6a0e-3f0b-4a61-8a36-6c1d3f5f5a10",
  "timestamp": "2026-11-25T10:01:10Z",
  "conversation_id": "5d0e7e1c-9f43-4b1c-8f57-2f0b6d7a9e11",
  "agent_id": "b7a9d6a2-4f0e-4f3c-9a6c-1f7a3f1c2d33",
  "agent_name": "Sofía",
  "environment": "live",
  "channel": "phone",
  "direction": "inbound",
  "caller": "+34600111222",
  "line": "+34910000001",
  "started_at": "2026-11-25T10:00:00Z",
  "ended_at": "2026-11-25T10:01:01Z",
  "duration_ms": 61000,
  "outcome": "completed",
  "summary": "Ana booked a cleaning for Tuesday at 10.",
  "sentiment": 0.6,
  "evaluation": [
    {"rule_id": "0f6b…", "rule_name": "Appointment booked", "passed": true, "reason": "The caller confirmed Tuesday at 10."}
  ],
  "all_criteria_passed": true,
  "collected_data": {"name": "Ana", "email": "ana@example.com"},
  "collected_earlier": ["email"],
  "analysis_off": null,
  "flagged": false,
  "flags": null,
  "variables": {"day": "Tuesday"},
  "transfer": null,
  "forward": null,
  "experiment": {"id": "3b1d…", "variant": "B"},
  "asked_not_to_be_called": null,
  "ai_notice": null,
  "purpose": null,
  "recording": {"available": true, "seconds": 58},
  "cost_usd": 0.0734
}
```

Every key is always there, `null` where there is nothing to say, except `test` and `transcript`. New keys may be added.

| Field | Description |
| :- | :- |
| `event` | `conversation.completed`. |
| `id` | The delivery's. The same on every attempt: use it to ignore one you already have. |
| `timestamp` | When the call was ready to be sent. |
| `test` | `true` on a test; absent otherwise. |
| `conversation_id` | Reads the call with [`GET /v1/conversations/{id}`](https://docs.lokutor.com/api-reference/agents#conversations). |
| `agent_id`, `agent_name` | The agent that took it. |
| `environment` | `live`, or `staging` for a call of the draft. |
| `channel`, `direction` | `phone` or `web`; on the phone, `inbound` or `outbound`. |
| `caller`, `line` | The other party's number and yours, as the carrier gave them. `null` on the web. |
| `started_at`, `ended_at`, `duration_ms` | When it was, and its length. |
| `outcome` | How it ended, in the words the agent gave when it ended the call (`completed`, or `voicemail`, `transferred`), or `forwarded`, `forward_no_answer` (and the like) and `message` for a call no agent took. `null` when the caller hung up. |
| `summary`, `sentiment` | What happened, and the mood from −1 to 1. |
| `evaluation`, `all_criteria_passed` | Each of the agent's rules: met or not, and why. |
| `collected_data`, `collected_earlier` | The agent's data fields, and which of them came from the caller's earlier calls rather than this one. |
| `analysis_off` | The parts of the [analysis](https://docs.lokutor.com/pricing.md#after-a-call) the agent has off (`summary`, `rules`, `data`): those are not coming. |
| `flagged`, `flags` | Why a person should look at it: `[{"source", "reason", "at"}]`. `source` is `agent`, `criteria`, `hangup` or `transfer`. |
| `variables` | What the [workflow](https://docs.lokutor.com/guides/workflows.md) collected on the way. |
| `transfer`, `forward` | The call's [transfer to a person](https://docs.lokutor.com/guides/call-transfer.md), or where a call no agent took was put through. |
| `experiment` | The [A/B test](https://docs.lokutor.com/guides/ab-testing.md) it was part of and the version it heard. |
| `asked_not_to_be_called` | The person [asked not to be called again](https://docs.lokutor.com/guides/outbound-calls.md#who-is-not-called): `{"words", "listed", "at"}`, what they said, whether they went on the list, and when. |
| `ai_notice` | The [AI notice](https://docs.lokutor.com/guides/outbound-calls.md#ai-notice) of a call the agent placed: `{"text", "said"}`, the sentence and whether it was heard. |
| `purpose` | What a call the agent placed was [for](https://docs.lokutor.com/guides/outbound-calls.md#what-a-call-is-for): `service` or `commercial`. |
| `recording` | Whether there is a recording and how long it is. The audio is in **Conversations**. |
| `cost_usd` | What the call costs you, its lines and the analysis included. |
| `transcript` | What was said, when the agent asks for it. |

What is sent is read when it is sent. A conversation you delete before that is not sent.

## Check that it is us

Anyone can post to your address. Each request carries:

| Header | Value |
| :- | :- |
| `Lokutor-Signature` | `v1=<hex>`: HMAC-SHA256 of `<timestamp>.<body>` with your signing secret. For a day after you make a new secret there are two, `v1=<new>,v1=<old>`; accept either. |
| `Lokutor-Timestamp` | The seconds since 1970 at which it was signed. Refuse one that is more than five minutes away. |
| `Lokutor-Delivery` | The `id` in the body. |
| `Lokutor-Event` | The `event` in the body. |

Use the body exactly as it arrived, before any JSON parsing, and the secret whole, with its `whsec_`.

```js Node.js theme={null}
import crypto from "node:crypto";
import express from "express";

const SECRET = process.env.LOKUTOR_WEBHOOK_SECRET; // whsec_…

export function isFromLokutor(body, headers, secret = SECRET, now = Date.now() / 1000) {
  const timestamp = headers["lokutor-timestamp"] ?? "";
  if (!(Math.abs(now - Number(timestamp)) <= 300)) return false;
  const expected = Buffer.from("v1=" + crypto.createHmac("sha256", secret).update(`${timestamp}.`).update(body).digest("hex"));
  return (headers["lokutor-signature"] ?? "").split(",").some(s => {
    const given = Buffer.from(s.trim());
    return given.length === expected.length && crypto.timingSafeEqual(given, expected);
  });
}

const app = express();
app.post("/lokutor", express.raw({ type: "application/json" }), (req, res) => {
  if (!isFromLokutor(req.body, req.headers)) return res.sendStatus(401);
  res.sendStatus(204); // answer first, work after
  const call = JSON.parse(req.body);
  console.log(call.conversation_id, call.outcome, call.summary);
});
app.listen(3000);
```

```python Python theme={null}
import hashlib, hmac, json, os, time
from fastapi import FastAPI, Request, Response

SECRET = os.environ.get("LOKUTOR_WEBHOOK_SECRET", "")  # whsec_…

def is_from_lokutor(body: bytes, headers, secret: str = SECRET, now: float | None = None) -> bool:
    timestamp = headers.get("lokutor-timestamp", "")
    if not timestamp.isdigit() or abs((now or time.time()) - int(timestamp)) > 300:
        return False
    expected = "v1=" + hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(s.strip(), expected) for s in headers.get("lokutor-signature", "").split(","))

app = FastAPI()

@app.post("/lokutor")
async def lokutor(request: Request):
    body = await request.body()
    if not is_from_lokutor(body, request.headers):
        return Response(status_code=401)
    call = json.loads(body)
    print(call["conversation_id"], call["outcome"], call["summary"])
    return Response(status_code=204)
```

To check your own code: the secret `whsec_test`, the timestamp `1764064000` and the body `{"event":"conversation.completed"}` sign as

```
v1=6f126262ed8e112915f2a38cb33201804d8fa0a3ad2e15c4054845e00f7d9ac7
```

## Answer, and what happens when you don't

Answer with any `2xx` within 10 seconds, and do the slow work afterwards. Anything else is tried again: after 30 seconds, 2, 10 and 30 minutes, 1, 2 and 4 hours and 8 hours twice, ten attempts over a day. `410` stops at once. Redirects are not followed, the certificate must be valid, and an address that resolves to a private network is refused.

A call can arrive twice, when your answer got lost on the way: ignore an `id` you already have. Calls are not sent in order.

**Developers → Webhooks** lists the last deliveries (two weeks, a month when they failed): how each was answered, when it is tried again, and **Send again**, which sends the call as it is now to the address it would go to today.

A new secret does not interrupt anything: requests are signed with both for a day. Put the new one in your system within it.

In a demo workspace nothing is sent.


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