# Generic PBX

> Connect an office PBX or any SIP server with a static IP to Edesy as a bring-your-own carrier, with an optional tech prefix and primary plus failover gateways.

Source: https://edesy.in/docs/sip-trunking/byoc/generic-pbx

Any SIP server with a static public IP, such as an office PBX or a carrier's session border controller, can be registered with Edesy as a carrier. Edesy trusts INVITEs from the gateway's IP, sends outbound calls to it, and can add a tech prefix to dialled numbers if your PBX routes on one.

> **Which page do I need?** If your PBX should dial out through Edesy's Indian numbers, you want a [termination trunk](https://edesy.in/docs/sip-trunking/termination-trunks/create-a-trunk) and the [FreePBX guide](https://edesy.in/docs/sip-trunking/guides/freepbx-17-pjsip). This page is for using *your PBX as the carrier* for Edesy calls.

## Values

| Setting | Value |
|---|---|
| Auth | IP-based. Edesy matches the source IP. |
| Gateway | Your PBX's public IP or hostname, port `5060` (or your SIP port) |
| Transport | `udp` (default) or `tcp`. TLS is available on request. |
| Tech prefix | Optional digits added in front of outbound numbers |
| Range matching | `netmask` on the gateway (default `32`) |

## 1. Register the carrier on Edesy

```bash
curl -X POST https://voice-api.edesy.in/v1/trunk-portal/trunks \
  -H "Authorization: Bearer sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Office PBX",
    "tech_prefix": "99",
    "gateways": [
      { "ipv4": "203.0.113.50", "port": 5060, "protocol": "udp" },
      { "ipv4": "203.0.113.51", "port": 5060, "protocol": "udp" }
    ],
    "numbers": ["+91XXXXXXXXXX"]
  }'
```

The second gateway is a failover. Set `"inbound": false` or `"outbound": false` on a gateway to use it in one direction only.

## 2. Configure the PBX

1. Allow SIP and media from Edesy's signalling IP on your firewall.
2. Create a SIP peer or trunk for Edesy with IP-based matching and no registration.
3. Route the listed numbers from that peer into your dialplan, and send outbound calls for Edesy to the address from onboarding on port `5070`.
4. Enable G.711 μ-law and A-law only, and RFC 2833 DTMF.

## 3. Test

- Outbound: `POST /v1/calls` with `from` set to one of the numbers you listed.
- Inbound: call one of those numbers through your PBX.

## FAQ

### What does the tech prefix do?

It is added in front of every number Edesy sends to your PBX, so a dialplan that routes on `99` can tell Edesy calls apart.

### My PBX is behind NAT.

Edesy matches on the source IP it sees, which is your public IP. Set your PBX's external address and open the media ports. See [One-Way Audio and NAT](https://edesy.in/docs/sip-trunking/troubleshooting/one-way-audio-and-nat).

See [Bring Your Own Carrier](https://edesy.in/docs/sip-trunking/byoc) for how routing works.
