# Connect your voice stack

Route inbound calls to your agent over SIP and place outbound calls from your number.

> Early access: these interfaces are documented as drafts. Confirm commands, packages and endpoints with us before use.

Source: https://trunkbeam.com/en/docs/sip

## Inbound calls

Every number points to a SIP target. We send each inbound call there.

```bash
trunkbeam numbers update +493023125417 --sip sip:agent@voice.example
```

Several targets are tried in order when the first does not answer. The last target may be a regular phone number, for example your office:

```bash
trunkbeam numbers update +493023125417 \
  --sip sip:agent@voice.example \
  --fallback sip:backup@voice.example \
  --fallback +4930123456
```

The SIP INVITE carries the caller's number in the `From` header and the dialed number in the `To` header, so your agent can behave differently per number.

## Outbound calls

For outbound calls, create a SIP trunk. You get host, username and password to enter at your voice platform.

```bash
trunkbeam trunks create --name vapi-production
```

```text
Host:      sip.trunkbeam.com
Username:  trk_4c1e9
Password:  (shown once)
Numbers:   all numbers in your account
```

Only numbers from your account are allowed as caller ID. We reject anything else, so nobody can place calls from numbers they do not own.

## Setup at your platform

Voice platforms usually call this "Bring your own SIP trunk", "Custom telephony" or "SIP trunk". The flow is similar everywhere:

1. Create a SIP trunk at the platform with host `sip.trunkbeam.com` and the credentials above.
2. Add your number at the platform and assign it to your agent.
3. Set the SIP address the platform gives you for inbound calls as the target with us.

## HD voice with G.722

TrunkBeam supports HD voice with the **G.722 wideband codec**, which carries a wider speech frequency range than traditional narrowband telephony.

HD quality requires your device, voice platform and the entire call path to support wideband audio. The systems on the SIP connection must negotiate a suitable codec. An HD-capable phone alone is not enough if another leg carries only narrowband audio, such as G.711. Converting that audio to G.722 later does not restore the lost frequencies.

This also applies to transfers: HD quality on the new connection depends on the destination device and call path.

Technical background: [ITU-T G.722](https://www.itu.int/rec/T-REC-G.722/en) and [SDP codec negotiation in RFC 3264](https://www.rfc-editor.org/rfc/rfc3264.html).

## Technical details

| | |
| --- | --- |
| Signaling | SIP over TLS (port 5061), UDP and TCP (port 5060) |
| Media | SRTP and RTP |
| Codecs | G.711 A-law (PCMA), G.711 µ-law (PCMU), G.722, Opus |
| DTMF | RFC 2833 (telephone-event) |
| Number format | E.164, for example `+493023125417` |

We will publish the IP ranges for firewall rules at launch.
