agentsvc.io

services / phone-validate

utilityoperational · 2 ms

Phone Number Validation

Parse and validate any phone number worldwide using libphonenumber. Returns is_valid, e164 (canonical international format e.g. '+4917612345678'), national_format, country_code (ISO alpha-2), and line_type (MOBILE/FIXED_LINE/VOIP/TOLL_FREE). Provide country_code hint (e.g. 'DE') for local numbers without country prefix.

Run free trial ↗3 free calls per day with the example input. Paid: $0.002 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/phone-validate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"phone":"+41 44 668 18 00"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
phone *stringPhone number to validate. Can be in any format: E.164 ('+4915123456789'), national ('015123456789'), or international ('0049 151 23456789'). Include country code (+ prefix) for best results.
country_codestringISO 3166-1 alpha-2 country code hint for parsing national numbers without country prefix (e.g. 'DE' for Germany, 'US' for United States). Optional if number includes country code (+...).

Output

FieldTypeDescription
phonestringThe input phone number as provided
is_validbooleantrue if the number is a valid, dialable phone number
e164stringE.164 formatted number (e.g. '+4915123456789'). International standard format.
national_formatstringNationally formatted number (e.g. '0151 23456789' for Germany)
international_formatstringInternationally formatted number (e.g. '+49 151 23456789')
country_codestringISO 3166-1 alpha-2 country code (e.g. 'DE', 'US', 'GB')
country_calling_codestringInternational dialing code (e.g. '49' for Germany, '1' for US)
line_typestringType of phone line: 'MOBILE', 'FIXED_LINE', 'FIXED_LINE_OR_MOBILE', 'TOLL_FREE', 'PREMIUM_RATE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL', or 'UNKNOWN'
checksobject

Example response (data)

{
  "phone": "+49 151 23456789",
  "is_valid": true,
  "e164": "+4915123456789",
  "national_format": "0151 23456789",
  "international_format": "+49 151 23456789",
  "country_code": "DE",
  "country_calling_code": "49",
  "line_type": "MOBILE",
  "checks": {
    "is_possible": true,
    "is_valid": true
  }
}