# Route a Number to SIP

> Send inbound calls on an Edesy number to a SIP URI or saved SIP destination, with optional digest credentials and custom SIP headers, in the portal or with PATCH /v1/phone-numbers/:id/routing.

Source: https://edesy.in/docs/sip-trunking/inbound/route-a-number-to-sip

To send calls on an Edesy number to your PBX or voice agent, set the number's inbound routing to **SIP URI** and pick a saved destination or paste a URI. Edesy then forwards each incoming call as a SIP INVITE. If your endpoint asks for credentials or a secret header, add them on the same screen.

## In the portal

1. Open **Phone Numbers** and select the number.
2. In **Inbound routing**, choose **SIP URI**.
3. Pick a saved destination from the dropdown, or choose **Custom URI** and paste one.
4. Optional: open **Endpoint requires a username and password?** and enter the SIP username and password your endpoint expects.
5. Optional: open **Endpoint needs a custom SIP header?** and add header names and values (for example, Vapi uses `X-Vapi-Secret`).
6. Save.

Passwords and header values are stored encrypted and are never shown again. To change a saved header, re-enter its value.

## With the API

`PATCH https://voice-api.edesy.in/v1/phone-numbers/:id/routing`

```bash
curl -X PATCH https://voice-api.edesy.in/v1/phone-numbers/NUMBER_ID/routing \
  -H "Authorization: Bearer sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inbound_target_type": "sip",
    "inbound_sip_uri": "sip:+91XXXXXXXXXX@your-project.sip.example.com",
    "inbound_sip_username": "edesy-inbound",
    "inbound_sip_password": "YOUR_ENDPOINT_PASSWORD",
    "inbound_sip_headers": { "X-Example-Secret": "YOUR_SECRET" }
  }'
```

| Field | Type | Description |
|---|---|---|
| `inbound_target_type` | string | `sip` for a SIP URI |
| `inbound_sip_uri` | string | The URI to dial |
| `inbound_sip_username` | string | Optional digest username. Send `""` to clear. |
| `inbound_sip_password` | string | Optional digest password. Write-only. Send `""` to clear. |
| `inbound_sip_headers` | object | Optional custom headers. Replaces the whole set; `{}` clears it. |

> **Note:** Put secrets in a header, not in the URI. Header parameters inside a SIP URI (such as `?x-secret=...`) are dropped and never reach your endpoint.

## Route many numbers through one trunk

If many numbers should go to the same place, set the target on a termination trunk instead and point each number at the trunk:

```bash
# 1. Set the trunk-level inbound target once
curl -X PATCH https://voice-api.edesy.in/v1/trunks/TRUNK_ID \
  -H "Authorization: Bearer sk_YOUR_API_KEY" -H "Content-Type: application/json" \
  -d '{"inbound_target_type": "sip", "inbound_sip_uri": "sip:pbx.example.com:5060"}'

# 2. Route each number to the trunk
curl -X PATCH https://voice-api.edesy.in/v1/phone-numbers/NUMBER_ID/routing \
  -H "Authorization: Bearer sk_YOUR_API_KEY" -H "Content-Type: application/json" \
  -d '{"inbound_target_type": "trunk", "inbound_trunk_id": "TRUNK_ID"}'
```

For a PBX that registers on a credentials trunk (such as FreePBX), routing the number to the trunk delivers calls to the registered PBX. See the [FreePBX guide](https://edesy.in/docs/sip-trunking/guides/freepbx-17-pjsip).

## Other inbound targets

SIP is one of several targets a number can use, alongside a webhook that returns VoiceML, a media stream to your bot, Conversation Relay, an IVR Studio flow, an application preset, browser softphones, missed call, and call forwarding. For the WebSocket options, see [SIP Trunking for AI Voice Agents](https://edesy.in/docs/sip-trunk-for-ai-voice-agents).

## FAQ

### Do I need a termination trunk for inbound calls?

No. A number can route straight to a SIP URI. A trunk is only needed for outbound calls, or to share one inbound target across many numbers.

### Why does the portal warn that my URI has no user part?

Most platforms find the right agent from the number in the URI. Use `sip:<number>@host` rather than `sip:host`.

### My endpoint rejects the call with 401 or 407. What is missing?

Credentials. Add the SIP username and password your endpoint expects in the number's SIP authentication settings.
