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

# WhatsApp Calling

> Enable voice calls and connect your own media server or voice agent through Kapso

Kapso forwards call events to your webhook and proxies call actions to Meta. Audio and the agent run on your own server or voice provider.

To start from working code, [enable Calling](#2-enable-calling), then [deploy the voice agent starter](https://docs.kapso.ai/docs/whatsapp/calling/voice-agents.md#deploy-the-starter). It registers its own webhook and handles audio, so you can skip steps 3 and 4.

## What you need

* A dedicated WhatsApp Cloud API number in your Kapso project, with a messaging limit of at least 2,000 unique recipients per day.
* A Kapso API key from that project and the number's **Meta phone number ID**.
* A public HTTPS endpoint for call webhooks.
* A media server that handles WebRTC audio and generates SDP offers and answers.

> [!NOTE]
>
> The Kapso sandbox doesn't support Calling, and coexistence numbers keep their calls in the WhatsApp Business App. Meta decides eligibility and country availability; check [Meta's current prerequisites](https://developers.facebook.com/documentation/business-messaging/whatsapp/calling) before picking a number.

## 1. Configure your application

Add these to your `.env`:

```dotenv theme={null}
KAPSO_API_KEY=your_project_api_key
WHATSAPP_PHONE_NUMBER_ID=your_meta_phone_number_id
META_GRAPH_VERSION=v24.0
WHATSAPP_WEBHOOK_SECRET=your_random_webhook_secret
PUBLIC_WEBHOOK_URL=https://your-app.example/webhooks/whatsapp
```

To run the shell examples on this page, load it with `set -a && source .env && set +a`. Your speech-to-text, LLM, and text-to-speech provider keys go on your server too.

`WHATSAPP_PHONE_NUMBER_ID` is Meta's phone number ID, not the display number, WABA ID, project ID, or Kapso configuration UUID. Find it under **Phone numbers** in the dashboard, or list your numbers:

```bash theme={null}
curl --fail-with-body \
  'https://api.kapso.ai/platform/v1/whatsapp/phone_numbers' \
  -H "X-API-Key: $KAPSO_API_KEY"
```

## 2. Enable Calling

```bash theme={null}
curl --fail-with-body -X PATCH \
  "https://api.kapso.ai/platform/v1/whatsapp/phone_numbers/$WHATSAPP_PHONE_NUMBER_ID" \
  -H "X-API-Key: $KAPSO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"whatsapp_phone_number":{"calls_enabled":true}}'
```

Or in the dashboard: open **Phone numbers**, select the number, and turn on **Calls** in its **Settings** tab. Either way, Kapso sends the setting to Meta; you don't need to change anything in Meta Business Manager.

Check the result through the proxy:

```bash theme={null}
curl --fail-with-body \
  "https://api.kapso.ai/meta/whatsapp/$META_GRAPH_VERSION/$WHATSAPP_PHONE_NUMBER_ID/settings?fields=calling" \
  -H "X-API-Key: $KAPSO_API_KEY"
```

`calling.status` should be `ENABLED`. If Meta rejects the number as ineligible, resolve that first. Changing the voice model or webhook won't enable it.

### Choose who answers

Once Calling is on, the number shows **Incoming call answering** in the dashboard. Call activity appears in the Inbox with any option.

| Option | Who answers | Your call actions |
| - | - | - |
| **Agent or integration** (default) | Your receiver or a dashboard voice agent | Work as described in these guides. |
| **Agent with Inbox fallback** | Your agent or a teammate in the Inbox, whichever answers first | Must go through Kapso, not directly to Meta. If someone else already answered, `pre_accept`, `accept`, and `reject` return `409 answered_elsewhere`. |
| **Inbox only** | Teammates in the Inbox | `pre_accept`, `accept`, and `reject` return `409 inbound_calls_answered_in_inbox`. `terminate` still works. |

Use **Agent or integration** for agent-only calls. To keep the agent and let teammates answer, select **Agent with Inbox fallback**. See [Inbox calls](https://docs.kapso.ai/docs/platform/inbox/calls.md).

## 3. Register a Meta webhook

Calling events keep Meta's payload format, so they go to a phone-number webhook with `kind: "meta"`. Kapso-format webhooks and project webhooks don't receive them.

Check whether the number already has one:

```bash theme={null}
curl --fail-with-body \
  "https://api.kapso.ai/platform/v1/whatsapp/phone_numbers/$WHATSAPP_PHONE_NUMBER_ID/webhooks?kind=meta" \
  -H "X-API-Key: $KAPSO_API_KEY"
```

Each number can have only one Meta webhook, including inactive ones. If one exists, reuse it or update it deliberately: changing it moves every Meta event for the number, not just calls.

If there's no Meta webhook, create one. `jq` encodes the URL and secret safely:

```bash theme={null}
jq -n \
  --arg url "$PUBLIC_WEBHOOK_URL" \
  --arg secret "$WHATSAPP_WEBHOOK_SECRET" \
  '{whatsapp_webhook:{kind:"meta",url:$url,secret_key:$secret,active:true}}' \
  | curl --fail-with-body -X POST \
    "https://api.kapso.ai/platform/v1/whatsapp/phone_numbers/$WHATSAPP_PHONE_NUMBER_ID/webhooks" \
    -H "X-API-Key: $KAPSO_API_KEY" \
    -H 'Content-Type: application/json' \
    --data-binary @-
```

`secret_key` is required. Kapso signs deliveries with it; it's not your API key. Save the returned webhook ID, then list the webhooks again and confirm the URL and `active: true`.

Before placing a call, check for overlap:

* **A `kind: "kapso"` webhook already processes your messages.** The Meta webhook also receives Meta `messages` changes. Process normal messages from only one of them to avoid duplicate replies, and handle Calling permission replies on the Meta webhook.
* **A voice agent is assigned to the number in the dashboard.** Decide whether that agent or your receiver answers calls. Don't let both answer.

## 4. Connect audio

```mermaid theme={null}
flowchart LR
  WhatsApp[WhatsApp caller] <--> Meta[Meta]
  Meta -->|Call event| Kapso[Kapso]
  Kapso -->|Signed HTTPS webhook| Agent[Your media server and agent]
  Agent -->|Call action and SDP| Kapso
  Kapso -->|Call action and SDP| Meta
  Meta <-->|WebRTC audio| Agent
```

Events and SDP travel over HTTPS through Kapso. Audio skips Kapso: it travels over WebRTC between Meta and your media server, so that server must be reachable for media too. ICE picks the media path: STUN discovers a reachable address, and TURN relays audio when a direct connection fails.

A tunnel like Tailscale Funnel can deliver webhooks to a local server, but it doesn't make UDP media reachable. Configure a TURN relay if your network needs one. Hosts without inbound UDP can still work: the [voice agent starter](https://docs.kapso.ai/docs/whatsapp/calling/voice-agents.md#deploy-the-starter) connects audio on Railway with only a public STUN server.

With your [receiver](https://docs.kapso.ai/docs/whatsapp/calling/receive-calls.md) and [voice agent](https://docs.kapso.ai/docs/whatsapp/calling/voice-agents.md) running, call the number from WhatsApp. To skip building both, [deploy the starter](https://docs.kapso.ai/docs/whatsapp/calling/voice-agents.md#deploy-the-starter). You can also [send a call button](https://docs.kapso.ai/docs/whatsapp/send-messages/voice-call.md) that the user taps to call you.

## Other Calling features

Meta can record and transcribe calls you opt in. Kapso shows the results in call details and serves them through the API; see [Recordings and transcripts](https://docs.kapso.ai/docs/whatsapp/calling/recordings-and-transcripts.md).

Meta also documents [SIP, voicemail, and partner call routing](https://developers.facebook.com/documentation/business-messaging/whatsapp/calling). These guides cover WebRTC only; those features need their own setup and testing. Routing a number's calls over SIP replaces the Calling API for that number, so Kapso call actions and Inbox answering stop. A messaging handoff doesn't transfer a live call.

## Pricing

User-initiated calls are free. Meta charges business-initiated calls by destination country and monthly volume, in 6-second pulses. Kapso adds no Calling markup. See [Calling pricing](https://docs.kapso.ai/docs/whatsapp/pricing-faq.md#how-is-whatsapp-calling-billed).

## Troubleshooting

If your agent cannot answer or Inbox has no answer controls, start with [Calling troubleshooting](https://docs.kapso.ai/docs/whatsapp/calling/troubleshooting.md).

| Symptom | Check |
| - | - |
| Number not found or access denied | The API key belongs to the project that owns this phone number ID. |
| Calling can't be enabled | The number is a dedicated Cloud API connection. Save Meta's error code and subcode. |
| Calls never reach your server | An active `kind: meta` webhook, its URL, and webhook delivery logs. |
| Signature verification fails | Raw request bytes, `X-Webhook-Signature`, and the webhook's `secret_key`. |
| Call action returns `409` | **Incoming call answering** on the number. `answered_elsewhere`: another answerer, such as a teammate in the Inbox, has the call. `inbound_calls_answered_in_inbox`: the number answers in the Inbox only. |
| Call connects but has no audio | ICE connection state, firewall and TURN configuration, and audio frames in both directions. |
| Greeting plays, then the agent stops responding | Final STT text, turn detection, what reaches the LLM, and provider errors. A greeting alone doesn't prove the agent hears the caller. |
| API returns non-JSON | HTTP status and response body before parsing, and the API host and path. |
| Outbound call is rejected | `start_call.can_perform_action`, number and country support, and Kapso billing errors. |
| No recording or transcript | `recording`/`transcription` on `accept` or `connect` (not `pre_accept`), whether the announcement played, and whether completion events arrived. |

> [card] [Receive calls](https://docs.kapso.ai/docs/whatsapp/calling/receive-calls.md)
>
> Verify events, answer a call, and end the session.

> [card] [Connect a voice agent](https://docs.kapso.ai/docs/whatsapp/calling/voice-agents.md)
>
> Deploy the starter, or connect Pipecat, ElevenLabs Agents, or Grok Voice.

> [card] [Make outbound calls](https://docs.kapso.ai/docs/whatsapp/calling/outbound-calls.md)
>
> Check permission, dial, and apply the caller's SDP answer.

> [card] [Recordings and transcripts](https://docs.kapso.ai/docs/whatsapp/calling/recordings-and-transcripts.md)
>
> Opt calls into Meta capture, then play, read, and download the results.

> [card] [TypeScript SDK](https://docs.kapso.ai/docs/whatsapp/typescript-sdk/calls.md)
>
> Use the call action, permission, and log helpers.


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