Skip to the content

IsValid

Checks if a telephone number is valid.

Live Demo

To connect to this service you'll need to use one of these endpoints:

JSON
Open API
SOAP

Description

Checks a telephone number for validity and formats it in a standard format. Details of the number's validity and other attributes are included in the result.

The telephone number can be supplied as either a full international number with leading + or 00 prefix (e.g. +441513554555) or as a national number (e.g. 01513554555), with or without additional formatting (e.g. spaces, brackets etc.). If a number is supplied as a national number, the default country code is used to identify which country the number is located in. The default country code can be supplied as any of:

  • international telephone dialling code (e.g. 44)
  • ISO 2-character code (e.g. GB)
  • ISO 3-character code (e.g. GBR)
  • ISO standard English country name (e.g United Kingdom)
  • "auto" to detect the country from the user's location (client-side integrations)

If the ValidationResult member of the returned structure is Invalid, the supplied telephone number is invalid and cannot be called. If it is Valid the telephone number is likely to be valid. This does not necessarily mean that the number can be called and is owned by the expected person, but does indicate that the number lies within a range of numbers that have been allocated for use. If it is NoCoverage we cannot provide an indication to it's validity and you should normally treat it as valid.

If you are using this API to prevent invalid telephone numbers in form submissions, we recommend only blocking `Invalid` results and allowing all other status codes.

This service is not appropriate if you require an absolute indication that a telephone number is related to a particular individual. In those circumstances, you should consider the use of a telephone number capture service. However, this service does provide a quick method to check that a number can accept incoming calls.

Wherever possible this method will perform a live check of the telephone network. This will be performed for UK landline numbers and international mobile numbers. The ValidationLevel property in the response will be set to FullNumber if a live check was performed.

UK numbers that start with 070, often referred to as personal numbers, are incredibly difficult to validate with any certainty, due to their private nature. We have created an option you can pass in to the API code, ExcludeUnlikelyNumbers, which will stop the likes of 07000000000 or 07077777777 getting through our validation. Please bear in mind that with this option, you may well exclude a small amount of genuine numbers.

Credit Usage

Each request to this method consumes 1 Phone Validation credit for each request, except where a "NoCoverage" result is returned. US mobile numbers are billed at 2 credits per request if the "IncludeUSStatus" option is set to true, or the default setting to enable this is turned on for your account.

Parameters

The following parameters can be supplied to this method

username

username

See the available authentication methods. If you are using username & password authentication, specify the username to authenticate as. If you are using API Key authentication and you are not using the JSON, Javascript or ADO APIs, use your API Key here with the prefix apikey-, e.g. apikey-ABCD-1234-EFGH-5678
password

password

If you are using username & password authentication, specify the password to use for authentication. Otherwise leave this blank.
telephoneNumber

telephoneNumber

The telephone number to validate

defaultCountry

defaultCountry

The ISO 2-character country code or international dialling code of the country to validate the telephoneNumber in, unless that number contains an explicit country code prefix. Alternatively, use "auto" to detect a country based on the user's location (ideal for client-side integrations - see also the EndUserIPAddress advanced option for server-side code).

options

options

An array of options that control further details of how this method operates. See the Advanced Options section below for more information.

Advanced Options

The following options can be specified as part of the option parameter. Each option is specified as a key/value pair. The list of available names is shown below, along with a description of the allowable values for that name.

Common Options
Name Description
ApplicationName

ApplicationName

Gives the name of the calling application - used to break down usage by application in the usage reports on the dashboard
Service-Specific Options
Name Description
RequiredCountry

RequiredCountry

Indicates the country that the number must be in to be considered valid. This should be provided as the ISO 2-character country code.

AllowedPrefixes

AllowedPrefixes

A comma-separated list of prefixes in standard international format that the number must start with to be treated as valid. For example, use "+441,+442" to allow only standard UK landline numbers.

BarredPrefixes

BarredPrefixes

A comma-separated list of prefixes in standard international format that will cause the number to be treated as invalid. For example, use "+90,+447781" to block any Indian numbers or numbers allocated to C&W Guernsey.

TreatUnavailableMobileAsInvalid

TreatUnavailableMobileAsInvalid

When validating a mobile number and the number is unavailable, this option causes the service to return Invalid as the ValidationResult instead of the default Unavailable. This will cause your calling application to have a stricter level of validation for mobiles, i.e. they must be turned on.

ExcludeUnlikelyNumbers

ExcludeUnlikelyNumbers

If set to true, the service will perform an additional regex check and invalidate any unlikely numbers even if they are technically valid, such as 07000000000 or 01234567890

DefaultFormatType

DefaultFormatType

