Twilio's Lookup API allows users to query phone number information including number validation and formatting, carrier information, and the caller name associated with a phone number. Continue reading for an overview of the Lookup API, how it works, and answers to frequently asked questions.
This guide covers the following information:
- Submit a Lookup API request
- Where does Lookup data come from?
- How is phone number validity determined?
- What are the Carrier Lookup 'Type' values?
- Geographic support and limitations
- Process simultaneous Lookup API requests
- Does Lookup cache response values?
Submit a Lookup API request
To Lookup a phone number, your application needs to make an HTTP GET request to Twilio’s Lookup REST API resource with the phone number you wish to lookup. Here's a simple cURL script example:
curl -X GET 'https://lookups.twilio.com/v1/PhoneNumbers/3105555555' \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
This example will lookup of the phone number (310) 555-5555 (
3105555555 in line 1 of the code sample). It should return the following response:
"national_format": "(310) 555-5555",
This response indicates the phone number is valid, but not necessarily in service. The
phone_number value is presented in E.164 formatting, which should be used across Twilio’s voice and messaging APIs.
Notice: The Lookup API will return an HTTP 404 status with a response containing
"code": 20404 when a phone number is determined invalid. For full details, see the section How is phone number validity determined.
The Lookup API supports additional parameters to specify a Carrier Lookup (
Type=carrier), a Caller ID Lookup (
Type=caller-name), and more. For a full rundown of these optional parameters, see our Lookup API reference guide (Twilio Docs).
Where does Lookup data come from?
Lookup utilizes a variety of authoritative sources to return the most accurate response for a given Lookup type. See more details on each Lookup type below:
|Lookup type||Data sources||Update frequency|
|Number validation and formatting||International numbering plan data||Bi-weekly|
|Carrier||Mobile number portability and numbering plan data from each country’s phone number regulator (where available).||Varies by country
(At minimum every 30 min, at maximum every 24 hrs)
|Caller Name||Network CNAM data supplied by carriers for the phone numbers that they own.||Varies by network|
How is phone number validity determined?
Lookup will return an
HTTP 404 status code if a phone number resource is invalid. Phone number validity is based on international phone numbering plan data administered by the ITU. Though the ITU should in theory have all global numbering plans on file, in practice, not every country will file their numbering plans with the ITU. Additionally, some government authorities may let telecom companies be responsible for administrating numbering plans. As a result of this lack of centralization, maintaining an accurate global numbering plan is a patchwork process. Twilio works with a variety of carrier partners to maintain accurate global numbering plan data but discrepancies can arise as numbering plans change and downstream providers must propagate these changes.
What are the Carrier Lookup 'Type' values?
In the response for a Carrier Lookup, the
type property specifies whether the phone is a landline, mobile, or voip phone.
landline(aka 'fixed' or 'wireline') and
mobile(aka 'non-fixed' or 'wireless') are service type designations provided by the carrier who owns the number.
voipis a classification on the carrier.
Please note, since VoIP phone numbers are easier to obtain, they are sometimes used for fraudulent purposes. Customers often use Lookup to screen these numbers in their applications.
Geographic support and limitations
While the Lookup API is supported internationally, there are limitations to some request types:
Phone number validation and formatting: Number validation and formatting lookups are supported in all countries worldwide.
Caller Name Lookup: This is sourced by authoritative CNAM data, which is only supported by carriers in the U.S, and a portion of carriers in Canada. CNAM lookups for phone numbers from other countries are not supported. For full details see Getting Started with CNAM Caller ID.
Carrier Lookup: This is supported worldwide with the following caveats:
voiptype will only be returned for carriers in the U.S. It is not supported outside of the U.S.
landlinetypes can be returned for all countries worldwide.
mobile_network_codefields are returned in over 90 countries where mobile number portability is supported. For more information, see Why does the Mobile Country Code (MCC), Mobile Network Code (MNC) not show up for my phone number lookup?
- Queries to Canada phone numbers require approval from the Canadian Local Number Portability Consortium. Refer to this article to learn more and request access. Without approval and access, queries to Canada numbers will return a
Process simultaneous Lookup API requests
The Lookup API only handles a phone number per request. For more information and recommendations, see Sending multiple requests to Twilio Lookup API.
Does Lookup cache response values?
To improve performance of the service, Lookup caches response values for Caller Name and Carrier Lookups for 1 hour.
Phone number validation and formatting lookups are not cached.