RURI Manipulation to add token

Hi to all,

In the dialplan, we are able to add a token to outgoing SIP requests’ RURI?
For instance when we send INVITE to AWS Chime, we have to do something like below:

INVITE sip:+17035550122@;transport=tls;X-chime-join-token=join-token SIP/2.0

as you can see ‘X-chime-join-token’ is added.


I don’t know of a way to add to something to the request URI, however, you could add a new header to the SIP Invite (or modify an existing header) by using the PJSIP_HEADER function and a handler to affect the outbound channel.

For example, this would add the header “X-chime-join-token: join-token” to the SIP invite like this:

exten => _9987.,1,Dial(PJSIP/${EXTEN}@${SIPTRUNK},,b(handler^addheader^1))

exten => addheader,1,Set(PJSIP_HEADER(add,X-chime-join-token)=join-token)

Maybe there is a way to change the Request URI, but I think it is the R-URI is very dependent on the dialog state of the target peer and simply inserting something could break the routing to the target (as mentioned, I do not know!).

Anyway, request URI generation is covered in RFC 3261 here:

PJSIP allows dialing based on URI, that may work:


Do note that ; is for comment so you’d need to escape it in the dialplan by placing \ in front of it.

1 Like

@mlast77 thanks but if you need a separate header, your solution works well, but in this case, we have to put the token into RURI or To, which is not changeable through the PJSIP header func.

I will try the @jcolp solution and update it here.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.