A SIP INVITE is a SIP request message that initiates a SIP call.
A SIP INVITE is made up of lines of text. The first line in an INVITE is called a Request-Line, which is followed by more lines of text called "headers". The headers contain information about the INVITE, such as the identity of the caller, whether the INVITE was forwarded before being sent to the recipient, and the number of times a call may be forwarded.
Below is an example of a SIP INVITE request message, which includes some commonly-used SIP INVITE headers.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
In the INVITE above, you can see several examples of what are called SIP URIs that look like email addresses. A SIP URI identifies a users' contact information by indicating a specific user at a specific host/domain. A SIP URI could be an identifier for a specific person, a voice mailbox, a group within an organization (like "sales" or "marketing"), etc.
sip:+14155552222@example.pstn.twilio.com
The parts of a SIP URI are described below.
The user is a phone number, word, or username that sits between the sip:
and the @
in a SIP URI.
sip:+14155552222@example.pstn.twilio.com
sip:sales@example.pstn.twilio.com
sip:maria.hernandez@example.pstn.twilio.com
The host or domain follows the @
in a SIP URI and can be a domain or IP address.
sip:+14155552222@example.pstn.twilio.com
sip:+14155552222@192.168.10.10
A SIP URI can also contain a port number. It is written after a :
following the host. If no port is included in the SIP URI, the default SIP port 5060
is used.
A SIP INVITE is a type of SIP request. The first line in any SIP request is called the Request-Line.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The Request-Line contains three parts:
The Request-URI is the contact information for the recipient of the SIP INVITE. It is found within the Request-Line of the INVITE.
The Request-URI: INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.0
The Request-URI User: INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.0
The Request-URI Host: INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.0
SIP headers contain information about the SIP message.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The SIP headers in a SIP request follow the Request-Line.
A SIP header has a name and a value. The header name is before the colon (:
), the header value is what follows the colon. For the header on line 7 above, the header would be called the "CSeq header", and value of the CSeq header is 1 INVITE
.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
This header field describes the transport used for the transaction (SIP/2.0/UDP
) and identifies where responses should be sent (to 192.168.10.10
on port 5060
). The branch
parameter is a unique value used to identify the transaction that is created by the SIP request.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
This header limits the number of hops a request can make on the way to its destination. The value is an integer that decreases by one at each hop. If the value of the Max-Forwards header reaches 0 before the SIP request reaches its destination, the request will be rejected with a 483 error (Too Many Hops).
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The To header contains the contact information for the called party (the recipient of the SIP INVITE).
To display name: To: "Bob" <sip:+14155552222@example.pstn.twilio.com>
To URI: To: "Bob" <sip:+14155552222@example.pstn.twilio.com>
To user: To: "Bob" <sip:+14155552222@example.pstn.twilio.com>
To host: To: "Bob" <sip:+14155552222@example.pstn.twilio.com>
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The From header contains the contact information for the party that initiated the SIP INVITE.
From display name: From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=1
From URI: From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=1
From user: From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=1
From host: From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=1
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The Call-ID header acts as a unique identifier that helps group a series of messages together. It must be the same for all requests and responses sent by either party in a dialog (an exchange of related messages between two user-agents). The value should be a cryptographically random group of characters, and can be followed by @
and a host/domain.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The CSeq header serves as a way to identify and order transactions. It is made up of an integer and a SIP method.
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The Contact header provides a SIP or SIPS URI that should be used to contact the user agent that sent the INVITE.
Contact display name: Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>
Contact URI: Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>
Contact user: Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>
Contact host: Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The Diversion header contains information about any re-directing/forwarding the call has undergone. It includes the contact information for the party that forwarded the call.
Diversion display name: Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>
Diversion URI: Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>
Diversion user: Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>
Diversion host: Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>
1INVITE sip:+14155552222@example.pstn.twilio.com SIP/2.02Via: SIP/2.0/UDP 192.168.10.10:5060;branch=z9hG4bK776asdhds3Max-Forwards: 704To: "Bob" <sip:+14155552222@example.pstn.twilio.com>5From: "Alice" <sip:+14155551111@example.pstn.twilio.com>;tag=16Call-ID: a84b4c76e667107CSeq: 1 INVITE8Contact: "Alice" <sip:+14155551111@192.168.10.10:5060>9Diversion: "Sales" <sip:+14155550000@example.pstn.twilio.com>10P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>11Content-Length: 0
The P-Asserted-Identity header contains the Caller ID information for the call that was authenticated in some way. This header may be used when forwarding calls within trusted domains, in order to maintain the original caller's caller ID rather than the forwarding entity's.
P-Asserted-Identity display name: P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Asserted-Identity URI: P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Asserted-Identity user: P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Asserted-Identity host: P-Asserted-Identity: "Alice" <sip:+14155551111@example.pstn.twilio.com>
Remote-Party-Id: “Alice” <sip:+14155551111@example.pstn.twilio.com>
The Remote-Party-Id (RPID) header identifies the originator of the call.
Remote-Party-Id (RPID) display name: Remote-Party-Id: "Alice" <sip:+14155551111@example.pstn.twilio.com>
Remote-Party-Id (RPID) URI: Remote-Party-Id: "Alice" <sip:+14155551111@example.pstn.twilio.com>
Remote-Party-Id (RPID) user: Remote-Party-Id: "Alice" <sip:+14155551111@example.pstn.twilio.com>
Remote-Party-Id (RPID) host: Remote-Party-Id: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Charge-Info: “Alice” <sip:+14155551111@example.pstn.twilio.com>
The P-Charge-Info header contains information about the identity of the party to be charged.
P-Charge-Info display name: P-Charge-Info: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Charge-Info URI: P-Charge-Info: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Charge-Info user: P-Charge-Info: "Alice" <sip:+14155551111@example.pstn.twilio.com>
P-Charge-Info host: P-Charge-Info: "Alice" <sip:+14155551111@example.pstn.twilio.com>