Docs / Phone

Validate a phone number

Checks a number’s format and returns the E.164, national, and international forms, plus the country and line type. An invalid number still returns 200. This does not check whether the line is active.

POST/v1/phones/validate
import { Client } from "@liveapiio/liveapi";

const client = new Client({ token: process.env.LIVEAPI_TOKEN });

const phone = await client.validatePhone("0555 111 22 33", "TR");

Request

Send Authorization: Bearer YOUR_TOKEN. The token stays on your server. Each library reads it from the environment and calls this endpoint for you.

FieldTypeDescription
numberstringThe number to check. National or international form. Required.
countrystringISO country code, such as TR. When omitted, the country is read from the number itself.

Response

200 with valid: false means the format is wrong. That response still uses one call.

200application/json
{
  "valid": true,
  "possible": true,
  "reason": null,
  "e164": "+905551112233",
  "national": "0555 111 22 33",
  "international": "+90 555 111 22 33",
  "country": "TR",
  "calling_code": "+90",
  "type": "MOBILE"
}
FieldDescription
validTrue when the number matches a real numbering plan.
possibleTrue when the length could be a phone number.
reasonNull when valid. Otherwise a short code such as invalid_number.
e164International form without spaces, such as +905551112233.
nationalThe form used inside the country.
internationalThe readable international form.
countryISO country code.
calling_codeCountry calling code, including the plus sign.
typeLine type from libphonenumber metadata, such as MOBILE.

Errors

A failed request returns { "error": { "code", "message" } } and does not use a call.

StatusCodeWhen
400invalid_requestThe JSON body is missing or not an object.
401unauthorizedThe bearer token is missing or not recognized.

We value your privacy

We use necessary cookies to run this website. With your consent, we would also like to use analytics and marketing cookies. Read our cookie policy.