Twilio Lookup API for filtering out phone numbers

Viewed 288

I have an application that allows users to send SMS to numbers they upload in their account. I am starting to implement the Twilio Lookup API so that we avoid sending SMS to numbers that cannot receive them. It's easy to run a carrier lookup and filter out landlines based on the returned type information, but I wanted to know if there was anything else I could glean from the returned lookup information that would indicate a number that doesn't accept SMS.

  • Does a blank mobile_network_code signify anything?
  • Is there any way to tell if a VoIP number cannot receive SMS?
  • Does type = null tell me anything useful about the phone number?
  • Are there any specific error_code values that signify the number cannot receive SMS?

Usually the Twilio documentation is pretty thorough but I feel like it's lacking on these pieces of information. Thanks for any information, all you Twilio evangelists!

1 Answers

Twilio developer evangelist here.

The Lookup API can very much depend on the underlying sources of data that we can access.

My best answers to your questions are:

Does a blank mobile_network_code signify anything?

That the underlying data could not provide a mobile network code. If the phone number still presents as a mobile number in the type, then you should still be able to send it an SMS. There is, for example, an issue with carrier data for Canadian numbers that prevents us from providing this data.

  • Is there any way to tell if a VoIP number cannot receive SMS?

No, best thing in this case is to try to send the message and catch and log any errors.

  • Does type = null tell me anything useful about the phone number?

Not really, again you should try sending messages and handle errors. See the note on Canadian carrier data for more.

  • Are there any specific error_code values that signify the number cannot receive SMS?

There are a number of error codes that relate to Lookup queries in the 6xxxx range. 60600 and 60610 mean similar things, that the phone is unprovisioned or out of coverage and that you likely can't send it a message. 60612 means it's not a mobile number, but should only be returned for lookup providers that require the number being looked up to be a mobile, which doesn't apply for the type information. Other error_codes tend to be about your account's ability to use a provider or package for looking numbers up. You can peruse the catalogue of errors for more information.

Related