Check a phone number against TPS
Check a telephone number against both the TPS and CTPS registers.
The Telephone Preference Service (TPS) and Company Telephone Preference Service (CTPS) are lists of UK telephone numbers that have been registered as not wishing to receive unsolicited sales and marketing calls.
Telemarketing agencies, as well as companies’ sales and marketing departments, must abide by these rules or they could face fines of up to £5,000 for calling a single TPS or CTPS registered number. Using our service to check your phone numbers against regularly updated TPS and CTPS data ensures that your company is being compliant when making telemarketing calls.
API method to use: tps_full
We also offer checking telephone numbers in bulk against the TPS or CTPS data. This service is ideal for integrating into a company CRM system or other business application, allowing you to regularly clean your customer data so that you are compliant at all times. See our Bulk TPS checking service for more details.
How it works
The telephone number provided is matched against both the TPS and CTPS registered data, with the method then returning a result that either it is, or is not, ok to call the telephone number.
Please see the Documentation section for more information including a list of mandatory and optional parameters, with returned values.
TPS checking demo
A demo of the tps_full method can be found in the Demo section. Alternatively, you can see T2A tps checking in action on ukphonebook.com.
Checks a telephone number against both the domestic and business Telephone Preference Scheme (TPS and CTPS) lists to ensure that the number is not registered with either scheme and may be freely called for marketing purposes.
Together, the TPS and CTPS registers make up a list of all residential and business numbers that are not to be called by telemarketers making unsolicited marketing calls. Fines of up to £5,000 can be faced for calling a single TPS or CTPS registered number.
We recommend checking against both registers as occasionally a telephone number may be found in the "incorrect" register, for example in the case of self employed individuals.
Integrating this service into your website or business application ensures you are maintaining the highest levels of both TPS and CTPS compliance. You can check your call lists against both the TPS and CTPS registers to ensure any numbers you are planning to call do not appear on either register. Alternatively, you can check single numbers for more specific purposes.
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking server-side. If invoking from the browser via JavaScript, generate a JavaScript key using the javascript_key method. |
telephone_number | Enter a UK telephone number. This can include spaces, brackets etc. |
Optional Parameters
Name | Description |
---|---|
client | You can optionally include an identifier for your final client or user. This is logged in your usage log and you will be able to view your usage statistics by client. |
output | Set to json for a JSON response; the default response is XML.
Not applicable to the SOAP API. |
callback | When using JSON, specify a JSONP wrapper in which the JSON response is to be wrapped. |
Returned Values
The XML response is contained within a <tps_full_res>
element.
Name | Description |
---|---|
status | Returns ok if the operation has succeeded, or error if an
error has occurred; Returns the error_code for error details. |
error_code | Returns the error code when the status is error . See below for error codes. |
t2a_version_number | The current API version number. |
credit_used | The number of credits used in order to execute the request. |
mode | Returns normal or test when executed in the
free test mode. |
tps_status | call if the number is NOT in the TPS (the domestic) register; no_call
if the number IS in the TPS register. |
ctps_status | call if the number is NOT in the CTPS (the business) register; no_call
if the number IS in the CTPS register. |
Error Codes
Name |
Description |
---|---|
missing_telephone_number |
\ Mandatory parameter. |
invalid_telephone_number |
The telephone number is invalid |
See the common error codes.
Free Test Mode
When operating in the free test mode errors are returned if mandatory parameters are missing, or it returns a dummy data response, in an identical format to a real response.
Note that the mode
is returned as test
when the method is operating in the free test mode.
Example XML Response
<tps_full_res> <mode>test</mode> <status>ok</status> <credit_used>0</credit_used> <t2a_version_number>3.3.8.0</t2a_version_number> <tps_status>no_call</tps_status> <ctps_status>no_call</ctps_status> <telephone_number>(0000) 000000</telephone_number> </tps_full_res>
There are two ways to authenticate your application with the T2A API. The two implementation examples on this page cover each type of authentication
We recommend using an API key for internal applications and the javascript key for public facing applications where you would want to protect your API key.
Please note: The examples below run on a sandbox environment which return sample data. To quality check the data we provide, up to 3 free searches are available in the demo tab with results showing live [REDACTED] data.
API key
<div class="tps-example"> <form class="tps-form"> <div class="form-group"> <label for="surname">Phone Number</label> <input type="text" class="form-control" id="telephone_number" placeholder="Enter a phone number"> </div> <button type="submit" class="btn example-submit">Submit</button> </form> </div> <div class="results"> <div id="results-output"></div> <a class="results-return" href="#">Back to search</a> </div>
.tps-example, .results { margin: 20px auto; width: 400px; } form.tps-form, .results { background-color: #F6F6F6; border: 1px solid #CBCBCB; padding: 15px; } .example-submit { background-color: #F0614C; border-radius: 2px; font-size: 11px; font-weight: 400; color: #fff; text-transform: uppercase; letter-spacing: 0.193em; width: 138px; height: 41px; margin-top: 10px; } .results { display: none; } .results-return { font-weight: 600; color: #F0614C; } #results-output span { font-weight: bold; text-transform: capitalize; } #results-output hr { border-top: 1px solid #000; } .error { font-size: 11px; color: #f00; }
$(document).ready(function(){ $(".tps-form").submit(function(e) { e.preventDefault(); $('.error', $(this)).remove(); var telephone_number = $("#telephone_number"); if(!telephone_number.val()) { errorBefore("Please enter a phone number.", telephone_number); } if($('.error', $(this)).length) { $('.error', $(this)).first().next('input').focus(); } else { $.ajax({ url: 'https://api.t2a.io/rest/rest.aspx', dataType: 'json', data: { 'method' : "tps", 'api_key' : 'sandbox', 'telephone_number' : telephone_number.val(), 'output' : 'json' }, success: function(result){ if(result.status == "error") { $('#results-output').append('<p class="output"><strong>Error:</strong>' + result.error_code +'</p>'); } else { $('#results-output').append('<p class="output"><span>Telephone Number:</span> ' + result.telephone_number + '</p>'); $('#results-output').append('<p class="output"><span>TPS Status:</span> ' + result.tps_status + '</p>'); $('#results-output').append('<p class="output"><span>CTPS Status:</span> ' + result.ctps_status + '</p>'); } $('.tps-example').hide(); $('.results').show(); } }); } }); $('.results-return').on('click', function(e){ e.preventDefault(); $('#results-output').empty(); $('.tps-example').show(); $('.results').hide(); }); }); function errorBefore(msg, insertBefore) { $('<p class="error">' + msg + '</p>').insertBefore(insertBefore); }
Javascript key
<div class="tps-example"> <form class="tps-form"> <div class="form-group"> <label for="surname">Phone Number</label> <input type="text" class="form-control" id="telephone_number" placeholder="Enter a phone number"> </div> <button type="submit" class="btn example-submit">Submit</button> </form> </div> <div class="results"> <div id="results-output"></div> <a class="results-return" href="#">Back to search</a> </div>
.tps-example, .results { margin: 20px auto; width: 400px; } form.tps-form, .results { background-color: #F6F6F6; border: 1px solid #CBCBCB; padding: 15px; } .example-submit { background-color: #F0614C; border-radius: 2px; font-size: 11px; font-weight: 400; color: #fff; text-transform: uppercase; letter-spacing: 0.193em; width: 138px; height: 41px; margin-top: 10px; } .results { display: none; } .results-return { font-weight: 600; color: #F0614C; } #results-output span { font-weight: bold; text-transform: capitalize; } #results-output hr { border-top: 1px solid #000; } .error { font-size: 11px; color: #f00; }
$(document).ready(function(){ $(".tps-form").submit(function(e) { e.preventDefault(); $('.error', $(this)).remove(); var telephone_number = $("#telephone_number"); if(!telephone_number.val()) { errorBefore("Please enter a phone number.", telephone_number); } if($('.error', $(this)).length) { $('.error', $(this)).first().next('input').focus(); } else { $.ajax({ url: 'https://t2a.io/ajax/getExampleJSKey', dataType: 'json', success: function (result) { if (result.status) { $.ajax({ url: 'https://api.t2a.io/rest/rest.aspx', dataType: 'json', data: { 'method' : "", 'javascript_key' : result.javascript_key, 'domain' : "t2a.io", 'telephone_number' : telephone_number.val(), 'output' : 'json' }, success: function(result){ if(result.status == "error") { $('#results-output').append('<p class="output"><strong>Error:</strong>' + result.error_code +'</p>'); } else { $('#results-output').append('<p class="output"><span>Telephone Number:</span> ' + result.telephone_number + '</p>'); $('#results-output').append('<p class="output"><span>TPS Status:</span> ' + result.tps_status + '</p>'); $('#results-output').append('<p class="output"><span>CTPS Status:</span> ' + result.ctps_status + '</p>'); } $('.tps-example').hide(); $('.results').show(); } }); } } }); } }); $('.results-return').on('click', function(e){ e.preventDefault(); $('#results-output').empty(); $('.tps-example').show(); $('.results').hide(); }); }); function errorBefore(msg, insertBefore) { $('<p class="error">' + msg + '</p>').insertBefore(insertBefore); }
This example first needs to call to a file on your server, which will provide the user with an API key from your javascript key.
In our example above we have used a PHP file located at ajax/getExampleJSKey
which looks like the example below
<?php $url = 'https://api.t2a.io/rest/rest.aspx' . "?method=javascript_key" . "&api_key=sandbox" . . "&domain=" . $_SERVER['HTTP_HOST']; . '&ip_address=' . get_user_ip() . "&lifetime_minutes=10"; $result = simplexml_load_file($url); if ($result->javascript_key) { echo (string)$result->javascript_key; }