Skip to main content

SIP inbound trunk

How to create and configure an inbound trunk to accept incoming calls.

Overview

After you purchase a phone number and configure your SIP trunking provider, you must create an inbound trunk and dispatch rule to accept incoming calls. The inbound trunk allows you to limit incoming calls to those coming from your SIP trunking provider.

You can also configure additional properties for all incoming calls that match the trunk including SIP headers, participant metadata and attributes, and session properties. For a full list of available parameters, see CreateSIPInboundTrunk.

Note

LiveKit supports username and password authentication for inbound trunks, but your SIP trunking provider must also support it. Support varies by provider—for example, Twilio Elastic SIP Trunking doesn’t support it, though you can use username and password authentication with TwiML. Check with your provider to confirm.

To learn more about LiveKit SIP, see SIP overview. To learn more about SIP API endpoints and types, see SIP API.

Restricting calls to a region

When you configure your SIP trunking provider for inbound calls, you need to specify the LiveKit SIP endpoint to use. By default, this is a global endpoint and incoming calls are routed to the region closest to the call's origination point—typically the region where your telephony provider initiated the call. You can limit calls to a specific region using region pinning.

Inbound trunk example

The following examples create an inbound trunk that accepts calls made to the number +1-510-555-0100 and enables Krisp noise cancellation. This phone number is the number purchased from your SIP trunking provider.

  1. Create a file named inbound-trunk.json with the following content:

    {
    "trunk": {
    "name": "My trunk",
    "numbers": [
    "+15105550100"
    ],
    "krispEnabled": true
    }
    }
    Important

    If you're using Telnyx, the leading + in the phone number assumes the Destination Number Format is set to +E.164 for your number.

  2. Create the inbound trunk using lk:

    lk sip inbound create inbound-trunk.json

Accepting calls from specific phone numbers

The configuration for inbound trunk accepts inbound calls to number +1-510-555-0100 from caller numbers +1-310-555-1100 and +1-714-555-0100.

Important

Remember to replace the numbers in the example with actual phone numbers when creating your trunks.

Tip

You can also filter allowed caller numbers with a Dispatch Rule.

  1. Create a file named inbound-trunk.json with the following content:

    {
    "trunk": {
    "name": "My trunk",
    "numbers": [
    "+15105550100"
    ],
    "allowedNumbers": [
    "+13105550100",
    "+17145550100"
    ]
    }
    }
    Important

    If you're using Telnyx, the leading + in the phone number assumes the Destination Number Format is set to +E.164 for your number.

  2. Create the inbound trunk using lk:

    lk sip inbound create inbound-trunk.json

List inbound trunks

Use the ListSIPInboundTrunk API to list all inbound trunks and trunk parameters.

lk sip inbound list

Update inbound trunk

Use the UpdateSIPInboundTrunk API to update specific fields of an inbound trunk or replace an inbound trunk with a new one.

Update specific fields of an inbound trunk

The UpdateSIPInboundTrunkFields API allows you to update specific fields of an inbound trunk without affecting other fields.

  1. Create a file named inbound-trunk.json with the following content:

    {
    "name": "My trunk",
    "numbers": [
    "+15105550100"
    ]
    }
    Important

    If you're using Telnyx, the leading + in the phone number assumes the Destination Number Format is set to +E.164 for your number.

Update the inbound trunk using lk:

lk sip inbound update --id <trunk-id> inbound-trunk.json

Replace inbound trunk

The UpdateSIPInboundTrunk API allows you to replace an existing inbound trunk with a new one using the same trunk ID.

The CLI doesn't support replacing inbound trunks.