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

# SIP

> Run assistant-api with the built-in SIP server for direct SIP connectivity.

The `assistant-api` includes a built-in SIP server. Any SIP client, softphone, or PBX can call it directly — no external telephony account is required.

***

## Required Configuration

```env theme={null}
# docker/assistant-api/.assistant.env
SIP__SERVER=0.0.0.0            # Bind address (listen on all interfaces)
SIP__EXTERNAL_IP=203.0.113.10  # Your server's PUBLIC IP — advertised in SDP
SIP__PORT=5090                  # SIP signalling port (UDP)
SIP__RTP_PORT_RANGE_START=10000
SIP__RTP_PORT_RANGE_END=20000
```

<Warning>
  `SIP__EXTERNAL_IP` must be your server's real public IP. If left as `0.0.0.0`, SDP will advertise a non-routable address, breaking the RTP media path — callers will hear silence.
</Warning>

***

## Firewall Ports

| Port          | Protocol | Purpose        |
| ------------- | -------- | -------------- |
| `5090`        | UDP      | SIP signalling |
| `10000–20000` | UDP      | RTP media      |

***

## Connecting a SIP Client

Route inbound calls to one of the accepted SIP destination users:

| Format                                                   | Example                                  | Resolution                                                                         |
| -------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------- |
| `sip:agent-{assistantID}@{SIP__EXTERNAL_IP}:{SIP__PORT}` | `sip:agent-123456789@203.0.113.10:5090`  | Routes directly by numeric assistant ID                                            |
| `sip:did-{did}@{SIP__EXTERNAL_IP}:{SIP__PORT}`           | `sip:did-+15551234567@203.0.113.10:5090` | Looks up the active SIP phone deployment whose phone value exactly matches `{did}` |
| `sip:{did}@{SIP__EXTERNAL_IP}:{SIP__PORT}`               | `sip:+15551234567@203.0.113.10:5090`     | Same DID lookup, without the `did-` prefix                                         |

The DID value is matched exactly. For example, `+15551234567` and `15551234567`
are different route values.

<Warning>
  Credential-style users such as `sip:{assistantID}:{apiKey}@host` are not
  accepted for inbound routing.
</Warning>

***

## Asterisk SIP Trunk (Optional)

To route calls from Asterisk through Rapida over SIP:

<Tabs>
  <Tab title="pjsip.conf">
    ```ini theme={null}
    ; /etc/asterisk/pjsip.conf
    [rapida-trunk]
    type=endpoint
    context=rapida-outbound
    disallow=all
    allow=ulaw
    aors=rapida-trunk-aor

    [rapida-trunk-aor]
    type=aor
    contact=sip:{SIP__EXTERNAL_IP}:{SIP__PORT}

    [rapida-dialer]
    type=identify
    endpoint=rapida-trunk
    match={SIP__EXTERNAL_IP}
    ```
  </Tab>

  <Tab title="extensions.conf">
    ```ini theme={null}
    ; /etc/asterisk/extensions.conf
    [rapida-outbound]
    exten => _X.,1,NoOp(Route through Rapida SIP)
     same => n,Dial(PJSIP/did-${EXTEN}@rapida-trunk)
     same => n,Hangup()
    ```
  </Tab>
</Tabs>

***

## Rapida SaaS SIP Endpoint

For Rapida SaaS, the production SIP server is:

```
sip:agent-{assistantID}@sip-01.in.rapida.ai:5060
```

You can also route by DID:

```
sip:did-{did}@sip-01.in.rapida.ai:5060
sip:{did}@sip-01.in.rapida.ai:5060
```

***

<CardGroup cols={2}>
  <Card title="Asterisk" icon="server" href="/opensource/services/assistant-api/telephony/asterisk">
    Asterisk AudioSocket and WebSocket transports
  </Card>

  <Card title="Configuration" icon="sliders" href="/opensource/services/assistant-api/configuration">
    SIP\_\_EXTERNAL\_IP and other SIP env vars
  </Card>

  <Card title="Telephony Overview" icon="network" href="/opensource/services/assistant-api/telephony/overview">
    All providers comparison
  </Card>

  <Card title="Configure Your Own" icon="code" href="/opensource/services/assistant-api/telephony/custom">
    Add a new telephony provider
  </Card>
</CardGroup>
