SIP Trunk

How to create and configure a LiveKit SIP Trunk.

caution:

SIP is currently in Developer Preview.

To provision an SIP Trunk with the SIP Service, use the CreateSIPTrunk API. It returns an SIPTrunkInfo object that describes the created SIPTrunk. These parameters can also be queried at any time using the ListSIPTrunk API.

SIP Trunk with no options set

The following creates a SIP Trunk with no configuration set. This means all inbound calls would be accepted, and outbound calls are not possible. This is not something you should go to production with.

Create a file at sipTrunk.json with the following contents:

{
"inbound_addresses": [],
"outbound_address": "",
"outbound_number": "",
"inbound_numbers_regex": [],
"inbound_username": "",
"inbound_password": "",
"outbound_username": "",
"outbound_password": ""
}
note:

Setting outbound_number parameter is required for both inbound and outbound calls.

Then create the SIP Trunk using livekit-cli:

export LIVEKIT_URL=<your LiveKit server URL>
export LIVEKIT_API_KEY=<your API Key>
export LIVEKIT_API_SECRET=<your API Secret>
livekit-cli create-sip-trunk --request sipTrunk.json

SIP Trunk configured for Twilio and one phone number

The following creates a SIP trunk that only allows traffic from Twilio from certain phone numbers. This is a good secure default configuration.

Create a file at sipTrunk.json with the following contents:

{
"inbound_addresses": ["54.172.60.0", "54.172.60.1", "54.172.60.2", "54.172.60.3"],
"outbound_address": "my-twillio-trunk.pstn.twilio.com",
"outbound_number": "+15555551212",
"inbound_numbers_regex": ["5555551212"],
"inbound_username": "",
"inbound_password": "",
"outbound_username": "twilioUsername",
"outbound_password": "twilioPassword"
}

Then create the SIP Trunk using livekit-cli:

export LIVEKIT_URL=<your LiveKit server URL>
export LIVEKIT_API_KEY=<your API Key>
export LIVEKIT_API_SECRET=<your API Secret>
livekit-cli create-sip-trunk --request sipTrunk.json