apyhub
Back
▣ DATA VALIDATION

Validate and Format Phone Number API

What it does

The phone validation API checks whether a phone number is valid for its country and returns it in formats you can store and compare. Send phone in E.164 form (with the +) or in national format with an ISO alpha-2 country hint such as GB or BR. You get back valid, the normalized e164 value, national_format, international_format, national_number, calling_code, country_code and the resolved country.

Use this phone number validation API at signup and checkout to catch mistyped numbers before an SMS code or delivery update goes nowhere. The country hint lets users type numbers the way they write them locally, such as 020 7946 0958, while your database keeps one consistent e164 value.

Normalizing to E.164 also makes contact data easier to work with. Deduplicate CRM records where the same person was saved as +44 20 7946 0958 and 020 7946 0958, match inbound calls to customer accounts, and clean phone columns before an import or migration.

Validation here follows each country's numbering rules. It does not contact the carrier or confirm the line is active, so a valid result means a correctly structured number for that country.

For carrier name, line type and time zone, use the Phone Carrier Lookup API. Signup forms usually collect more than a phone number, so pair it with the Email Validation API and the Address Validation API.

POST
Parse & validate a phone number (E.164 + per-country rules).
https://api.eu.apyhub.com/creightonnick0/validate-phone-number

QUICKSTART

GUIDE

Quickstart

Check whether a phone number is valid by sending it in the request body.

curl -X POST "https://api.eu.apyhub.com/creightonnick0/validate-phone-number" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+44 20 7946 0958"}'

What you'll get back

Returns a JSON object with these top-level fields: e164 (string), input (string), valid (boolean), country (string), calling_code (string), country_code (string), national_format (string), national_number (string), and international_format (string).

{
  "e164": "+442079460958",
  "input": "+44 20 7946 0958",
  "valid": true,
  "country": "United Kingdom",
  "calling_code": "44",
  "country_code": "GB",
  "national_format": "020 7946 0958",
  "national_number": "2079460958",
  "international_format": "+44 20 7946 0958"
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
The phone number (E.164 with + , or national format)
ISO alpha-2 country hint (required for national-format numbers)

About this endpoint

What it does

Parses and validates a phone number, returning normalized formatting and country-related details when available. The request accepts a phone number in E.164 or national format, with an optional country hint for national-format inputs.

Request Body

ParameterTypeDescription
phoneStringThe phone number, either in E.164 format with + or in national format.
countryStringISO alpha-2 country hint. Required for national-format numbers.

Response

Returns a JSON object with these top-level fields: e164 string, input string, valid boolean, country string, calling_code string, country_code string, national_format string, national_number string, and international_format string.

ParameterTypeDescription
e164StringThe normalized E.164 representation of the phone number.
inputStringThe input phone number as received.
validBooleanWhether the phone number is valid.
countryStringThe resolved country, if available.
calling_codeStringThe country calling code, if available.
country_codeStringThe country code, if available.
national_formatStringThe national formatting of the phone number, if available.
national_numberStringThe national number portion, if available.
international_formatStringThe international formatting of the phone number, if available.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.