How to attach custom headers to SIP REFER using TransferSIPParticipant

This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.

Does anyone know if we can attach a custom header to SIP REFER using TransferSIPParticipant?

Yes, you can attach custom headers to SIP REFER by including them in the headers parameter:

transfer_request = proto_sip.TransferSIPParticipantRequest(
    participant_identity=participant_identity,
    room_name=room_name,
    transfer_to=transfer_to,
    play_dialtone=True,
    headers={"X-CallStatus": "Transferred", "X-CallerId": agent_did}
)

Hello, I’ve tried replicating this and I’ve tried all combinations but I can’t make it work for TransferSipParticipantRequest. My testing setup is having agent_a execute a transfer to agent_b with the transferSipParticipantRequest and headers, and at the same time have agent_b log the participant attributes. I have the outbound trunk set with SIP_ALL_HEADERS and I can see Telnyx headers, but not the ones I set through the transfer request on agent_a.

However, it does work when creating outbound calls via CreateSIPParticipantRequest.

Any help or workaround would be appreciated.

Thanks!

I wanted to check that the AI summary of this previous issue was not mangled, but the answer given in Slack is pretty much verbatim to the answer above. I can’t link to the original public Slack answer because it falls just outside of the 3 month Slack retention period.

I got in contact with Telnyx and they do not support sending custom headers on the new INVITE they create when they receive a REFER with custom headers. Their response:

‘The response from the internal team is that Teknyx doesn’t pass custom headers on the transferred leg, only the origin and destination numbers are passed.’

I feel this info should be verified and/or updated on the docs for future reference.

Thank you for following up and responding back to this thread. Although I verified that the summary of the original community-provided answer was accurate, I did not validate the answer itself. I have changed the marked solution of this topic to your most recent reply.