The format the telephone number should be returned in. This can be one of the following values:

  • International - the number is presented back with full international dialling code
  • National - the number is presented back without the international dialling code but with the full area code
  • Local - the number is presented back with only the local part
DifferentFormatCountries

DifferentFormatCountries

A comma-separated list of country codes (without leading + or 00). Any telephone numbers for these countries will be formatted using the DifferentFormatType format instead of the DefaultFormatType.

DifferentFormatType

DifferentFormatType

The format the telephone number should be returned in if it is from a country listed in DifferentFormatCountries. This can be one of the same set of values as DefaultFormatType.

UseLocalFormatting

UseLocalFormatting

Indicates if telephone numbers should be formatted according to the country-specific rules for its particular country. If this is set to false, numbers are formatted according to ITU international standard formatting.

EndUserIPAddress

EndUserIPAddress

If the defaultCountry parameter is set to "auto", the country will be detected based on the IP address the request is coming from. While this works for client-side integrations, when using the service from server-side code you will need to specify the IP address that the country should be derived from by specifying it in this option. This would typically be taken from the IP address that your client is submitting the data from, and can be obtained from server variables e.g. $_SERVER['REMOTE_HOST'] in PHP.

CustomFormatCountries

CustomFormatCountries

The TelephoneNumber field in the result will be formatted according to our standard country-specific rules. This option allows you to override those formats. Custom formats are specified as a semi-colon separated list of <countrycode>=<format>, where <countrycode> is the international dialling code and <format> is the format to use for telephone numbers in that country.

Formats are specified using the following special characters. Examples show the result of the formatting character based on the input telephone number +441513554555 extension 1234.

Character Description Example
0 The next available digit of the telephone number. This will not include the international dialling code for the country, or the trunk dialling prefix 1
i The international dialling code for the country 44
t The trunk dialling prefix required for long distance calls within the country 0
t The area code of the telephone number. This will not include the trunk dialling prefix 151
l The local part of the telephone number 3554555
x The extension number 1234

Any other characters will be treated as literal strings. The backslash character is used as an escape character, so \i will output i and \\ will output \.

If there are more numbers in the telephone number than are output by the specified format string, the additional numbers will be appended to the result to ensure no data is lost.

IncludeUSStatus

IncludeUSStatus

By default, all North American phone numbers will be validated to ensure the exchange is correct, i.e. all but the final 4 digits. Full number validation is available for US mobile numbers, but due to the costs involved in this process any such numbers are billed at 2 credits per lookup instead of the usual 1. Because of this difference in cost, this is an opt-in process. You can opt-in to this additional validation on a per-request basis using this option, or you can change your default setting on your dashboard.

Results

This method returns an object containing the following fields:

Status

Status

Indicates whether the method call was successful, or if some error occurred. If the Success field is true, the other results described below can be used to get the results of the method. If Success is false, some error occurred in calling the method, such as the authentication failed or the account is out of credits. The details of the error can be obtained from the ErrorMessage field, and any other results should be ignored
Result

Result

Contains properties indicating the validity and other information for the supplied telephone number:

Name Description
TelephoneNumber The supplied telephone number presented in an international standard format
ValidationResult Indicates whether the telephone number is valid or not. The following values are available:
  • Valid - the telephone number is potentially valid
  • Invalid - the telephone number is invalid
  • NoCoverage - we do not have telephone number validation coverage for the required country. You will not be charged for this request
  • Unavailable - the telephone number is a valid mobile number but is currently unavailable - may be turned off or out of network coverage
  • Ambiguous - the telephone number is a potentially valid UK landline number but we receive an ambiguous result from the telephone network when trying to validate it fully

If you are using this API to prevent invalid telephone numbers in form submissions, we recommend only blocking Invalid results and allowing all other status codes.

ValidationLevel Indicates the level to which we have validated the telephone number. The following values are available:
  • None - the number has not been validated
  • STDCode - the number has been validated to the main area code
  • Exchange - the number has been validated to an individual range of numbers; this usually maps to a single telephone exchange
  • FullNumber - the full telephone number has been validated live against the telephone network
NumberType Indicates the type of number. The following values are available:
  • Unknown - the type of telephone number could not be determined
  • Landline - the number is a geographic landline number
  • Mobile - the number is a mobile number
  • NonGeographic - the number is a non-geographic landline number
  • Special - the number is a premium rate or other similar class of special number
Location The physical location associated with the number. This will be blank where a location cannot be determined, e.g. for mobile numbers
Provider The name of the company providing the telephone service. This will normally not reflect the impact of number portability
CountryCode The ISO 2-character code of the country the number is registered in
CountryName The ISO standard name of the country the number is registered in

Live Demo

telephoneNumber
defaultCountry
options
Name Value
Common Options
Service-Specific Options

Sample Code