Data8 Logo

DescriptionEndpoint URLsParametersAdvanced OptionsResultsCredit UsageSample CodeLive Demo
FormatTelephoneNumber
Converts a telephone number to its standard format.
Description

Converts a telephone number to its standard format.

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.

Endpoint URLs

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

Protocol URL
JSON
JSON
https://webservices.data-8.co.uk/TelephoneFormatting/FormatTelephoneNumber.json
OPEN API
OPEN API
https://webservices.data-8.co.uk/swagger/TelephoneFormatting/swagger.json
SOAP
SOAP
https://webservices.data-8.co.uk/telephoneformatting.asmx
Parameters
The following parameters can be supplied to this method:
Name Description
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.
Name Description
Common Options
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
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:
Name Description
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

Credit Usage

Each request to this method consumes 1 TelephoneFormatting credit.

Sample Code

Request Format

{
  "number": "0044 151-3554555",
  "options": {
    "DefaultCountryCode": 44,
    "DefaultFormatType": "International",
    "DifferentFormatCountries": 44,
    "DifferentFormatType": "National",
    "UseLocalFormatting": true
  }
}

Response Format

{
  "Status": {
    "Success": true,
    "CreditsRemaining": 1000
  },
  "FormattedNumber": "0151 355 4555"
}

Depending on your chosen authentication method you will need to modify this request slightly:

API Key

Post the request to
https://webservices.data-8.co.uk/TelephoneFormatting/FormatTelephoneNumber.json?key=your-api-key
and do NOT include the username or password properties in the request JSON document.
Read More

Username and Password

Post the request to
https://webservices.data-8.co.uk/TelephoneFormatting/FormatTelephoneNumber.json
and include username and password properties in the request JSON document.
Do not use for client-side requests!
Read More

JWT Token

Obtain a JWT token for your user and post the request to
https://webservices.data-8.co.uk/TelephoneFormatting/FormatTelephoneNumber.json
Include the JWT token in the request headers as:
Authorization: Bearer your-jwt-token
Read More
Live Demo
Parameter Value
Parameters
number
number
Common Options
ApplicationName
ApplicationName
Service-Specific Options
DefaultCountryCode
DefaultCountryCode
DefaultFormatType
DefaultFormatType
DifferentFormatCountries
DifferentFormatCountries
DifferentFormatType
DifferentFormatType
UseLocalFormatting
UseLocalFormatting
Credits Remaining Today: 5
Try It Now!
An error has occurred. This application may no longer respond until reloaded. Reload 🗙