SIP headers (also called SIP fields) are part of every HTTP request made by an outbound call. They can convey message attributes to ensure that information packets travel along the correct path between devices on different networks.
SIP headers are categorized into four main types: record-route headers, route headers, via headers, and contact headers. They always have the format
<header_name>:<value>
Plivo SIP headers are always prefixed with X-PH-
. Only characters [A-Z], [a-z], and [0-9] are allowed as part of either a SIP header name or value to ensure that you can encode them in a URL. You can use multiple header fields by entering them as a comma-separated list:
head1=val1,head2=val2,head3=val3,...,headn=valn
You can use custom SIP headers to pass information (such as customer ID or product information) from a front-end application to a back-end application and vice versa.
If you’re using a SIP endpoint and you’ve configured it to send custom SIP headers, Plivo will send the SIP headers with your HTTP request.
You can pass custom SIP headers either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.
You can create and deploy a PHLO to make an outbound call with custom SIP headers with a few clicks on the PHLO canvas.
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first PHLO, follow our instructions to set up a .NET development environment.
To create a PHLO, visit the PHLO page of the Plivo console. If this is your first PHLO, the PHLO page will be empty.
Your PHLO is now ready to test.
You integrate a PHLO into your application workflow by making an API request to trigger the PHLO with the required payload — the set of parameters you pass to the PHLO. You can define a static payload by specifying values when you create the PHLO, or define a dynamic payload by passing values through parameters when you trigger the PHLO from your application.
In either case, you need your Auth ID and Auth Token, which you can get from the overview page of the Plivo console.
When you configure values when creating the PHLO, they act as a static payload.
In Visual Studio, in the CS project, open the file Program.cs
and paste into it this code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using Plivo;
namespace test_PHLO
{
class Program
{
public static void Main(string[] args)
{
var phloClient = new PhloApi("<auth_id>", "<auth_token>");
var phloID = "<phlo_id>";
var phlo = phloClient.Phlo.Get(phloID);
Console.WriteLine(phlo.Run());
}
}
}
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console.
To use dynamic values for the parameters, use Liquid templating parameters when you create the PHLO and pass the values from your code when you trigger it.
In Visual Studio, in the CS project, open the file Program.cs
and paste into it this code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using Plivo;
namespace test_PHLO
{
class Program
{
public static void Main(string[] args)
{
var phloClient = new PhloApi("<auth_id>", "<auth_token>");
var phloID = "<phlo_id>";
var phlo = phloClient.Phlo.Get(phloID);
var data = new Dictionary<string, object>
{
{ "from", "<caller_id>" },
{ "to", "<destination_number>" }
};
Console.WriteLine(phlo.Run(data));
}
}
}
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phlo_id placeholder with your PHLO ID from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234).
Save the file and run it.
Here’s how to use Plivo APIs and XML to make an outbound call with custom SIP headers.
Plivo requests an answer URL when the call is answered (step 4) and expects the file at that address to hold a valid XML response from the application with instructions on how to handle the call. To see how this works, you can use https://s3.amazonaws.com/static.plivo.com/answer.xml as an answer URL to test your first outgoing call. The file contains this XML code:
<Response>
<Speak>Congratulations! You've made your first outbound call!</Speak>
</Response>
This code instructs Plivo to say, “Congratulations! You’ve made your first outbound call!” to the call recipient. You can find the entire list of valid Plivo XML verbs in our XML Reference documentation.
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a .NET development environment.
Open the file in the CS project called Program.cs
and paste into it this code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("<auth_id>","<auth_token>");
try
{
var response = api.Call.Create(
to:new List<String>{"<destination_number>"},
from:"<caller_id>",
answerMethod:"GET",
answerUrl:"https://s3.amazonaws.com/static.plivo.com/answer.xml",
sipHeaders: "customer=johndoe"
);
Console.WriteLine(response);
}
catch (PlivoRestException e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
}
Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234). Destination_number may also be a SIP endpoint, in which case the destination_number placeholder must be a valid SIP URI — for example, sip:john1234@phone.plivo.com.
Save the file and run it.
(201, {
u'message': u'call fired',
u'request_uuid': u'85b1d45d-bc12-47f5-89c7-ae4a2c5d5713',
u'api_id': u'ad0e27a8-9008-11e4-b932-22000ac50fac'
}
)
The SIP header can be seen as a query parameter in the answer_url
/answer.xml?Direction=outbound&From=1111111111&ALegUUID=5260e820-958c-11e4-b6bf-498d468c930b&BillRate=0.00300&
To=sip%3Aabcd150105094929%40phone.plivo.com&<mark>X-PH-Test=Sample</mark>&CallUUID=5260e820-958c-11e4-b6bf-498d468c930b&ALegRequestUUID=2202d0ab-a890-4199-8582-e7a2615cb23b&
RequestUUID=2202d0ab-a890-4199-8582-e7a2615cb23b&SIP-H-To=%3Csip%3Aabcd150105094929%40phone.plivo.com%3E%3Btag%3D6U9J4.uVHI7KyEKSgD8vrPnAKQoR2QXc&
CallStatus=in-progress&Event=StartApp