How can we do sip bye with new customer headers
# ask-ai
b
How can we do sip bye with new customer headers
t
Thanks for reaching out, Sam. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about sending a SIP BYE with custom customer headers. You don’t send the BYE yourself — LiveKit will send the SIP BYE for you when you end the call. To include custom headers in that BYE, map participant attributes to SIP headers on your inbound SIP trunk, then set those participant attributes before ending the call. Only attributes mapped in the trunk’s
attributes_to_headers
will be included. Steps to implement this: 1. Configure your inbound trunk’s attributes_to_headers mapping ◦ Map the participant attribute keys to the SIP header names you want in the BYE. Example JSON:
Copy code
{
  "trunk": {
    "name": "My SIP Trunk",
    "numbers": [
      "+15551234567"
    ],
    "attributes_to_headers": {
      "custom.reason": "X-Custom-Reason",
      "custom.value": "X-Custom-Value",
      "five9.route_type": "X-RouteType"
    }
  }
}
1. Set/update the SIP participant’s attributes in the room ◦ Before ending the session, update the participant attributes to the values you want to appear as headers:
Copy code
await job_ctx.api.room.update_participant(
       api.UpdateParticipantRequest(
           room=job_ctx.room.name,
           identity=sip_participant.identity,
           attributes={
               "custom.reason": "completed",
               "custom.value": "success"
           }
       )
   )
1. End the call (LiveKit sends the BYE) ◦ Call
delete_room
(or otherwise terminate the session). LiveKit will send the SIP BYE including the headers mapped from the participant attributes:
Copy code
await job_ctx.api.room.delete_room(
       api.DeleteRoomRequest(room=job_ctx.room.name)
   )
Important notes • You cannot manually craft the BYE through LiveKit; LiveKit handles SIP signaling internally. • Only attributes defined in
attributes_to_headers
will be included as headers in the BYE. • If the caller hangs up first, LiveKit will not include your custom headers in a BYE you intended to send, so ensure your flow sets attributes and initiates the end from the side that triggers LiveKit’s BYE. If you’d like, tell me: • Which SIP headers and attribute names you want to use, and • Whether you need an example for a different language or for configuring a specific SIP provider, and I’ll provide the exact examples you can drop into your setup. Sources: How to do call transfers with Five9 | LiveKit