LiveKit attributes are not mapped to SIP X-* heade...
# ask-ai
c
LiveKit attributes are not mapped to SIP X-* headers when sending BYE
t
Thanks for reaching out, Shivansh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking into the BYE header-mapping issue. To diagnose this I need a few details: 1. Which field(s) in your trunk config are you using to map headers/attributes (e.g.,
attributes_to_headers
,
headers_to_attributes
)? 2. Are you expecting LiveKit participant attributes to be added as
X-*
headers on the SIP BYE, or to be mapped from incoming BYE headers into LiveKit attributes? Which direction is the problem? 3. Example configs (redact secrets) for the trunk and a sample SIP trace/snippet showing the INVITE and the BYE (headers present in INVITE but missing in BYE). 4. LiveKit version / deployment (managed LiveKit cloud or self-hosted) and SIP gateway/trunk setup details. 5. Any custom signaling or hooks that run on disconnect/leave? With those I can check the mapping behavior and suggest next steps or workarounds. If you prefer, paste the relevant config and SIP traces here and I’ll review them. Sources: SIP APIs | LiveKit docs
c
this is the JSON I have for inbound trunk the transfer attribute is not getting sent in the bye
Copy code
{
  "sipTrunkId": "ST_h78yQL8y",
  "name": "My inbound trunk",
  "numbers": [
    "+911234567890"
  ],
  "headersToAttributes": {
    "X-TCN-provider_name": "provider_name",
  },
  "attributesToHeaders": {
    "transfer": "True"
  },
  "includeHeaders": "SIP_ALL_HEADERS"
}
t
Thanks — I’m looking at the trunk JSON you sent and the problem you described (the
transfer
attribute is not sent as an X-* header on BYE). A few quick checks and questions to diagnose: 1. How and when is the
transfer
attribute set on the participant? (e.g., added when the call is established, updated later via REST/RTC API, or set from an incoming SIP header on INVITE) 2. Confirm the attribute name and mapping:
attributesToHeaders
maps LiveKit participant attributes (left side) to SIP header names (right side). In your JSON you currently have: ◦ "transfer": "True" That maps a LiveKit attribute named
transfer
to a SIP header literally named
True
. If you intend the header to be
X-Transfer: <value>
, the mapping should be
"transfer": "X-Transfer"
(or the exact header name you want). 1. Do you expect the attribute’s current value to be sent as the header value, or do you want a static header present (
X-Transfer: True
)? If you want the participant attribute value used as the header value, the mapping must point to the header name; the attribute value is used as the header value automatically. 2. Is the BYE generated by LiveKit (call ending from within LiveKit) or by the SIP peer? If the peer sends BYE, LiveKit must include mapped attributes when it generates outbound SIP requests — confirm whether BYE is sent by LiveKit in your trace. 3. Please paste a short SIP trace (INVITE and BYE headers) or indicate whether
transfer
appears on the participant in LiveKit just before hangup. Next steps based on answers: • If you intended a static header (
X-Transfer: True
), change mapping to
"transfer": "X-Transfer"
and ensure the participant has
transfer
set to
"True"
before termination. • If you intended the header name to be
True
, explain why and we’ll validate that behavior, but typical usage is mapping attribute -> header name (e.g.,
"transfer": "X-Transfer"
). Tell me how
transfer
is set and share the SIP BYE/INVITE snippets if possible and I’ll point to the exact config change or workaround.
c
give me the JSON
t
Use the header name you want on the right side and ensure the participant has the
transfer
attribute set before hangup. Example mapping
transfer
-> `X-Transfer`:
Copy code
{
  "sipTrunkId": "ST_h78yQL8y",
  "name": "My inbound trunk",
  "numbers": [
    "+911234567890"
  ],
  "headersToAttributes": {
    "X-TCN-provider_name": "provider_name"
  },
  "attributesToHeaders": {
    "transfer": "X-Transfer"
  },
  "includeHeaders": "SIP_ALL_HEADERS"
}
If you want a static header value
True
regardless of the attribute value, set the participant attribute
transfer
to
"True"
before termination or let me know and I can show a config/workaround.
c
await ctx.api.room.delete_room( api.DeleteRoomRequest( room=ctx.room.name, ) ) this is how I delete the room how do I send the value to transfer
t
You can’t pass attributes in
delete_room
. Set the participant’s
transfer
attribute before deleting the room so the trunk’s
attributes_to_headers
mapping can include it on the BYE. Example (Python):
Copy code
# set transfer attribute on the participant
await ctx.api.room.update_participant(
    room=ctx.room.name,
    identity=participant_identity,
    attributes={
        "transfer": "True"   # or the transfer value you want sent as the header value
    },
)

