BlogData

A dead number parses fine

Phone validation checks the numbering plan. HLR adds assignment and reachability status, which answer different questions.

A disconnected number can still have the right length, a real area code, and a valid prefix. It can pass validation even though calling it gets you nowhere.

That is the difference between /phone and /hlr. The first checks the number against the numbering plan. The second adds status information about the line.

Here are the relevant fields from an HLR response:

GET /hlr/+13102858000
{
  "phone": "+13102858000",
  "valid": true,
  "country": "US",
  "live": true,
  "connected": null
}

valid says the number passes validation. live says the status result identifies it as assigned to a subscriber. connected says whether the handset was reachable when checked. Those last two are separate because an assigned number can belong to a phone that is switched off.

In this example, assignment is known and reachability is not. Landlines commonly return that combination. A mobile result can include both answers, but either field can be null when the check did not establish it. Recent results can be reused, so this is not a promise that a phone is reachable at the instant your request arrives.

For cleaning a phone list, keep three outcomes for live: assigned, unassigned, and unknown. A test such as if (!result.live) folds false and null into the same branch. That would mark an unanswered check as a dead number. Compare with true or false explicitly and leave null results for your review policy.

An unreachable handset needs different handling again. connected: false can describe a phone that was temporarily unavailable; it is not a reason by itself to delete the number from a contact list. Neither status proves that the number belongs to the person who gave it to you.

For numbers outside North America, ?deep=true can add roaming and mobile network details under deep. The HLR reference explains the available fields and how long recent checks can be reused.