> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.formantai.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.formantai.com/_mcp/server.

# Receive Call Updates

> Build a webhook receiver for real-time call outcomes.

## 1. Create an endpoint

```javascript
const express = require("express");
const app = express();

app.use(express.json());

app.post("/webhooks/formant", async (req, res) => {
  const event = req.body;
  console.log(`Received ${event.event_type}: ${event.event_id}`);
  res.status(204).send();
});

app.listen(3000);
```

## 2. Add signature verification

Before production, verify `X-FormantAI-Signature` using the webhook secret.

Copy Node.js and Python examples for validating signed requests.

## 3. Configure the agent

Open the dashboard:

```text
Agent -> Webhook tab -> Add Target
```

Set:

* Name: `crm-sync`
* URL: `https://your-api.example.com/webhooks/formant`
* Secret: your generated webhook secret
* Events: `call.completed`, `call.no_answer`, `call.busy`, `call.failed`
* Include transcript: enabled if your CRM needs it
* Include recording URL: enabled if you need recordings

## 4. Process events idempotently

Webhook delivery can retry. Store `event_id` and ignore duplicates.

```javascript
async function handleEvent(event) {
  const inserted = await insertEventIfNew(event.event_id, event);
  if (!inserted) return;

  if (event.event_type === "call.completed") {
    await updateCustomerFromCall(event.data.call, event.data.results);
  }
}
```

## 5. Monitor delivery

Track webhook receiver latency and failures. Your endpoint should return a `2xx` response within 10 seconds.