brief-vase-33757
09/25/2025, 3:01 PMtall-airline-16756
09/25/2025, 3:01 PMtall-airline-16756
09/25/2025, 3:01 PMheaders_to_attributes in LiveKit, you can easily set it up within either an inbound or outbound SIP trunk configuration. This feature helps you map custom SIP headers (like X-* headers) directly to LiveKit participant attributes, making your setup more personalized and efficient.
For Inbound SIP Trunks:
When you're setting up or updating an inbound SIP trunk, simply use the headers_to_attributes field to connect headers from the SIP INVITE request to participant attributes. Here’s an example to guide you:
{
"trunk": {
"name": "Demo inbound trunk",
"numbers": [
"+15105550100"
],
"headers_to_attributes": {
"X-Custom-Id": "user_id",
"X-Custom-Role": "role"
}
}
}
For Outbound SIP Calls:
When making an outbound call using CreateSIPParticipant, you can include headers_to_attributes within the SIPOutboundConfig to map headers from the SIP 200 OK response to participant attributes. Here’s a helpful example:
{
"sip_trunk_id": "trunk_123",
"sip_call_to": "+1234567890",
"room_name": "my_room",
"trunk": {
"hostname": "sip.provider.com",
"transport": "UDP",
"headers_to_attributes": {
"X-User-ID": "user_id"
}
}
}
If you have any questions or need a hand with this setup, please don’t hesitate to reach out. I’m here to help!
Sources: SIP participant | LiveKit Docs | protobufs/rpc/sip.proto | livekit-protocol/livekit/protocol/sip.pyi | livekit-protocol/src/livekit.rsbrief-vase-33757
09/25/2025, 3:03 PMtall-airline-16756
09/25/2025, 3:03 PMheaders_to_attributes field might not be updating in your request because of the update method being used. To update this field, you’ll want to use the replace action in your update request, since the usual update methods don’t support changing this field directly.
Here’s a simple way to update it:
1. Use the replace action in your update request. For example:
{
"req": {
"sip_trunk_id": "your-trunk-id",
"replace": {
"name": "Updated Trunk Name",
"numbers": [
"+15105550100"
],
"address": "sip.provider.com",
"headers_to_attributes": {
"X-Custom-ID": "caller_id",
"X-Dept": "department"
},
"media_encryption": 0
}
}
}
1. Make sure to include all required fields, since the replace action will overwrite the entire trunk configuration.
2. Double-check that you’re using the correct API endpoint and authentication token, and that it matches your trunk type (inbound or outbound).
3. After sending the request, you can confirm the update by using GetSIPInboundTrunk or GetSIPOutboundTrunk.
If you run into any issues or have questions along the way, please don’t hesitate to reach out—I’m here to help!
Sources: livekit/livekit_sip.pb.go | SIP APIs | LiveKit Docsbrief-vase-33757
09/25/2025, 3:06 PMtall-airline-16756
09/25/2025, 3:07 PMupdate and replace actions in your request. To help you get the headers_to_attributes field updated correctly, here are a few friendly steps to follow:
1. Try using only the replace action when modifying the headers_to_attributes field, since the update action doesn’t support changes to this field.
2. Make sure the header names in headers_to_attributes are formatted properly. For example, they should match the pattern ^[a-zA-Z][a-zA-Z0-9\-_]*$ and avoid spaces or special characters.
3. Double-check that the SIP headers in the incoming INVITE request exactly match the names you’ve specified in headers_to_attributes, keeping in mind that this mapping is case-sensitive.
4. After sending your request, you can use the GetSIPInboundTrunk API to confirm that the headers_to_attributes field updated as expected.
If you’re still running into issues, it might help to look at the SIP INVITE request logs to see if the SIP provider is sending the headers you expect. Please don’t hesitate to reach out if you’d like me to walk through this with you further—I’m here to help!
Sources: protobufs/rpc/io.proto | SIP inbound trunk | LiveKit Docs | SIP APIs | LiveKit Docs