# then delete the room (will trigger BYE)
await ctx.api.room.delete_room(
    api.DeleteRoomRequest(
        room=ctx.room.name,
    )
)
Ensure your trunk mapping sends that attribute as the header name you want, e.g.:
Copy code
"attributes_to_headers": {
  "transfer": "X-Transfer"
}
Would you like the exact snippet for your codebase (e.g., with your participant identity variable) or to set multiple attributes at once? Sources: Managing participants | LiveKit docs | Managing rooms | LiveKit docs | SIP APIs | LiveKit docs
c
2025-11-27 235841,697 - my-worker - ERROR - ❌ Error hanging up call: RoomService.update_participant() got an unexpected keyword argument 'room' 2025-11-27 235841,697 - my-worker - ERROR - ❌ Error hanging up call: RoomService.update_participant() got an unexpected keyword argument 'room' 2025-11-27 235841,697 - ERROR my-worker - ❌ Error hangin
t
Thanks — that error means you passed
room
directly to
update_participant
. Use an
UpdateParticipantRequest
via the
request=
parameter. Example Python (async):
Copy code
from livekit.api import UpdateParticipantRequest

# set transfer attribute on the participant
await ctx.api.room.update_participant(
    request=UpdateParticipantRequest(
        room=ctx.room.name,
        identity=participant_identity,
        attributes={"transfer": "True"}
    )
)

# then delete the room (triggers BYE)
await ctx.api.room.delete_room(
    api.DeleteRoomRequest(room=ctx.room.name)
)
Confirm the participant identity variable and that the trunk maps
transfer
to the header you want, e.g.:
Copy code
"attributes_to_headers": { "transfer": "X-Transfer" }
Do you want me to provide a non-async/snippet for your worker or a full example with error handling? Sources: Managing participants | LiveKit docs
c
this is working but when I saw the logs in the livekit dashboards inside the call logs I couldn't find this transfer attribute there.
t
Thanks — that’s expected behavior. Participant attributes (like
transfer
) are stored on the participant object and can be mapped to SIP headers, but they do not automatically appear in the LiveKit dashboard call logs. The dashboard call logs mainly show SIP signaling events and connection states, not arbitrary participant attributes. What you can do to verify and surface the
transfer
attribute: • Confirm the attribute is set before hangup:
Copy code
await ctx.api.room.update_participant(
  request=UpdateParticipantRequest(
    room=ctx.room.name,
    identity=participant_identity,
    attributes={"transfer": "True"}
  )
)
• Read the participant to verify:
Copy code
res = await ctx.api.room.get_participant(
  request=RoomParticipantIdentity(room=ctx.room.name, identity=participant_identity)
)
print(res.participant.attributes)
• Ensure your trunk maps the attribute to the header:
Copy code
"attributes_to_headers": { "transfer": "X-Transfer" }
• Surface it in logs for visibility: log the attribute in your agent/worker when you set it (or use
ctx.log_context_fields
in an agent) so it appears in runtime logs and is easy to correlate with call events. If you’d like, I can give a full agent-worker snippet that sets the attribute, logs it, and then deletes the room. Which runtime are you using (async worker, sync script, or an agent)? Sources: Participant attributes and metadata | LiveKit docs | Log collection | LiveKit Docs | Observability data hooks | LiveKit docs | Job lifecycle | LiveKit docs
c
the identity should be of bot or SIP participaint ?
t
Use the SIP participant’s identity. You must set the
transfer
attribute on the participant that represents the SIP endpoint (the actual call leg). LiveKit maps participant attributes to SIP headers when LiveKit generates outbound SIP messages for that participant. Setting the attribute on a bot or other non-SIP participant will not attach the header to the SIP BYE for the SIP leg. How to confirm: • Read the room’s participants (or call
get_participant
) and find the identity that matches the SIP caller. • Update that participant with
UpdateParticipantRequest(room=..., identity=<sip_identity>, attributes={ "transfer":"True" })
before calling
delete_room
. • Verify with
get_participant
that the attribute is present, and log it from your agent/worker so you can correlate it with the BYE. If you want, paste the participant list or a sample participant identity and I’ll show the exact request to use.
c
how do I know whether the headers are being sent or not with the bye ?
t
Good question — here are concise ways to verify the header is actually sent on the BYE. 1) Confirm participant attribute is set before hangup • Read the SIP participant right before delete:
Copy code
res = await ctx.api.room.get_participant(
  request=RoomParticipantIdentity(room=ctx.room.name, identity=sip_identity)
)
print(res.participant.attributes)
If
transfer
is present and correct, it can be included on outbound SIP requests. 2) Check LiveKit dashboard call logs • The dashboard call logs show SIP signaling events but do not always show every custom header. You may not see
X-Transfer
there even if it is sent. 3) Capture SIP traffic (recommended) • For managed LiveKit: get SIP gateway/trunk provider logs or ask for SIP traces from your SIP provider that show outgoing BYE from LiveKit to the PSTN/SIP peer. • For self-hosted LiveKit: run a packet capture on the SIP gateway network interface and inspect BYE with Wireshark/tcpdump: ◦ tcpdump example: sudo tcpdump -s 0 -A -i <if> port 5060 • In Wireshark filter:
sip.Method == "BYE"
and inspect headers for
X-Transfer
(or your header name). 4) Enable/inspect SIP gateway logs • If you control the SIP gateway (Kamailio/FreeSWITCH/OpenSIPS), enable SIP debug/logging to show outbound requests and headers. 5) Correlate timestamps/identities • Match the BYE you capture with the room/participant identity and timestamp so you confirm the correct call leg. If you want, tell me whether you’re on LiveKit Cloud or self-hosted and which SIP gateway/trunk provider you use — I’ll give exact tcpdump/Wireshark commands or where to request SIP traces from your provider.