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/validateimport { 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.
| Field | Type | Description |
|---|---|---|
| number | string | The number to check. National or international form. Required. |
| country | string | ISO 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.
200
application/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"
}| Field | Description |
|---|---|
| valid | True when the number matches a real numbering plan. |
| possible | True when the length could be a phone number. |
| reason | Null when valid. Otherwise a short code such as invalid_number. |
| e164 | International form without spaces, such as +905551112233. |
| national | The form used inside the country. |
| international | The readable international form. |
| country | ISO country code. |
| calling_code | Country calling code, including the plus sign. |
| type | Line type from libphonenumber metadata, such as MOBILE. |
Errors
A failed request returns { "error": { "code", "message" } } and does not use a call.
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The JSON body is missing or not an object. |
| 401 | unauthorized | The bearer token is missing or not recognized. |