You can iterate over it Then for the first entry, you can set $ru and $du variables and it will become the main branch For the other do append_branch and set parameters of the branch[-1] accordingly. So you can control branch creation instead of automatically doing it by Kamailio and filter all needed.