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

# VoIP / SIP

> Bridge an existing phone line or SIP trunk to Humain without any WebRTC runtime on your device.

## Overview

VoIP mode lets you connect a PSTN phone line or SIP trunk to the Humain AI. Unlike WebRTC, there
is no browser or special client library required — your PBX or VoIP adapter handles the telephony;
Humain handles the AI.

> [!NOTE]
>
> VoIP mode is configured in the admin panel under **Kiosk → Voice settings → VoIP / SIP**.
> Contact [support@humain.ai](mailto:support@humain.ai) to enable the SIP endpoint for your
> workspace.

## Integration paths

> [card] [SIP trunk (PBX)](https://humain.mintlify.site/voip/sip-gateway.md)
>
> Configure your PBX (Asterisk, FreeSWITCH, 3CX, or any SIP-compatible system) to route
> calls to the Humain SIP endpoint. Best for high-volume call centres with existing
> telephony infrastructure.

> [card] [Asterisk / FreePBX](https://humain.mintlify.site/voip/asterisk-agi.md)
>
> Write a dialplan and AGI script for full control over call flow, DTMF handling, and
> mid-call transfers. Or use the FreePBX GUI module for zero-code setup.

> [card] [Twilio / Vonage / Telnyx](https://humain.mintlify.site/voip/twilio.md)
>
> Route cloud telephony calls to a Humain Kiosk session via webhooks and the provider's
> audio streaming API. Lets you add SMS fallback, recording, and call analytics.

> [card] [Mobile app (SIP client)](https://humain.mintlify.site/mobile/ios-swift.md)
>
> Embed a SIP stack (PJSIP, linphone) in your iOS/Android app. The app registers against
> the Humain SIP endpoint and calls are handled like any other SIP call.

## Session flow

A VoIP session still uses the Device API. Your server-side integration (PBX dialplan, Twilio webhook,
etc.) calls the Humain API to open and close sessions. The audio bridge is handled transparently.

```mermaid theme={null}
sequenceDiagram
  participant P as PSTN / Caller
  participant T as Telephony layer (PBX / Twilio)
  participant S as Humain API (server)
  participant AG as Humain API (agent_url)

  P->>T: Incoming call
  T->>S: POST /v1/sessions {"mode":"voip"}
  S-->>T: 201 {"session_id":"...","agent_url":"..."}
  Note over T,AG: SIP INVITE → SIP 200 OK
  P->>AG: Audio (via RTP / SIP)
  AG->>P: Audio (Gemini Live response)
  Note over P,AG: Conversation continues...
  P->>T: Caller hangs up
  T->>AG: POST /v1/sessions/{sid}/end
  AG-->>T: 204
```

## Configuration checklist

**1. Enable VoIP for your kiosk**

In the admin panel, open your kiosk and navigate to **Voice settings → VoIP / SIP**.
Toggle VoIP on and note the assigned SIP URI (e.g. `sip:kiosk-abc123@sip.humain.ai`).

**2. Configure your telephony layer**

Point your PBX, ATA, or CPaaS at the Humain SIP endpoint. Use the SIP URI from the
previous step. TLS and SRTP are required — plain SIP is not supported.

**3. Open sessions programmatically**

When an inbound call arrives, your server-side webhook calls `POST /v1/sessions` with
`mode: "voip"` before accepting the SIP INVITE.

```bash theme={null}
curl -X POST https://api.humain.ai/v1/sessions \
  -H "Authorization: Bearer hk_live_your_credential_here" \
  -H "Content-Type: application/json" \
  -d '{"mode":"voip"}'
```

**4. Close sessions on hang-up**

When the caller hangs up, call `POST {agent_url}/v1/sessions/{sid}/end` (the `agent_url`
from the open response, not necessarily the host you called to open the session) to flush
usage data.

## Supported codecs

| Codec | Support |
| - | - |
| G.711 μ-law (PCMU) | ✅ Supported |
| G.711 A-law (PCMA) | ✅ Supported |
| G.722 (HD voice) | ✅ Supported |
| Opus | ✅ Supported |
| G.729 | ❌ Not supported |

> [!NOTE]
>
> For best transcription accuracy, prefer G.722 (wideband) or Opus over G.711 narrowband.
> Gemini Live — the model that handles live voice, including VoIP calls — performs
> significantly better at 16 kHz+ audio.

## Security

All SIP signalling uses TLS (port 5061). Media uses SRTP. Plain SIP on port 5060 is rejected
at the network edge. Ensure your PBX or ATA supports TLS/SRTP before attempting to connect.


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