high-twilight-48614
08/12/2025, 2:17 PMtall-airline-16756
08/12/2025, 2:17 PMtall-airline-16756
08/12/2025, 2:18 PMLiveKitAPI
client with your LiveKit URL, API key, and API secret.
2. Prepare the Update Request: Use the SIPInboundTrunkUpdate
class to set up the new list of numbers. The ListUpdate
helper makes it easy to specify these numbers.
3. Call the Update Method: Then, call the update_sip_inbound_trunk_fields
method from the SipService
class, passing the trunk ID along with your update request.
Here’s a quick example to guide you:
from livekit import api
from livekit.protocol.models import ListUpdate
from livekit.protocol.sip import (
SIPInboundTrunkUpdate,
)
async def update_inbound_trunk_numbers():
# First, initialize the LiveKit API client
lk_api = api.LiveKitAPI(
url="your_livekit_url",
api_key="your_api_key",
api_secret="your_api_secret",
)
# Swap out "existing_trunk_id" with your actual Inbound Trunk ID
trunk_id = "existing_trunk_id"
# Define your new list of numbers
new_numbers = ["+1234567890", "+2345678901"]
# Create the update request with the new numbers
update = SIPInboundTrunkUpdate(
numbers=ListUpdate(set=new_numbers),
)
# Now, update the trunk
updated_trunk = await lk_api.sip.update_sip_inbound_trunk_fields(trunk_id, numbers=new_numbers)
print("Inbound Trunk updated:", updated_trunk)
# Just a heads up: make sure to run this inside an async context
# if __name__ == "__main__":
# import asyncio
# asyncio.run(update_inbound_trunk_numbers())
Don’t forget to replace placeholders like your_livekit_url
, your_api_key
, your_api_secret
, existing_trunk_id
, and the new numbers with your actual info. This will smoothly update your Inbound Trunk with the new numbers you want.high-twilight-48614
08/12/2025, 2:35 PMtall-airline-16756
08/12/2025, 2:36 PMnumbers
field in the SIPInboundTrunkUpdate
object is immutable. To update it, you’ll want to use the ListUpdate
helper instead. Here’s a simple way to fix it:
from livekit.protocol.models import ListUpdate
from livekit.protocol.sip import SIPInboundTrunkUpdate
# Create the update object with ListUpdate for numbers
update = SIPInboundTrunkUpdate(
numbers=ListUpdate(set=["+1234567890", "+2345678901"]),
)
# Use the update object in your request
response = await lk_api.sip.update_sip_inbound_trunk_fields(
trunk_id="existing_trunk_id",
update=update
)
print("Inbound Trunk updated:", response)
Just make sure to use the ListUpdate
constructor with the set
parameter to replace your list of numbers. This little tweak fixes the immutability hiccup and lets your update go through smoothly. Hope this helps!high-twilight-48614
08/12/2025, 2:41 PMtall-airline-16756
08/12/2025, 2:42 PMupdate_sip_inbound_trunk_fields
method doesn’t take an update
keyword argument. Instead, you can just pass the fields you want to update directly as keyword arguments. Here's how you can do it:
from livekit import api
# Initialize the LiveKit API client
lk_api = api.LiveKitAPI(
url="your_livekit_url",
api_key="your_api_key",
api_secret="your_api_secret",
)
# Update specific fields of an inbound trunk
updated_trunk = await lk_api.sip.update_sip_inbound_trunk_fields(
trunk_id="existing_trunk_id",
numbers=["+1234567890", "+2345678901"],
name="Updated Trunk Name",
metadata="Updated metadata"
)
print("Inbound Trunk updated:", updated_trunk)
Just swap out the placeholders like your_livekit_url
, your_api_key
, your_api_secret
, and existing_trunk_id
with your real info. Then, pass the fields you want to update (like numbers
, name
, or metadata
) directly to the method. Hope this helps!
Sources: livekit-protocol/livekit/protocol/sip.py | SIP APIs | LiveKit Docs | SIP inbound trunk | LiveKit Docshigh-twilight-48614
08/12/2025, 2:49 PMtall-airline-16756
08/12/2025, 2:50 PM