SIP Trunk

How to create and configure a LiveKit SIP Trunk.

caution:

LiveKit SIP Trunk configuration is now split to Inbound Trunk and Outbound Trunk. Please use these new APIs instead of the old ones.

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 to <your-sip-number> 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 content:

{
"outbound_number": "<your-sip-number>",
"outbound_address": "",
"outbound_username": "",
"outbound_password": "",
"inbound_addresses": [],
"inbound_numbers": [],
"inbound_username": "",
"inbound_password": ""
}
note:

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

Then create the SIP Trunk using lk:

export LIVEKIT_URL=<your LiveKit server URL>
export LIVEKIT_API_KEY=<your API Key>
export LIVEKIT_API_SECRET=<your API Secret>
lk 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 +9876543210 phone number calling +1234567890. This is a good secure default configuration.

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

{
"outbound_number": "+1234567890",
"outbound_address": "my-twilio-trunk.pstn.twilio.com",
"outbound_username": "<twilio-trunk-username>",
"outbound_password": "<twilio-trunk-password>",
"inbound_numbers": ["+9876543210"],
"inbound_addresses": [],
"inbound_username": "",
"inbound_password": ""
}

Then create the SIP Trunk using lk:

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