@sergey-safarov gave the solution if you need in in request_route or reply_route. For more, see:
- https://www.kamailio.org/wikidocs/tutorials/faq/main/#sip-message-processing
Further discussion should be done on sr-users@lists.kamailio.org mailing list.
Closing.