Get static numbers for marketing campaigns
Static numbers are used where you want to track something offline or where people are calling from a website you are not able to add our tracking code to. For example, a Google Ad extension or phone number on a directory website.
Before you begin this guide, please ensure you have followed the Authenticate guide and have a valid token.
You can download a full working code example for this guide here:
CURL, PHP, Node.js, Python, C#
Get the list of available prefixes
The first thing to do is to get the list of available prefixes that are available to purchase. When adding the number, you will be allocated a number that starts with this prefix.
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
curl -L -X GET "https://www.reports.mediahawk.co.uk/rest/v2_0/prefixes?api_key=${apiKey}" \
-H "Accept: application/json" \
$apiKey = "<API_KEY>";
$client = new Client();
$headers = [
"Accept" => "application/json"
];
$request = new Request("GET", "https://www.reports.mediahawk.co.uk/rest/v2_0/prefixes?api_key=" . $apiKey, $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
import json
from datetime import datetime
apiKey = "<API_KEY>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/prefixes?api_key=" + apiKey
headers = {
"Content-Type": "application/json"
}
httpRequest = requests.Session();
response = httpRequest.request("GET", url, headers=headers)
print(json.dumps(response, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let config = {
method: "get",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/prefixes?api_key=" + apiKey,
headers: {
Accept: "application/json",
},
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
var restClient = new RestClient("https://www.reports.mediahawk.co.uk");
restClient.Timeout = -1;
var request = new RestRequest("/rest/v2_0/prefixes?api_key=" + apiKey, Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
IRestResponse response = restClient.Execute(request);
Console.WriteLine(response.Content);
The response will appear here
Create a campaign
Static numbers are grouped into campaigns. Before we add the number, we need to set up a campaign for the number to belong to.
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
campaignName="<CAMPAIGN_NAME>"
startDate=$(date "+%Y-%m-%d")
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/campaigns?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "name": "'$campaignName'", "start_date": "'$startDate'", "end_date": "", "run_continuously": true }'
$apiKey = "<API_KEY>";
$campaignName = "<CAMPAIGN_NAME>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"name" => $campaignName,
"start_date" => date("Y-m-d"),
"end_date" => "",
"run_continuously" => true,
]);
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/campaigns?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
echo $result->getBody();
import requests
import json
from datetime import datetime
apiKey = "<API_KEY>";
campaignName = "<CAMPAIGN_NAME>";
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/campaigns?api_key=" + apiKey
payload = json.dumps({
"name" : campaignName,
"start_date" : datetime.today().strftime("%Y-%m-%d"),
"end_date" : "",
"run_continuously" : True
})
headers = {
"Content-Type": "application/json"
}
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, headers=headers, data=payload)
campaignResponse = json.loads(response.text)
print(json.dumps(campaignResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let campaignName = "<CAMPAIGN_NAME>";
let data = JSON.stringify({
name: campaignName,
start_date: new Date().toISOString().split("T")[0],
end_date: "",
run_continuously: true,
});
let config = {
method: "post",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/campaigns?api_key=" + apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string campaignName = "<CAMPAIGN_NAME";
var restClient = new RestClient("https://www.reports.mediahawk.co.uk/");
var campaignCreateRequest = new RestRequest("/rest/v2_0/campaigns?api_key=" + apiKey, Method.POST);
campaignCreateRequest.AddHeader("Content-Type", "application/json");
campaignCreateRequest.AddHeader("Accept", "application/json");
campaignCreateRequest.AddJsonBody(
new {
name = campaignName,
start_date = DateTime.Now.ToString("yyyy-MM-dd"),
end_date = "",
run_continuously = true,
}
);
IRestResponse campaignCreateResponse = restClient.Execute(campaignCreateRequest);
var campaignResponseObject = JsonConvert.DeserializeObject<dynamic>(campaignCreateResponse.Content);
Console.WriteLine(campaignResponseObject);
The response will appear here
Set up metadata
In addition to campaigns, numbers can have metadata attached to them which allows users to pivot the data in reports. If we want to attach metadata, we need to create the appropriate values before we add the number.
Metadata is optional but recommended in order to group numbers together in useful ways.
Channel
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
channelName="<CHANNEL_NAME>"
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/channels?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "name": "'$channelName'" }'
$apiKey = "<API_KEY>";
$channelName = "<CHANNEL_NAME>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"name" => $channelName,
]);
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/channels?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
// Print request result
echo $result->getBody();
import requests
import json
apikey = "<API_KEY>"
channelName = "<CHANNEL_NAME>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/channels?api_key=" + apiKey
payload = json.dumps({
"name" : channelName,
})
headers = {
"Content-Type": "application/json"
}
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, headers=headers, data=payload)
channelResponse = json.loads(response.text)
print(json.dumps(channelResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let channelName = "<CHANNEL_NAME>";
let data = JSON.stringify({
name: channelName,
});
let config = {
method: "post",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/channels?api_key=" +
apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string channelName = "<CHANNEL_NAME>";
var client = new RestClient("https://www.reports.mediahawk.co.uk/");
var channelCreateRequest = new RestRequest("/rest/v2_0/metadata/channels?api_key=" + apiKey, Method.POST);
channelCreateRequest.AddHeader("Content-Type", "application/json");
channelCreateRequest.AddHeader("Accept", "application/json");
channelCreateRequest.AddJsonBody(new { name = channelName });
IRestResponse channelCreateResponse = client.Execute(channelCreateRequest);
var channelCreateObject = JsonConvert.DeserializeObject<dynamic>(channelCreateResponse.Content);
Console.WriteLine(channelCreateObject);
The response will appear here
Department
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
departmentName="<DEPARTMENT_NAME>"
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/departments?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "name": "'$departmentName'" }'
$apiKey = "<API_KEY>";
$departmentName = "<DEPARTMENT_NAME>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"name" => $departmentName,
]);
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/departments?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
echo $result->getBody();
import requests
import json
apikey = "<API_KEY>"
departmentName = "<DEPARTMENT_NAME>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/departments?api_key=" + apiKey
payload = json.dumps({
"name" : departmentName
})
headers = {
"Content-Type": "application/json"
}
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, headers=headers, data=payload)
departmentResponse = json.loads(response.text)
print(json.dumps(departmentResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let departmentName = "<DEPARTMENT_NAME>";
let data = JSON.stringify({
name: departmentName,
});
let config = {
method: "post",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/departments?api_key=" +
apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string departmentName = "<DEPARTMENT_NAME>";
var client = new RestClient("https://www.reports.mediahawk.co.uk/");
var departmentCreateRequest = new RestRequest("/rest/v2_0/metadata/departments?api_key=" + apiKey, Method.POST);
departmentCreateRequest.AddHeader("Content-Type", "application/json");
departmentCreateRequest.AddHeader("Accept", "application/json");
departmentCreateRequest.AddJsonBody(new { name = departmentName });
IRestResponse departmentResponse = client.Execute(departmentCreateRequest);
var departmentCreateObject = JsonConvert.DeserializeObject<dynamic>(departmentResponse.Content);
Console.WriteLine(departmentCreateObject);
The response will appear here
Media owner
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
mediaOwnerName="<MEDIA_OWNER>"
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/media_owners?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "name": "'$mediaOwnerName'" }'
$apiKey = "<API_KEY>";
$mediaOwner = "<MEDIA_OWNER>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"name" => $mediaOwner,
]);
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/media_owners?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
echo $result->getBody();
import requests
import json
apiKey = "<API_KEY>"
mediaOwner = "<MEDIA_OWNER>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/media_owners?api_key=" + apiKey
payload = json.dumps({
"name" : mediaOwner,
})
headers = {
"Content-Type": "application/json"
}
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, headers=headers, data=payload)
mediaownerResponse = json.loads(response.text)
print(json.dumps(mediaownerResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let mediaOwner = "<MEDIA_OWNER>";
let data = JSON.stringify({
name: mediaOwner,
});
let config = {
method: "post",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/metadata/media_owners?api_key=" +
apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string mediaOwnerName = "<MEDIA_OWNER>";
var client = new RestClient("https://www.reports.mediahawk.co.uk");
var mediaOwnerCreateRequest = new RestRequest("/rest/v2_0/metadata/media_owners?api_key=" + apiKey, Method.POST);
mediaOwnerCreateRequest.AddHeader("Content-Type", "application/json");
mediaOwnerCreateRequest.AddHeader("Accept", "application/json");
mediaOwnerCreateRequest.AddJsonBody(new { name = mediaOwnerName });
IRestResponse mediaOwnerResponse = client.Execute(mediaOwnerCreateRequest);
var mediaOwnerCreateObject = JsonConvert.DeserializeObject<dynamic>(mediaOwnerResponse.Content);
Console.WriteLine(mediaOwnerCreateObject);
The response will appear here
Purchase a static number
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
prefix="<NUMBER_PREFIX>"
description="<NUMBER_DESCRIPTION>"
startDate=$(date "+%Y-%m-%d")
campaignId="<CAMPAIGN_ID>"
departmentId="<DEPARTMENT_ID>"
channelId="<CHANNEL_ID>"
mediaOwnerId="<MEDIA_OWNER_ID>"
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/numbers?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "prefix": "'$prefix'", "name": "'$description'", "start_date": "'$startDate'", "end_date": "", "run_continuously": true, "campaign_id": '$campaignId', "metadata": { "department_id": '$departmentId', "channel_id": '$channelId', "media_owner_id": '$mediaOwnerId', "cost": { "amount": 10.00, "frequency": "Daily" } } }'
$apiKey = "<API_KEY>";
$prefix = "<NUMBER_PREFIX>";
$description = "<NUMBER_DESCRIPTION>";
$campaignId = "<CAMPAIGN_ID>";
$departmentId = "<DEPARTMENT_ID>";
$channelId = "<CHANNEL_ID>";
$mediaOwnerId = "<MEDIA_OWNER_ID>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"prefix" => $prefix,
"name" => $description,
"start_date" => date("Y-m-d"),
"end_date" => "",
"run_continuously" => true,
"campaign_id" => $campaignId,
"metadata" => [
"department_id" => $departmentId,
"channel_id" => $channelId,
"media_owner_id" => $mediaOwnerId,
"cost" => [
"amount" => 10.00,
"frequency" => "Daily",
],
],
]);
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/numbers?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
echo $result->getBody();
import requests
import json
from datetime import datetime
apiKey = "<API_KEY>"
prefix = "<PREFIX>"
description = "<NUMBER_DESCRIPTION>"
campaignId = "<CAMPAIGN_ID>"
departmentId = "<DEPARTMENT_ID>"
channelId = "<CHANNEL_ID>"
mediaOwnerId = "<MEDIA_OWNER_ID>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/numbers?api_key=" + apiKey
payload = json.dumps({
"prefix": prefix,
"name": description,
"start_date": datetime.today().strftime("%Y-%m-%d"),
"end_date": "",
"run_continuously": True,
"campaign_id": campaignId,
"metadata": {
"department_id": departmentId,
"channel_id": channelId,
"media_owner_id": mediaOwnerId,
"cost": {
"amount": 10.00,
"frequency": "Daily"
}
}
})
headers = {
"Content-Type": "application/json"
}
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, headers=headers, data=payload)
numberResponse = json.loads(response.text)
print(json.dumps(numberResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let prefix = "<PREFIX>";
let description = "<DESCRIPTION>";
let campaignId = "<CAMPAIGN_ID>";
let departmentId = "<DEPARTMENT_ID>";
let channelId = "<CHANNEL_ID>";
let mediaOwnerId = "<MEDIA_OWNER_ID>";
let data = JSON.stringify({
prefix: prefix,
name: description,
start_date: new Date().toISOString().split("T")[0],
end_date: "",
run_continuously: true,
campaign_id: campaignId,
metadata: {
department_id: departmentId,
channel_id: channelId,
media_owner_id: mediaOwnerId,
cost: {
amount: parseFloat("3.33"),
frequency: "Daily",
},
},
});
let config = {
method: "post",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/numbers?api_key=" + apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string prefix = "<PREFIX>";
string numberDescription = "<NUMBER_DESCRIPTION>";
string campaignId = "<CAMPAIGN_ID>";
string departmentId = "<DEPARTMENT_ID>";
string channelId = "<CHANNEL_ID>";
string mediaOwnerId = "<MEDIA_OWNER_ID>";
var client = new RestClient("https://www.reports.mediahawk.co.uk");
var numberCreateRequest = new RestRequest("/rest/v2_0/numbers?api_key=" + apiKey, Method.POST);
numberCreateRequest.AddHeader("Content-Type", "application/json");
numberCreateRequest.AddHeader("Accept", "application/json");
numberCreateRequest.AddJsonBody(JsonConvert.SerializeObject(
new
{
prefix = prefix,
name = numberDescription,
start_date = DateTime.Now.ToString("yyyy-MM-dd"),
end_date = "",
run_continuously = true,
campaign_id = campaignId,
metadata = new
{
department_id = departmentId,
channel_id = channelId,
media_owner_id = mediaOwnerId,
cost = new
{
amount = 10.00,
frequency = "Daily"
}
}
}
));
IRestResponse numberResponse = client.Execute(numberCreateRequest);
var numberCreateObject = JsonConvert.DeserializeObject<dynamic>(numberResponse.Content);
Console.WriteLine(numberCreateObject);
The response will appear here
Once you know the prefix you wish to add, the campaign and the metadata we can go ahead and add the number.
Upload your intro audio
We accept audio in wav, wma, mp3, m4a and aac.
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
pathToFile="<PATH_TO_FILE>"
curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/media?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-F 'file=@"'$pathToFile'"'
$apiKey = "<API_KEY>";
$pathToFile = "<PATH_TO_FILE>";
$client = new Client();
$options = [
"multipart" => [
[
"name" => "file",
"contents" => Utils::tryFopen($pathToFile, "r"),
],
],
];
$request = new Request("POST", "https://www.reports.mediahawk.co.uk/rest/v2_0/media?api_key=" . $apiKey);
$result = $client->sendAsync($request, $options)->wait();
echo $result->getBody();
import requests
import json
apiKey = "<API_KEY>"
pathToFile = "<PATH_TO_FILE>"
fileName = "<FILE_NAME>
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/media?api_key=" + apiKey
payload = json.dumps({
"name" : ""
})
files = [
("file",(fileName, open(pathToFile,"rb"), "audio/mpeg"))
]
# requests client
httpRequest = requests.Session();
response = httpRequest.request("POST", url, files=files)
mediaResponse = json.loads(response.text)
print(json.dumps(mediaResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let FormData = require("form-data");
let fs = require("fs");
let pathToFile = "<PATH_TO_FILE>";
let data = new FormData();
data.append("file", fs.createReadStream(pathToFile));
let config = {
method: "post",
url: "https://www.reports.mediahawk.co.uk/rest/v2_0/media?api_key=" + apiKey,
headers: {
"Content-Type": "multipart/form-data",
Accept: "application/json",
...data.getHeaders(),
},
data: data,
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data, null, " "));
})
.catch(function (error) {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string pathToFile = "<PATH_TO_FILE>";
var client = new RestClient("https://www.reports.mediahawk.co.uk");
var fileName = Path.GetFileName(pathToFile);
var fileUploadRequest = new RestRequest("/rest/v2_0/media?api_key=" + apiKey, Method.POST);
fileUploadRequest.AddFile("file", pathToFile);
fileUploadRequest.AlwaysMultipartFormData = true;
IRestResponse fileUploadtResponse = client.Execute(fileUploadRequest);
var fileUploadCreateObject = JsonConvert.DeserializeObject<dynamic>(fileUploadtResponse.Content);
Console.WriteLine(fileUploadCreateObject);
The response will appear here
Set up routing
The last step in setting up a static number is to set up where you would like it routed to. We will set up a routing that has an intro message that will play to the caller when they ring in.
If routing to a UK destination number, please note we only allow numbers beginning with: '441', '442', '443', '447' or '448'.
To prevent unexpected charges, routing to non-UK destination numbers is restricted by default. Please contact client services at 03332228333 or via email at clientservices@mediahawk.co.uk if you would like this restriction removed.
- CURL
- PHP
- Python
- Node.js
- C#
- Try it out
apiKey="<API_KEY>"
# Numbers in E.164 format with no leading plus (e.g. 44111222333)
staticNumber="<STATIC_NUMBER>"
destinationNumber="<DESTINATION_NUMBER>"
mediaId="<MEDIA_ID>"
curl -L -X PUT "https://www.reports.mediahawk.co.uk/rest/v2_0/routings/${staticNumber}/advanced?api_key=${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{ "routes": [ { "destinations": [ { "number": "'$destinationNumber'" } ] } ], "intro_media_id": "'$mediaId'", "call_recording": true }'
$apiKey = "<API_KEY>";
// Numbers in E.164 format with no leading plus (e.g. 44111222333)
$staticNumber = "<STATIC_NUMBER>";
$destinationNumber = "<DESTINATION_NUMBER>";
$audioId = "<AUDIO_ID>";
$client = new Client();
$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
];
$body = json_encode([
"routes" => [
[
"destinations" => [
[
"number" => $destinationNumber,
],
],
],
],
"intro_media_id" => $audioId,
"call_recording" => true,
]);
$request = new Request("PUT", "https://www.reports.mediahawk.co.uk/rest/v2_0/routings/" . $staticNumber . "/advanced?api_key=" . $apiKey, $headers, $body);
$result = $client->sendAsync($request)->wait()->getBody();
echo $result->getBody();
import requests
import json
apiKey = "<API_KEY>"
# Numbers in E.164 format with no leading plus (e.g. 44111222333)
staticNumber = "<STATIC_NUMBER>"
destinationNumber = "<DESTINATION_NUMBER>"
audioId = "<AUDIO_ID>"
url = "https://www.reports.mediahawk.co.uk/rest/v2_0/routings/"+staticNumber+"/advanced?api_key=" + apiKey
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
}
payload = json.dumps({
"routes": [
{
"destinations": [
{
"number": destinationNumber
}
]
}
],
"intro_media_id": audioId,
"whisper_media_id": audioId,
"call_recording": True
})
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
}
httpRequest = requests.Session();
response = httpRequest.request("PUT", url, headers=headers, data=payload)
connectResponse = json.loads(response.text)
print(json.dumps(connectResponse, indent=2))
const axios = require("axios");
let apiKey = "<API_KEY>";
let audioId = "<AUDIO_ID>";
// Numbers in E.164 format with no leading plus (e.g. 44111222333)
let staticNumber = "<STATIC_NUMBER>";
let destinationNumber = "<DESTINATION_NUMBER>";
let data = JSON.stringify({
routes: [
{
destinations: [
{
number: destinationNumber,
},
],
},
],
intro_media_id: audioId,
call_recording: true,
});
let config = {
method: "put",
url:
"https://www.reports.mediahawk.co.uk/rest/v2_0/routings/" +
staticNumber +
"/advanced?api_key=" +
apiKey,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
data: data,
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, " "));
})
.catch((error) => {
console.log(error);
});
using RestSharp;
using Newtonsoft.Json;
string apiKey = "<API_KEY>";
string audioId = "<AUDIO_ID>";
// Numbers in E.164 format with no leading plus (e.g. 44111222333)
string destinationNumber = "<DESTINATION_NUMBER>";
string staticNumber = "<STATIC_NUMBER>";
var client = new RestClient("https://www.reports.mediahawk.co.uk");
var routingRequest = new RestRequest("/rest/v2_0/routings/"+staticNumber+"/advanced?api_key=" + apiKey, Method.PUT);
routingRequest.AddHeader("Content-Type", "application/json");
routingRequest.AddHeader("Accept", "application/json");
routingRequest.AddJsonBody(JsonConvert.SerializeObject(
new
{
routes = new[]
{
new { destinations = new [] {
new {
number = destinationNumber
}
}
}
},
intro_media_id = audioId,
call_recording = true
}
));
IRestResponse routingResponse = client.Execute(routingRequest);
var routingCreateObject = JsonConvert.DeserializeObject<dynamic>(routingResponse.Content);
Console.WriteLine(routingCreateObject);
The response will appear here