Skip to main content

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.

apiKey="<API_KEY>"
curl -L -X GET "https://www.reports.mediahawk.co.uk/rest/v2_0/prefixes?api_key=${apiKey}" \
-H "Accept: application/json" \

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.

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 }'

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.

info

Metadata is optional but recommended in order to group numbers together in useful ways.

Channel

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'" }'

Department

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'" }'

Media owner

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'" }'

Purchase a static number

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" } } }'

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

info

We accept audio in wav, wma, mp3, m4a and aac.

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'"'

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.

info

If routing to a UK destination number, please note we only allow numbers beginning with: '441', '442', '443', '447' or '448'.

info

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.

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 }'