[{"data":1,"prerenderedAt":78},["ShallowReactive",2],{"content:en:blog\u002Fphone-number-validation":3},{"path":4,"locale":5,"section":6,"title":7,"description":8,"html":9,"headings":10,"faq":52,"updated":74,"order":75,"words":76,"meta":77},"blog\u002Fphone-number-validation","en","blog","Phone number validation: format, numbering plans, line type and live lookups","How phone number validation works layer by layer: parsing, numbering plan checks, line type, live carrier lookups, and what a valid result never proves.","\u003Cp>Phone number validation checks that a number can exist: it parses what was typed, finds the country, and tests the digits against that country's numbering plan for an allowed length and a range the regulator has opened. A valid result does not prove that the line works or that it belongs to the person who typed it. A live lookup tells you which network serves the number today, and only a one-time code proves possession.\u003C\u002Fp>\n\u003Ch2 id=\"five-questions-five-different-checks\">Five questions, five different checks\u003C\u002Fh2>\n\u003Cp>&quot;Validate a phone number&quot; covers several questions. Each one has its own source of truth, its own cost and its own blind spots.\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Check\u003C\u002Fth>\n\u003Cth>Question it answers\u003C\u002Fth>\n\u003Cth>Where the answer comes from\u003C\u002Fth>\n\u003Cth>Cost\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>Parsing\u003C\u002Ftd>\n\u003Ctd>Is this a phone number, and which country does it belong to?\u003C\u002Ftd>\n\u003Ctd>The input, plus the \u003Ccode>+\u003C\u002Fcode> prefix or a country you send\u003C\u002Ftd>\n\u003Ctd>Local, instant\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Numbering plan\u003C\u002Ftd>\n\u003Ctd>Can a number with these digits exist?\u003C\u002Ftd>\n\u003Ctd>National plans, compiled in Google's libphonenumber metadata\u003C\u002Ftd>\n\u003Ctd>Local, instant\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Line type\u003C\u002Ftd>\n\u003Ctd>Was the range opened for mobile, landline, VoIP, toll-free, premium rate?\u003C\u002Ftd>\n\u003Ctd>The ranges each plan sets aside for each service\u003C\u002Ftd>\n\u003Ctd>Local, instant\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Live lookup\u003C\u002Ftd>\n\u003Ctd>Which network serves the number now, and was it ported?\u003C\u002Ftd>\n\u003Ctd>An upstream number-lookup provider, queried at call time\u003C\u002Ftd>\n\u003Ctd>A network round trip, paid\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Possession\u003C\u002Ftd>\n\u003Ctd>Does the person in front of the form hold this phone?\u003C\u002Ftd>\n\u003Ctd>A one-time code sent by SMS or voice\u003C\u002Ftd>\n\u003Ctd>Seconds to minutes, a message per attempt\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>Most phone bugs come from asking one layer for another layer's answer. A regex cannot tell you the line type. A valid result cannot tell you who owns the number. A live lookup cannot tell you that the person typing is that owner.\u003C\u002Fp>\n\u003Ch2 id=\"parsing-turn-what-people-type-into-one-number\">Parsing: turn what people type into one number\u003C\u002Fh2>\n\u003Cp>People write the same number in many ways. A San Francisco number can arrive as \u003Ccode>(415) 555-0123\u003C\u002Fcode>, \u003Ccode>415.555.0123\u003C\u002Fcode>, \u003Ccode>+1 415 555 0123\u003C\u002Fcode>, \u003Ccode>001 415 555 0123\u003C\u002Fcode> typed in Europe, or \u003Ccode>tel:+14155550123\u003C\u002Fcode> copied from a link. Parsing removes the noise and decides which plan to read.\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Separators carry no meaning.\u003C\u002Fstrong> Spaces, dashes, dots, slashes and parentheses are dropped.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Extensions are set aside.\u003C\u002Fstrong> \u003Ccode>ext. 42\u003C\u002Fcode>, \u003Ccode>x42\u003C\u002Fcode> or \u003Ccode>#42\u003C\u002Fcode> is not part of the number, and E.164 has no room for it.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>The country comes from the prefix or from you.\u003C\u002Fstrong> A leading \u003Ccode>+\u003C\u002Fcode> means a country calling code follows. A leading \u003Ccode>00\u003C\u002Fcode> means the same thing in most countries, since \u003Ccode>00\u003C\u002Fcode> is the international prefix ITU-T recommends. Without either, the digits are a national number, and you need to know which nation.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>That last point is where most validation goes wrong. \u003Ccode>06 12 34 56 78\u003C\u002Fcode> is a valid mobile number in France. Read with a fixed default country of US, it fails. Read with no country at all, it cannot be read. The phone API returns \u003Ccode>status: &quot;unknown&quot;\u003C\u002Fcode> in that case rather than guessing.\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Input\u003C\u002Fth>\n\u003Cth>Country sent\u003C\u002Fth>\n\u003Cth>What parsing sees\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Ccode>+44 7400 123456\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>none\u003C\u002Ftd>\n\u003Ctd>A UK number, from the \u003Ccode>+44\u003C\u002Fcode> prefix\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>07400 123456\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>GB\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>A UK number; the leading \u003Ccode>0\u003C\u002Fcode> is the trunk prefix\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>07400 123456\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>none\u003C\u002Ftd>\n\u003Ctd>Unknown: no \u003Ccode>+\u003C\u002Fcode>, no country, so no plan applies\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>(415) 555-0123 ext. 7\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>US\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>+14155550123\u003C\u002Fcode>, with extension 7 kept apart\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>+44 (0)121 234 5678\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>none\u003C\u002Ftd>\n\u003Ctd>A Birmingham landline; the stray trunk \u003Ccode>0\u003C\u002Fcode> is dropped\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Ch3 id=\"why-a-regular-expression-is-not-enough\">Why a regular expression is not enough\u003C\u002Fh3>\n\u003Cp>A pattern such as \u003Ccode>^\\+?[0-9]{7,15}$\u003C\u002Fcode> checks characters and length. It accepts \u003Ccode>+11234567890\u003C\u002Fcode>, which no North American number can be, because area codes never start with 1. It accepts \u003Ccode>+447400123456789\u003C\u002Fcode>, fifteen digits and far too long for a UK mobile. And it rejects \u003Ccode>(415) 555-0123\u003C\u002Fcode>, a correct number written the way Americans write it. A regex is fine for instant feedback while someone types. The decision needs the plan.\u003C\u002Fp>\n\u003Ch2 id=\"the-numbering-plan-can-this-number-exist\">The numbering plan: can this number exist?\u003C\u002Fh2>\n\u003Cp>ITU-T Recommendation E.164 sets the frame for every number in the world: a country calling code of one to three digits, then a national number, 15 digits at most in total. Inside that frame, each country runs its own plan. National regulators decide which lengths are allowed and which blocks are open for which service. NANPA administers the North American Numbering Plan behind \u003Ccode>+1\u003C\u002Fcode>, Ofcom the UK plan, ARCEP the French plan, the Bundesnetzagentur the German one.\u003C\u002Fp>\n\u003Cp>Google's libphonenumber collects those plans into metadata, with patterns per country and per type of line. It distinguishes two levels of correctness:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Possible:\u003C\u002Fstrong> the length is one the country allows. \u003Ccode>+44 7400 12345\u003C\u002Fcode> is possible, because nine digits is a legal UK length.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Valid:\u003C\u002Fstrong> the number also matches a range the plan has opened. \u003Ccode>+44 7400 12345\u003C\u002Fcode> is not valid, because UK numbers starting with 7 have ten digits.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>A validator that only checks possibility lets through numbers nobody can dial. Ask for validity.\u003C\u002Fp>\n\u003Ch3 id=\"rules-hidden-in-ten-north-american-digits\">Rules hidden in ten North American digits\u003C\u002Fh3>\n\u003Cp>The NANP shows how much structure fits in a short number. A number is written NPA-NXX-XXXX: a three-digit area code, a three-digit central office code, then four digits.\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Rule of the plan\u003C\u002Fth>\n\u003Cth>A number that breaks it\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>The area code starts with a digit from 2 to 9\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>+1 123-456-7890\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>The central office code also starts with 2 to 9\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>+1 201-155-0123\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>N11 codes, such as 411 and 911, are service codes and never area codes\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>+1 911-555-0123\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>NANPA also reserves 555-0100 through 555-0199 for fictional use. \u003Ccode>+1 201-555-0123\u003C\u002Fcode> is valid in the plan yet assigned to nobody, which makes it a safe test value for forms and code samples. The UK has its own fiction range: Ofcom sets aside 07700 900000 to 07700 900999 for drama, and libphonenumber's data rejects those numbers as invalid.\u003C\u002Fp>\n\u003Ch3 id=\"plans-change\">Plans change\u003C\u002Fh3>\n\u003Cp>Regulators open new ranges, retire old ones and add overlay area codes when a region runs short of numbers. libphonenumber ships metadata updates in its releases, and a validator is only as current as its copy of that data. A number from a block opened very recently can fail until the data catches up. When a customer insists that a brand-new number is real, believe them and check the first digits against the regulator's announcements.\u003C\u002Fp>\n\u003Ch2 id=\"line-type-what-the-range-was-opened-for\">Line type: what the range was opened for\u003C\u002Fh2>\n\u003Cp>Each plan reserves ranges for each service, so a valid number also carries a line type. The phone API returns one of \u003Ccode>mobile\u003C\u002Fcode>, \u003Ccode>landline\u003C\u002Fcode>, \u003Ccode>fixed_line_or_mobile\u003C\u002Fcode>, \u003Ccode>voip\u003C\u002Fcode>, \u003Ccode>toll_free\u003C\u002Fcode>, \u003Ccode>premium_rate\u003C\u002Fcode>, \u003Ccode>shared_cost\u003C\u002Fcode>, \u003Ccode>personal_number\u003C\u002Fcode>, \u003Ccode>pager\u003C\u002Fcode>, \u003Ccode>uan\u003C\u002Fcode>, \u003Ccode>voicemail\u003C\u002Fcode> or \u003Ccode>unknown\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>Three facts decide how far you can rely on it:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>North America does not split mobile and landline.\u003C\u002Fstrong> Both share area codes, so every geographic \u003Ccode>+1\u003C\u002Fcode> number comes back \u003Ccode>fixed_line_or_mobile\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>VoIP is labeled only where the plan reserves ranges for it\u003C\u002Fstrong>, such as 056 in the UK or 09 in France. Internet phone services that hand out ordinary geographic or mobile numbers look like any other number.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>The type describes the range, not the phone.\u003C\u002Fstrong> A number ported from a landline operator to a mobile one keeps the type of its original range.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>The line type decides whether an SMS can arrive, and it is a cheap filter in front of a verification flow: never send a one-time code to a premium-rate number. \u003Ca href=\"\u002Fblog\u002Fvoip-number-lookup\">Mobile, landline or VoIP\u003C\u002Fa> goes through every type, and the free \u003Ca href=\"\u002Ftools\u002Fline-type-lookup\">line type lookup\u003C\u002Fa> shows it for any number.\u003C\u002Fp>\n\u003Ch2 id=\"live-lookups-who-serves-the-number-today\">Live lookups: who serves the number today\u003C\u002Fh2>\n\u003Cp>Everything so far reads static plan data. It never touches the phone network, so it cannot see what happened to a number after its range was assigned. And numbers move. Number portability lets a subscriber change operator and keep the number: in the United States and Canada, the Number Portability Administration Center (NPAC) records ported numbers, and in the European Union, Article 106 of the European Electronic Communications Code guarantees portability.\u003C\u002Fp>\n\u003Cp>A live lookup asks an upstream number-lookup provider about the number at the time of the call. With \u003Ccode>&quot;level&quot;: &quot;live&quot;\u003C\u002Fcode>, the response changes like this:\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Field\u003C\u002Fth>\n\u003Cth>Basic level\u003C\u002Fth>\n\u003Cth>Live level\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Ccode>carrier.name\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>The operator the range was originally assigned to, when the plan data names one\u003C\u002Ftd>\n\u003Ctd>The operator serving the number now\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>carrier.mcc\u003C\u002Fcode>, \u003Ccode>carrier.mnc\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>null\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Mobile country and network codes (ITU-T E.212)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>ported\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>null\u003C\u002Fcode>, since the plan cannot see porting\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>true\u003C\u002Fcode> or \u003Ccode>false\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>carrier.source\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>numbering_plan\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>live\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>Pay for it when the current network changes the outcome: routing and pricing SMS, or reviewing a sensitive change such as an account recovery. A live lookup costs 3 credits instead of 1. When the provider fails, the API answers \u003Ccode>502 upstream_unavailable\u003C\u002Fcode> and bills nothing. A live lookup sends the number to the lookup provider; the basic level sends it nowhere.\u003C\u002Fp>\n\u003Cp>What a live lookup still cannot tell you is who the subscriber is, or whether the phone is switched on. The API never returns the name or address behind a number.\u003C\u002Fp>\n\u003Ch2 id=\"possession-the-step-no-validation-replaces\">Possession: the step no validation replaces\u003C\u002Fh2>\n\u003Cp>Validation filters out impossible numbers. It does not tie a number to a person. Anyone can type a valid number that belongs to someone else, by mistake or on purpose. When a number will be used to sign in, recover an account or receive private messages, send a one-time code and mark the number verified only when the code comes back.\u003C\u002Fp>\n\u003Cp>Validate before you send that code. Every SMS costs money, and attackers know it. In SMS pumping, also called artificially inflated traffic, bots fill verification forms with numbers on expensive routes and share the revenue of the messages you pay for. A validity and line type check before the send, codes limited to the countries you serve, and per-number and per-IP rate limits remove the cheapest attacks. \u003Ca href=\"\u002Fblog\u002Fprevent-fake-signups\">Stopping fake signups\u003C\u002Fa> combines these checks with email and IP signals.\u003C\u002Fp>\n\u003Ch2 id=\"validate-a-number-with-the-api\">Validate a number with the API\u003C\u002Fh2>\n\u003Cp>Send what the person typed and, when there is no \u003Ccode>+\u003C\u002Fcode>, the country they picked next to the field:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode class=\"language-bash\">\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">curl\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> https:\u002F\u002Fapi.qelka.com\u002Fv1\u002Fphone\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> \\\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  -H\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"Authorization: Bearer \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$API_KEY\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> \\\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  -H\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"Content-Type: application\u002Fjson\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> \\\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  -d\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> '{\"phone\": \"07400 123456\", \"country\": \"GB\"}'\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The response has \u003Ccode>status: &quot;valid&quot;\u003C\u002Fcode>, \u003Ccode>e164: &quot;+447400123456&quot;\u003C\u002Fcode> and \u003Ccode>line_type: &quot;mobile&quot;\u003C\u002Fcode>. Without \u003Ccode>country\u003C\u002Fcode>, the same input returns \u003Ccode>status: &quot;unknown&quot;\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>A basic check of a US number returns the full record:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode class=\"language-json\">\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">{\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"id\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"lkp_01M84BPXA0RJ291DEC04H84EKA\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"object\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"phone\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"input\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"+14155550123\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"valid\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">true\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"status\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"valid\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"e164\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"+14155550123\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"national\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"(415) 555-0123\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"country\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: { \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"code\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"US\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"name\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"United States\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"calling_code\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"1\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> },\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"region\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"California\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"timezones\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: [\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"America\u002FLos_Angeles\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">],\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"line_type\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"fixed_line_or_mobile\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"carrier\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: { \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"name\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"mcc\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"mnc\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\"source\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"numbering_plan\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> },\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"ported\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"credits_used\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  \"cached\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">false\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Ccode>line_type\u003C\u002Fcode> is \u003Ccode>fixed_line_or_mobile\u003C\u002Fcode> because the North American plan does not separate the two. \u003Ccode>carrier.name\u003C\u002Fcode> is \u003Ccode>null\u003C\u002Fcode> because libphonenumber's carrier data names no range holder for numbers in the US states.\u003C\u002Fp>\n\u003Cp>In JavaScript, on your server, with a timeout and one decision per outcome:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode class=\"language-javascript\">\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> API\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> 'https:\u002F\u002Fapi.qelka.com\u002Fv1'\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">export\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> async\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> function\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> checkPhone\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\">phone\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\">country\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> response\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  try\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    response \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> await\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> fetch\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">`${\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">API\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">}\u002Fphone`\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">      method: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'POST'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">      headers: {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">        Authorization: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">`Bearer ${\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">process\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">env\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">API_KEY\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">}`\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">        'Content-Type'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'application\u002Fjson'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">      },\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">      body: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">JSON\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">stringify\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(country \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">?\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { phone, country } \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { phone }),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">      signal: AbortSignal.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">timeout\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">5000\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    })\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">  } \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">catch\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'accept_unchecked'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">  }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">response.ok) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'accept_unchecked'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> result\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> await\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> response.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">json\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (result.status \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">===\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> 'unknown'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'ask_country'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">result.valid) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'ask_correction'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> ([\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'premium_rate'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'shared_cost'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">].\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">includes\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(result.line_type)) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'refuse'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">null\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">  return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { decision: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'accept'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, e164: result.e164, lineType: result.line_type }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Failures fail open: if the API is slow or unreachable, the form goes through and you can check the number later. A validation outage should never be the reason nobody can sign up.\u003C\u002Fp>\n\u003Ch2 id=\"what-to-do-with-the-result\">What to do with the result\u003C\u002Fh2>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Result\u003C\u002Fth>\n\u003Cth>In a signup or checkout form\u003C\u002Fth>\n\u003Cth>Before sending an SMS\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Ccode>valid\u003C\u002Fcode>, \u003Ccode>mobile\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Accept and store \u003Ccode>e164\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Send\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>valid\u003C\u002Fcode>, \u003Ccode>fixed_line_or_mobile\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Accept\u003C\u002Ftd>\n\u003Ctd>Send and watch delivery reports, or run a live lookup first\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>valid\u003C\u002Fcode>, \u003Ccode>landline\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Accept if your flow can use a call\u003C\u002Ftd>\n\u003Ctd>Do not text: call, or ask for a mobile number\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>valid\u003C\u002Fcode>, \u003Ccode>voip\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Accept or flag, by your policy\u003C\u002Ftd>\n\u003Ctd>Fine for notices; decide per flow for codes\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>valid\u003C\u002Fcode>, \u003Ccode>premium_rate\u003C\u002Fcode> or \u003Ccode>shared_cost\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Refuse\u003C\u002Ftd>\n\u003Ctd>Never send\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>invalid\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Ask for a correction and show an example number for the country\u003C\u002Ftd>\n\u003Ctd>Remove from the send\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>unknown\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Ask for the country, then check again\u003C\u002Ftd>\n\u003Ctd>Fix the country first\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Ch2 id=\"mistakes-that-cost-the-most\">Mistakes that cost the most\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Cstrong>A fixed default country.\u003C\u002Fstrong> Default to the visitor's locale or IP country, and let them change it. A \u003Ccode>US\u003C\u002Fcode> default turns every French or British number typed at home into a failure.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Storing what was typed.\u003C\u002Fstrong> Store \u003Ccode>e164\u003C\u002Fcode>. Two spellings of one number then match, and SMS providers accept the value as it is. \u003Ca href=\"\u002Fblog\u002Fe164-format\">E.164 explained\u003C\u002Fa> covers storage in detail.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>A numeric column.\u003C\u002Fstrong> It drops the \u003Ccode>+\u003C\u002Fcode>. A text column of 16 characters fits any E.164 number.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Calling the API from the browser.\u003C\u002Fstrong> Your key would ship to every visitor. Validate on the server, and keep the browser to a light length hint.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Treating \u003Ccode>valid\u003C\u002Fcode> as verified.\u003C\u002Fstrong> Only a returned code proves possession.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Refusing every VoIP number.\u003C\u002Fstrong> Some real customers only have one. Decide per flow, not globally.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"try-it-before-you-write-code\">Try it before you write code\u003C\u002Fh2>\n\u003Cp>The free \u003Ca href=\"\u002Ftools\u002Fphone-validator\">phone validator\u003C\u002Fa> runs the same basic check, 10 times a day without an account. With a test key, numbers are parsed for real and no credits are spent, so you can build the whole integration in \u003Ca href=\"\u002Fdocs\u002Ftest-mode\">test mode\u003C\u002Fa>. Every field is described in the \u003Ca href=\"\u002Fdocs\u002Fapi-reference\u002Fphone\">phone API reference\u003C\u002Fa>, and the \u003Ca href=\"\u002Fphone-validation-api\">phone validation API\u003C\u002Fa> page covers pricing and volumes.\u003C\u002Fp>\n",[11,15,18,22,25,28,31,34,37,40,43,46,49],{"id":12,"text":13,"depth":14},"five-questions-five-different-checks","Five questions, five different checks",2,{"id":16,"text":17,"depth":14},"parsing-turn-what-people-type-into-one-number","Parsing: turn what people type into one number",{"id":19,"text":20,"depth":21},"why-a-regular-expression-is-not-enough","Why a regular expression is not enough",3,{"id":23,"text":24,"depth":14},"the-numbering-plan-can-this-number-exist","The numbering plan: can this number exist?",{"id":26,"text":27,"depth":21},"rules-hidden-in-ten-north-american-digits","Rules hidden in ten North American digits",{"id":29,"text":30,"depth":21},"plans-change","Plans change",{"id":32,"text":33,"depth":14},"line-type-what-the-range-was-opened-for","Line type: what the range was opened for",{"id":35,"text":36,"depth":14},"live-lookups-who-serves-the-number-today","Live lookups: who serves the number today",{"id":38,"text":39,"depth":14},"possession-the-step-no-validation-replaces","Possession: the step no validation replaces",{"id":41,"text":42,"depth":14},"validate-a-number-with-the-api","Validate a number with the API",{"id":44,"text":45,"depth":14},"what-to-do-with-the-result","What to do with the result",{"id":47,"text":48,"depth":14},"mistakes-that-cost-the-most","Mistakes that cost the most",{"id":50,"text":51,"depth":14},"try-it-before-you-write-code","Try it before you write code",[53,56,59,62,65,68,71],{"q":54,"a":55},"How do I check if a phone number is valid?","Parse it with its country, then test it against that country's numbering plan: the length must be allowed and the digits must fall in a range the regulator has opened. Libraries built on Google's libphonenumber do this, and so does the free \u003Ca href=\"\u002Ftools\u002Fphone-validator\">phone validator\u003C\u002Fa>. Send the country along with numbers typed without a \u003Ccode>+\u003C\u002Fcode>, or no check can know which plan to read. Then store the E.164 form of every valid number.",{"q":57,"a":58},"Can you validate a phone number with a regex?","Only loosely. A regex checks characters and length, so it cannot know that North American area codes never start with 0 or 1, that a UK mobile has exactly ten digits after +44, or which ranges a regulator has opened. Use a regex for instant feedback while someone types, and run the real check against numbering plan data on your server before you accept the number.",{"q":60,"a":61},"What is the difference between phone validation and phone verification?","Validation looks at the number itself: can it exist, which country, which line type. It sends nothing and the owner sees nothing. Verification proves that the person in front of your form holds the phone, usually with a one-time code sent by SMS or voice call. Validate first, so you never pay to send a code to an impossible or premium-rate number, then verify when the number will be used to sign in.",{"q":63,"a":64},"Why does a valid phone number not work?","A numbering plan lists the numbers that can exist, not the ones in service. A valid number may never have been assigned, may have been disconnected, or may now belong to a new subscriber. The fictional range 555-0100 to 555-0199 in North America is valid in the plan and assigned to nobody. A live lookup shows the network serving a number today; only a call or a returned code shows that someone answers.",{"q":66,"a":67},"How many digits does a valid phone number have?","ITU-T E.164 caps an international number at 15 digits, country calling code included. Each country sets its own lengths inside that limit: 10 digits after +1 in the United States and Canada, 9 after +33 in France, 10 for a UK mobile after +44, while German numbers vary with the area and the type of line. A correct length is necessary, but it never makes a number valid on its own.",{"q":69,"a":70},"Does phone validation call or text the number?","No. A basic check reads numbering plan data on the server and never contacts the phone network, so the owner of the number sees nothing. A live lookup asks an upstream number-lookup provider which network serves the number. That reads network records, not the handset, and it does not place a call or send a message either. Only a verification code, which you choose to send, reaches the phone.",{"q":72,"a":73},"How much does a phone validation API call cost?","With Qelka, a basic check against the numbering plan costs 1 credit, and a live lookup of the current carrier and porting status costs 3 credits. Errors are not billed, and neither are live lookups whose provider fails. The free plan includes 100 credits a month, and the \u003Ca href=\"\u002Ftools\u002Fphone-validator\">phone validator\u003C\u002Fa> runs 10 checks a day without an account. Test keys never spend credits.","2026-11-23",1,2341,{},1795474028826]