Phone Number Validator API
Validate and format phone numbers for 240+ countries: E.164, international and national formats, country, calling code and line type (mobile, fixed line…).
The Phone API parses a phone number written in any common way – with spaces, dashes, brackets, a leading 0 or a +country code – and tells you whether it is valid and possible for its country. It returns the detected country and name, the calling code, the national number and the number in four formats: E.164 (+84912345678), international, national and an RFC 3966 tel: URI.
It also detects the line type when the numbering plan allows it: MOBILE, FIXED_LINE, FIXED_LINE_OR_MOBILE, TOLL_FREE, PREMIUM_RATE, VOIP, SHARED_COST, PERSONAL_NUMBER, PAGER, UAN or VOICEMAIL. Validation uses the full metadata of Google’s libphonenumber (via libphonenumber-js), covering more than 240 countries and territories.
For numbers without a +country prefix, pass the ISO country code in country (e.g. VN, US); otherwise the caller’s country detected by Cloudflare is used, falling back to US. Unparseable input returns valid: false with a reason instead of an HTTP error.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
number | body|query | string | yes | Phone number in any common format (max 64 characters). | |
country | body|query | string | no | ISO 3166 country code for numbers without +prefix. Default: caller’s country, else US. |
Example
curl -X POST "https://apibox.io.vn/v1/phone" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"number":"0912 345 678","country":"VN"}'const res = await fetch('https://apibox.io.vn/v1/phone', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"number": "0912 345 678",
"country": "VN"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/phone",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"number": "0912 345 678", "country": "VN"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/phone');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"number":"0912 345 678","country":"VN"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"input": "0912 345 678",
"valid": true,
"possible": true,
"type": "MOBILE",
"country_code": "VN",
"country": "Vietnam",
"calling_code": "+84",
"national_number": "912345678",
"formats": {
"e164": "+84912345678",
"international": "+84 912 345 678",
"national": "0912 345 678",
"rfc3966": "tel:+84912345678"
}
}
Use cases
- Normalise phone numbers to E.164 before storing them or sending SMS
- Reject invalid or landline numbers in OTP sign-up flows
- Clean up phone columns in CRM imports
- Display numbers in the familiar national format for each country
FAQ
How do I validate a Vietnamese phone number?
POST {"number": "0912 345 678", "country": "VN"}. You get valid: true, type MOBILE and the E.164 form +84912345678. Numbers starting with +84 do not need the country parameter.
What is E.164 and why should I store numbers in it?
E.164 is the international format "+" + country code + number without spaces (e.g. +14155552671). It is unique, unambiguous and what SMS and voice providers like Twilio expect.
Does "valid" mean the number is in service?
No. It means the number matches the official numbering plan of its country. Whether it is currently assigned or reachable can only be confirmed by calling or sending an OTP.
Related APIs
IP Geolocation
Look up the country, region, city, coordinates, ASN and ISP of any IPv4 or IPv6 address – or your own IP – in one fast JSON call.
DNSDNS Lookup
Query A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV and more for any domain, or reverse-lookup an IP (PTR), via DNS over HTTPS. Clean JSON output.
@Email Validator
Validate e-mail addresses: syntax, MX/A records, ~120k disposable domains, role accounts, free providers and typo hints like gmial.com → gmail.com.