# PJSIP: Change the user part of the Contact Header

**URL:** <https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049>\
**Category:** Asterisk Support\
**Created:** [June 17, 2016, 11:50am UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049 "2016-06-17T11:50:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlebrother](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@littlebrother](https://community.asterisk.org/u/littlebrother)\
**Post date:** [June 17, 2016, 11:50am UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/1 "2016-06-17T11:50:09Z")

</div>

Hello,

I try to change the user part of the contact header. I have configured a SIP trunk.  
If I made an outbound call the INVITE message contains always the following contact header sip:asterisk@192.168.40.33.

I have trying some changes in the pjsip.conf but nothing works. I’ve got always the same contact header.

Can I change the user part in the contact header?

Thank a lot!

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [June 17, 2016, 2:33pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/2 "2016-06-17T14:33:26Z")

</div>

The only requirement on Contact headers is that they be recognizable by the entity that sets them and should route the response back to that entity. The user part does not have to represent anything meaningful in the real world.

What is the source of your requirement for semantics beyond those required by the RFCs?

---

<div class="post-metadata">

**Author:** ![littlebrother](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@littlebrother](https://community.asterisk.org/u/littlebrother)\
**Post date:** [June 17, 2016, 7:43pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/3 "2016-06-17T19:43:03Z")

</div>

Hello,

Sorry, I have seen the first post missing the contact header example. Asterisk always includes the following contact header [sip:asterisk@192.168.1.11](mailto:sip:asterisk@192.168.1.11)

I need the possibility to configure the value of the user port.  
Especially I replace the value ‘asterisk’ with the user part of the from header.

For example, a SIP device with the phone number 12345 make an outgoing call to the SIP trunk.  
The INVITE message of the SIP trunk should contains the following contact header [sip:12345@192.168.1.11](mailto:sip:12345@192.168.1.11) instead of [sip:asterisk@192.168.1.11](mailto:sip:asterisk@192.168.1.11).

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [June 17, 2016, 7:54pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/4 "2016-06-17T19:54:25Z")

</div>

There is no valid reason why this should be necessary. As I already said, your device seems to be reading more into the Contact header than it is allowed to read into it.

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [June 17, 2016, 8:09pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/5 "2016-06-17T20:09:31Z")

</div>

As David mentions there should be no reason to do this, and as a result there is no ability to configure or change this without code modifcations.

---

<div class="post-metadata">

**Author:** ![dancms](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@dancms](https://community.asterisk.org/u/dancms)\
**Post date:** [December 6, 2017, 4:50pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/6 "2017-12-06T16:50:00Z")

</div>

Does that mean there is not a way to change the hardset ‘asterisk’ to some other value?

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [December 6, 2017, 4:53pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/7 "2017-12-06T16:53:27Z")

</div>

I don’t believe we’ve added a way to set such a thing, no. If we did it would be mentioned in the documentation for the pjsip.conf configuration.

---

<div class="post-metadata">

**Author:** ![dancms](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@dancms](https://community.asterisk.org/u/dancms)\
**Post date:** [December 6, 2017, 4:56pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/8 "2017-12-06T16:56:12Z")

</div>

Would you happen to know where this is set in source code?

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [December 6, 2017, 4:57pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/9 "2017-12-06T16:57:58Z")

</div>

It would start from ast\_sip\_create\_dialog\_uac in res\_pjsip.c and trickle down from there. I don’t know precisely where.

---

<div class="post-metadata">

**Author:** ![dancms](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@dancms](https://community.asterisk.org/u/dancms)\
**Post date:** [December 6, 2017, 5:00pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/10 "2017-12-06T17:00:58Z")

</div>

ok, thanks! I will try and locate.

---

<div class="post-metadata">

**Author:** ![dancms](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@dancms](https://community.asterisk.org/u/dancms)\
**Post date:** [December 6, 2017, 5:15pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/11 "2017-12-06T17:15:25Z")

</div>

This seams like what I’m after, I may be mistaken though, I tried setting and doesn’t seam to change anything. Do you know what this does?

```
			<configOption name="contact_user" default="">
				<synopsis>Force the user on the outgoing Contact header to this value.</synopsis>
				<description><para>
					On outbound requests, force the user portion of the Contact header to this value.
				</para></description>
			</configOption>
```

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [December 6, 2017, 5:19pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/12 "2017-12-06T17:19:13Z")

</div>

It appears to set the Contact user as documented, at least from looking at the code which is also in res\_pjsip.c. I don’t know anything else about it.

---

<div class="post-metadata">

**Author:** ![dancms](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@dancms](https://community.asterisk.org/u/dancms)\
**Post date:** [December 6, 2017, 6:32pm UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/13 "2017-12-06T18:32:43Z")

</div>

Not sure what I miss-typed the first time, but this does work and changes the default ‘asterisk’ to the the value set.

Thanks,

---

<div class="post-metadata">

**Author:** ![dovi5988](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/dovi5988/32/7320_2.png) [@dovi5988](https://community.asterisk.org/u/dovi5988)\
**Post date:** [November 25, 2020, 11:10am UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/14 "2020-11-25T11:10:30Z")

</div>

Are you setting this in pjsip.conf or in the dialplan? We have a requirement from a carrier to dynamically set the contact for calls and I was looking for a way to do this.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [November 25, 2020, 11:17am UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/15 "2020-11-25T11:17:30Z")

</div>

I’d go with a supplier that implements SIP. The user part of the contact has no meaning to anything except the system that sent the Contact header. Often it doesn’t even have a meaning t that system.

---

<div class="post-metadata">

**Author:** ![53rg10](https://avatars.discourse-cdn.com/v4/letter/5/df705f/32.png) [@53rg10](https://community.asterisk.org/u/53rg10)\
**Post date:** [February 13, 2022, 8:45am UTC](https://community.asterisk.org/t/pjsip-change-the-user-part-of-the-contact-header/67049/16 "2022-02-13T08:45:17Z")

</div>

For anyone wondering about this today it’s well documented.

;[mytrunk]  
;type=registration  
;contact\_user=1234567890 ; On outgoing requests, force the user portion of the Contact  
; header to this value (default: “”)

;[endpoint]  
;contact\_user=1234567890 ; On outgoing requests, force the user portion of the Contact  
; header to this value (default: “”)
