Age Verification
Validate your data against our UK people data sources
Validate your data against our UK people data sources to see if a record, aged over 18, is found.
If your business sells age restricted items you can use our age verification method to validate your data. This could be used during the eCommerce checkout process or on your CRM system.
This method allows the validation of a UK person, by matching your supplied data to our database of current UK persons.
Your data MUST contain:-
- Surname
- Forename
- UK Postcode
- UK Address(first line)
The method will then attempt to locate the individual in our data. You can control the level of fuzziness that the method will use, by setting a series of parameters.
If a person is found in our data, aged over 18, the method returns a validation status true. We also describe the quality of the match.
If, for example, your data has a record for Ian Whitehead, and our method finds Ian Whithead (note the slight spelling difference) at the same address, we include this element:-
<match_code_surname>FUZZY</match_code_surname>
to indicate that there is a slight spelling difference.
Mandatory Parameters
None of the parameters are case sensitive apart from the api key or javascript key.
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. |
surname |
The surname of the subject. The case is irrelevant. |
forename |
The forename of the subject. |
postcode | The postcode of the subject. Ideally this is the full UK postcode, but the method will check a partial code. If postcode_fuzzy is set to true, it will allow the final character of the postcode to be incorrect.
This can be in any case and any format (such as YO98 9HZ or yo989HZ) |
addr1 | The first line of the address |
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. |
check_under_18 | If set to "true" or "yes" or "y", the method will include persons who are under 18, but will return the status FOUND_UNDER_18 rather than FOUND. If you do not set this parameter, persons under 18 will return the status NOT_FOUND |
addr2 | The second line of the address |
addr3 | The third line of the address |
place | The locality |
town | The postal town |
surname_fuzzy | Set to true (default) to allow a slight fuzzy match. |
forename_fuzzy | Set to true (default) to allow a slight fuzzy match. |
Returned Values
The XML response is contained within a <age_verification_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. |
validation_status |
Set to:-
NOT_FOUND when the person could not be validated. FOUND_UNDER_18 when a person under 18 has been validated FOUND when a person has been validated. TOO_MANY when the search parameters indicates more than one person sharing the full name. If you receive a NOT_FOUND response you could try a previous address, if you have one available. Our data contains current and previous addresses for UK people. |
match_code_surname | Describes how we matched the surname. Possible values:-
|
match_code_forename | Describes how we matched the forename. Possible values:-
|
match_code_address |
Describes how we matched the address. Possible values:-
|
Error Codes
Name |
Description |
---|---|
missing_surname |
Mandatory parameter |
missing_forename |
Mandatory parameter |
missing_addr1 |
Mandatory parameter |
missing_postcode |
Mandatory parameter |
invalid_postcode |
The postcode is not a valid UK postcode.
|
See the common error codes.
Worked Example
Mrs Rowena Stanley
26 Braeside Gardens
York
YO24 4EZ
The free test mode may be accessed by the use of the value test for the api_key. The test mode provides free access to a fictional analogue of our real search engine data.
The fictional person above is provided to enable easy and free integration of our API method.
The address is also fictional, although it is an extrapolation of real streets.
Perfect Match Example
Using these parameters to find our dummy record:-
Parameter | Value |
---|---|
surname | Stanley |
forename | Rowena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 Braeside Gardens |
town | York |
...returned the XML below. Note that the match codes are all FULL for the name and address values.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>3.1.0.1</t2a_version_number> <validation_status>FOUND</validation_status> <match_code_forename>FULL</match_code_forename> <match_code_surname>FULL</match_code_surname> <match_code_address>FULL</match_code_address> <match_code_postcode>FULL</match_code_postcode> </age_verification_res>
Successful Fuzzy Match Example
In this example the forename has been mis-spelt and by default we allow a small degree of fuzziness on the match. The API indicates that a fuzzy match has been made. You can edit the fuzzy matching criteria with the optional input parameters forename_fuzzy and surname_fuzzy (set them to true or false as needed).
Using these parameters to find our dummy record:-
Parameter | Value |
---|---|
surname | Stanley |
forename | Roweena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 |
...returned the XML below. Note that the match code for the forename is FUZZY because of the slight spelling change, and PARTIAL for the address.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>2.2.3.8</t2a_version_number> <validation_status>FOUND</validation_status> <match_code_forename>FUZZY</match_code_forename> <match_code_surname>FULL</match_code_surname> <match_code_address>PARTIAL</match_code_address> <match_code_postcode>FULL</match_code_postcode> </age_verification_res>
Exact Match Failure Example
The forename has been mis-spelt but forename_fuzzy and surname_fuzzy are both set to false.
Using these parameters to simulate an exact match failure
Parameter | Value |
---|---|
forename_fuzzy | false |
surname_fuzzy | false |
surname | Stanley |
forename | Roweena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 Braeside Gardens |
town | York |
...returned the XML below.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>2.2.3.8</t2a_version_number> <validation_status>NOT_FOUND</validation_status> <match_code_forename>NO_MATCH</match_code_forename> <match_code_surname>NO_MATCH</match_code_surname> <match_code_address>NO_MATCH</match_code_address> <match_code_postcode>NO_MATCH</match_code_postcode> </age_verification_res>
Validate your data against our UK people data sources to see if a record, aged over 18, is found.
If your business sells age restricted items you can use our age verification method to validate your data. This could be used during the eCommerce checkout process or on your CRM system.
This method allows the validation of a UK person, by matching your supplied data to our database of current UK persons.
Your data MUST contain:-
- Surname
- Forename
- UK Postcode
- UK Address(first line)
The method will then attempt to locate the individual in our data. You can control the level of fuzziness that the method will use, by setting a series of parameters.
If a person is found in our data, aged over 18, the method returns a validation status true. We also describe the quality of the match.
If, for example, your data has a record for Ian Whitehead, and our method finds Ian Whithead (note the slight spelling difference) at the same address, we include this element:-
<match_code_surname>FUZZY</match_code_surname>
to indicate that there is a slight spelling difference.
Mandatory Parameters
None of the parameters are case sensitive apart from the api key or javascript key.
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. |
surname |
The surname of the subject. The case is irrelevant. |
forename |
The forename of the subject. |
postcode | The postcode of the subject. Ideally this is the full UK postcode, but the method will check a partial code. If postcode_fuzzy is set to true, it will allow the final character of the postcode to be incorrect.
This can be in any case and any format (such as YO98 9HZ or yo989HZ) |
addr1 | The first line of the address |
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. |
check_under_18 | If set to "true" or "yes" or "y", the method will include persons who are under 18, but will return the status FOUND_UNDER_18 rather than FOUND. If you do not set this parameter, persons under 18 will return the status NOT_FOUND |
addr2 | The second line of the address |
addr3 | The third line of the address |
place | The locality |
town | The postal town |
surname_fuzzy | Set to true (default) to allow a slight fuzzy match. |
forename_fuzzy | Set to true (default) to allow a slight fuzzy match. |
Returned Values
The XML response is contained within a <age_verification_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. |
validation_status |
Set to:-
NOT_FOUND when the person could not be validated. FOUND_UNDER_18 when a person under 18 has been validated FOUND when a person has been validated. TOO_MANY when the search parameters indicates more than one person sharing the full name. If you receive a NOT_FOUND response you could try a previous address, if you have one available. Our data contains current and previous addresses for UK people. |
match_code_surname | Describes how we matched the surname. Possible values:-
|
match_code_forename | Describes how we matched the forename. Possible values:-
|
match_code_address |
Describes how we matched the address. Possible values:-
|
Error Codes
Name |
Description |
---|---|
missing_surname |
Mandatory parameter |
missing_forename |
Mandatory parameter |
missing_addr1 |
Mandatory parameter |
missing_postcode |
Mandatory parameter |
invalid_postcode |
The postcode is not a valid UK postcode.
|
See the common error codes.
Worked Example
Mrs Rowena Stanley
26 Braeside Gardens
York
YO24 4EZ
The free test mode may be accessed by the use of the value test for the api_key. The test mode provides free access to a fictional analogue of our real search engine data.
The fictional person above is provided to enable easy and free integration of our API method.
The address is also fictional, although it is an extrapolation of real streets.
Perfect Match Example
Using these parameters to find our dummy record:-
Parameter | Value |
---|---|
surname | Stanley |
forename | Rowena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 Braeside Gardens |
town | York |
...returned the XML below. Note that the match codes are all FULL for the name and address values.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>3.1.0.1</t2a_version_number> <validation_status>FOUND</validation_status> <match_code_forename>FULL</match_code_forename> <match_code_surname>FULL</match_code_surname> <match_code_address>FULL</match_code_address> <match_code_postcode>FULL</match_code_postcode> </age_verification_res>
Successful Fuzzy Match Example
In this example the forename has been mis-spelt and by default we allow a small degree of fuzziness on the match. The API indicates that a fuzzy match has been made. You can edit the fuzzy matching criteria with the optional input parameters forename_fuzzy and surname_fuzzy (set them to true or false as needed).
Using these parameters to find our dummy record:-
Parameter | Value |
---|---|
surname | Stanley |
forename | Roweena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 |
...returned the XML below. Note that the match code for the forename is FUZZY because of the slight spelling change, and PARTIAL for the address.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>2.2.3.8</t2a_version_number> <validation_status>FOUND</validation_status> <match_code_forename>FUZZY</match_code_forename> <match_code_surname>FULL</match_code_surname> <match_code_address>PARTIAL</match_code_address> <match_code_postcode>FULL</match_code_postcode> </age_verification_res>
Exact Match Failure Example
The forename has been mis-spelt but forename_fuzzy and surname_fuzzy are both set to false.
Using these parameters to simulate an exact match failure
Parameter | Value |
---|---|
forename_fuzzy | false |
surname_fuzzy | false |
surname | Stanley |
forename | Roweena |
postcode | YO244EZ (or YO24 4EZ) |
addr1 | 26 Braeside Gardens |
town | York |
...returned the XML below.
<?xml version="1.0"?> <age_verification_res> <mode>normal</mode> <t2a_version_number>2.2.3.8</t2a_version_number> <validation_status>NOT_FOUND</validation_status> <match_code_forename>NO_MATCH</match_code_forename> <match_code_surname>NO_MATCH</match_code_surname> <match_code_address>NO_MATCH</match_code_address> <match_code_postcode>NO_MATCH</match_code_postcode> </age_verification_res>
Description
A facility to bulk age verify a CSV file of people with fully qualified UK addresses
This method allows for the verification of a list of UK persons, in a CSV.
The data must be uploaded to T2A as a csv, containing at least these columns:
- surname and forename (or full name)
- Postcode
- Address Line 1
T2A will append to the CSV a single RESULT column. These are the possible values:-
Result Code | Explanation |
---|---|
FOUND_OVER_18 | The person has been verified |
FOUND_UNDER_18 | The person has been found but not verified as 18 or over. |
NOT_FOUND | The person was not found in our data
If you receive a NOT_FOUND response you could try a previous address, if you have one available. Our data contains current and previous addresses for UK people. |
INVALID_POSTCODE | The supplied postcode was invalid |
INVALID_ADDRESS | The supplied address was invalid |
INSUFFICIENT_DATA | There was insufficient information to be able to validate the person |
Usage
This is an asynchronous method, requiring several stages in the operation.
- Create a job (also known as a transaction). This is a unique item that will be used to upload, process and finally download your data. Create the job using the create command. Please note that this is a free method.
- Upload your csv dataand specify the location of the above columns by using the upload command. This is free.
- Start the process. It runs in the backgroumd.
- Invoke the progress command to monitor the progress of T2A in processing your job. You may wish to display this as a progress bar or similar to your final users. The invocation of this method is normally from JavaScript.When the percentage figure has reached 100, the processing is complete,and you may proceed to the next stage.
- When the process is completed, check the number of records found. This is free
- If you wish to purchase the full result (i.e. the original csv, appended), invoke the finalise command which will prepare the data, deduct the necessary credits, and supply a download URL which can be used to obtain the purchased csv.
Commands
Introduction
The individual operations of this method are selected using the mandatory command
parameter.
Command 'create'
Create a transaction (also known as a job) to be used for your upload, append and download. This is free.
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. |
command | Must be set to create |
Returned Values
The XML response is contained within a <age_verification_bulk_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 |
transaction_id | The ID of the job created. |
t2a_version_number | The current API version number. |
Example XML Response
<?xml version="1.0"?> <age_verification_bulk_res> <mode>normal</mode> <status>ok</status> <t2a_version_number>1.0.0</t2a_version_number> <transaction_id>wKVrW6dhYPMBEA0iQTuJ_u9YQx_L1fOvVqQ1AOboPS_U</transaction_id> </age_verification_bulk_res>
Command 'upload'
Upload your csv data to T2A.
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking via server-side XML or SOAP. If using JSON, generate a JavaScript key using the javascript_key method. |
command | Must be set to upload |
transaction_id | The ID of the job, as created by create. |
type | Must be set to res or bus to denote residential or business data. The data cannot be mixed. |
csv_data | The csv data. If you are using the REST API, you will need to invoke this method as a POST. |
is_first_line_headers | Set to Y if the first lineof the CSV is the column headers. |
is_first_line_headers | Set to Y if the first lineof the CSV is the column headers. |
surname_column | The column containing the surname, as a zero-based integer. |
forename_column | The column containing the forename, as a zero-based integer. |
forename_column | The column containing the forename, as a zero-based integer. |
address1_column | The column containing the first line of the address, as a zero-based integer. |
address2_column | The column containing the second line of the address, as a zero-based integer. |
address3_column | The column containing the third line of the address, as a zero-based integer. |
postcode_column | The column containing the postcode, as a zero-based integer. |
Returned Values
The XML response is contained within a <age_verification_bulk_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 |
t2a_version_number | The current API version number. |
Example XML Response
<?xml version="1.0"?> <age_verification_bulk_res> <mode>normal</mode> <status>ok</status> <t2a_version_number>1.0.0</t2a_version_number> <transaction_id>wKVrW6dhYPMBEA0iQTuJ_u9YQx_L1fOvVqQ1AOboPS_U</transaction_id> </age_verification_bulk_res>
Command 'start'
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking via server-side XML or SOAP. If using JSON, generate a JavaScript key using the javascript_key method. |
command | Must be set to start |
transaction_id | The ID of the job, as created by create |
Returned Values
The XML response is contained within a <age_verification_bulk_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 |
t2a_version_number | The current API version number. |
Example XML Response
<?xml version="1.0"?> <age_verification_bulk_res> <mode>normal</mode> <status>ok</status> <t2a_version_number>1.0.0</t2a_version_number> <transaction_id>wKVrW6dhYPMBEA0iQTuJ_u9YQx_L1fOvVqQ1AOboPS_U</transaction_id> </age_verification_bulk_res>
Command 'progress'
Read the progress of the background processing of the appending. This might often be invoked as a client-side (Javascript) returning JSON.
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking via server-side XML or SOAP. If using JSON, generate a JavaScript key using the javascript_key method. |
command | Must be set to progress |
transaction_id | The ID of the job, as created by create. |
output | Set to json if json is required. |
Returned Values
The XML response is contained within a <age_verification_bulk_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 |
t2a_version_number | The current API version number. |
percentage | The progress. When "100" the job has finished processing and you may proceed to the next stage. |
Example JSON Response
{ "transaction_id":"5nTrnrVDj6Q83GKuq68IdqAQnFcKYKCnoKNsJSVLiRzY", "percentage":"45", "mode":"normal", "status":"ok", "t2a_version_number":"2.2.2.3" }
Command 'results'
View a summary of how many records were verified using the command 'results'.
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking via server-side XML or SOAP. If using JSON, generate a JavaScript key using the javascript_key method. |
command | Must be set to results |
transaction_id | The ID of the job, as created by create. |
Returned Values
The XML response is contained within a <age_verification_bulk_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 |
t2a_version_number | The current API version number. |
total_found | The total number of rows that were able to be verified. |
Example XML Response
<?xml version="1.0"?> <age_verification_bulk_res> <mode>normal</mode> <status>ok</status> <t2a_version_number>3.1.0.6</t2a_version_number> <transaction_id>5nTrnrVDj6Q83GKuq68IdqAQnFcKYKCnoKNsJSVLiRzY</transaction_id> <total_found>183</total_found> </age_verification_bulk_res>
Command 'finalise'
Use this command to commit to purchase the processed results. Providing that you have sufficient T2A credits, the price is deducted from your balance, and you may then download the processed results.
This command can be safely re-invoked; it will only charge once.
The results include the URL by which the processed CSV may be downloaded.
Mandatory Parameters
Name | Description |
---|---|
api_key or javascript_key |
Use your API key if invoking via server-side XML or SOAP. If using JSON, generate a JavaScript key using the javascript_key method. |
command | Must be set to finalise |
transaction_id | The ID of the job, as created by create. |
Optional Parameters
Name | Description |
---|---|
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 <age_verification_bulk_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 |
t2a_version_number | The current API version number. |
credit_used | The number of credits used in order to execute the request. |
download_url | The full URL from which the processed CSV may now be downloaded. |
Example XML Response
<?xml version="1.0"?> <age_verification_bulk_res> <mode>normal</mode> <status>ok</status> <t2a_version_number>1.0.0</t2a_version_number> <transaction_id>wKVrW6dhYPMBEA0iQTuJ_u9YQx_L1fOvVqQ1AOboPS_U</transaction_id> <download_url>https://api.t2a.io/rest/rest.aspx?method=csv_download&job_id=2Kp9vcVWLYoisqKdADJx__3bf1LmVKVKEs6s01qOvZzz</download_url> </age_verification_bulk_res>
Error Codes
See the common error codes. There are no errors which are specific to this method.
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="age-verification-example"> <form class="age-verification-form"> <div class="form-group"> <label for="surname">Surname</label> <input type="text" class="form-control" id="surname" placeholder="Person's surname e.g Fawcett"> </div> <div class="form-group"> <label for="surname">Forename</label> <input type="text" class="form-control" id="forename" placeholder="Person's forename e.g John"> </div> <div class="form-group"> <label for="surname">Postcode</label> <input type="text" class="form-control" id="postcode" placeholder="UK Postcode"> </div> <div class="form-group"> <label for="surname">Address</label> <input type="text" class="form-control" id="addr1" placeholder="UK Address (First line)"> </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>
.age-verification-example, .results { margin: 20px auto; width: 400px; } form.age-verification-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; } p.not_found { font-weight: bold; color: red; } p.found_under_18 { font-weight: bold; color: red; } p.found { font-weight: bold; color: green; }
$(document).ready(function(){ $(".age-verification-form").submit(function(e) { e.preventDefault(); $('.error', $(this)).remove(); var surname = $("#surname"); if(!surname.val()) { errorBefore("Please enter a surname.", surname); } var forename = $("#forename"); if(!forename.val()) { errorBefore("Please enter a forename.", forename); } var postcode = $("#postcode"); if(!postcode.val()) { errorBefore("Please enter a postcode.", postcode); } var addr1 = $("#addr1"); if(!addr1.val()) { errorBefore("Please enter an address.", addr1); } if($('.error', $(this)).length) { $('.error', $(this)).first().next('input').focus(); } else { $.ajax({ url: 'https://api.t2a.io/rest/rest.aspx', dataType: 'json', data: { 'method' : "age_verification", 'api_key' : 'sandbox', 'surname' : surname.val(), 'forename' : forename.val(), 'postcode' : postcode.val(), 'addr1' : addr1.val(), 'check_under_18' : 'true', 'output' : 'json' }, success: function(result){ if(result.validation_status == "NOT_FOUND") { $('#results-output').append('<p class="output not_found">'+forename.val()+' '+surname.val()+' was not found at the specificed address') }; if(result.validation_status == "FOUND_UNDER_18") { $('#results-output').append('<p class="output found_under_18">'+forename.val()+' '+surname.val()+' was found at the specified address, but we cannot confirm they are over 18') }; if(result.validation_status == "FOUND") { $('#results-output').append('<p class="output found">'+forename.val()+' '+surname.val()+' was found at the specified address and is over 18') }; $('.age-verification-example').hide(); $('.results').show(); } }); } }); $('.results-return').on('click', function(e){ e.preventDefault(); $('#results-output').empty(); $('.age-verification-example').show(); $('.results').hide(); }); }); function errorBefore(msg, insertBefore) { $('<p class="error">' + msg + '</p>').insertBefore(insertBefore); }
Javascript key
<div class="age-verification-example"> <form class="age-verification-form"> <div class="form-group"> <label for="surname">Surname</label> <input type="text" class="form-control" id="surname" placeholder="Person's surname e.g Fawcett"> </div> <div class="form-group"> <label for="surname">Forename</label> <input type="text" class="form-control" id="forename" placeholder="Person's forename e.g John"> </div> <div class="form-group"> <label for="surname">Postcode</label> <input type="text" class="form-control" id="postcode" placeholder="UK Postcode"> </div> <div class="form-group"> <label for="surname">Address</label> <input type="text" class="form-control" id="addr1" placeholder="UK Address (First line)"> </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>
.age-verification-example, .results { margin: 20px auto; width: 400px; } form.age-verification-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; } p.not_found { font-weight: bold; color: red; } p.found_under_18 { font-weight: bold; color: red; } p.found { font-weight: bold; color: green; }
$(document).ready(function(){ $(".age-verification-form").submit(function(e) { e.preventDefault(); $('.error', $(this)).remove(); var surname = $("#surname"); if(!surname.val()) { errorBefore("Please enter a surname.", surname); } var forename = $("#forename"); if(!forename.val()) { errorBefore("Please enter a forename.", forename); } var postcode = $("#postcode"); if(!postcode.val()) { errorBefore("Please enter a postcode.", postcode); } var addr1 = $("#addr1"); if(!addr1.val()) { errorBefore("Please enter an address.", addr1); } 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' : "age_verification", 'javascript_key' : result.javascript_key, 'domain' : "t2a.io", 'surname' : surname.val(), 'forename' : forename.val(), 'postcode' : postcode.val(), 'addr1' : addr1.val(), 'check_under_18' : 'true', 'output' : 'json' }, success: function(result){ if(result.validation_status == "NOT_FOUND") { $('#results-output').append('<p class="output not_found">'+forename.val()+' '+surname.val()+' was not found at the specificed address') }; if(result.validation_status == "FOUND_UNDER_18") { $('#results-output').append('<p class="output found_under_18">'+forename.val()+' '+surname.val()+' was found at the specified address, but we cannot confirm they are over 18') }; if(result.validation_status == "FOUND") { $('#results-output').append('<p class="output found">'+forename.val()+' '+surname.val()+' was found at the specified address and is over 18') }; $('.age-verification-example').hide(); $('.results').show(); } }); } } }); } }); $('.results-return').on('click', function(e){ e.preventDefault(); $('#results-output').empty(); $('.age-verification-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; }
Next Steps...
We will give you a unique API key to allow you to test the method using credits on your T2A account. The Demo tab will allow you to test the parameters required and view the result.
If you do not have an account you will first need to sign up
Other related API methods:
OCR ID Checking
See who lives at an address
Search the Electoral Roll (edited version)
Check if a person is deceased
Person Verification - check if someone exists