Skip to the content

FormatTelephoneNumber

Converts a telephone number to its standard format

Live Demo

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

JSON
Open API
SOAP

Description

The service returns the telephone number formatted according to a number of options as described below. The default combination of these options means that input telephone numbers are treated as UK unless they include a country code, and UK numbers are formatted using national dialling rules (e.g. 0151 355 4555) while all other countries are formatted using international dialling rules (e.g. +1 800 555 1234).

The functionality of this service is included in the PhoneValidation service. If you need to validate and format a telephone number, you can do both in one API call with that service.

Credit Usage

Each request to this method consumes 1 TelephoneFormatting credit.

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.
number

number

The telephone number to reformat

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
DefaultCountryCode

DefaultCountryCode

The country code (without leading + or 00) that telephone numbers are assumed to be from if no country code is included in the input telephone number.

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.

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
FormattedNumber

FormattedNumber

Contains the formatted version of the supplied number

Live Demo

number
options
Name Value
Common Options
Service-Specific Options

Sample Code