Skip to contentSkip to navigationSkip to topbar
On this page

Lookup v1 API


(warning)

Warning

Version 2 of the Lookup API is now available! Lookup v2 has an improved developer experience and exciting features, such as Twilio Regions support and these new data packages:

  • Line Type Intelligence : Get the line type of a phone number including mobile, landline, fixed VoIP, non-fixed VoIP, toll-free, and more.
  • SIM Swap : Get information on the last SIM change for a mobile phone number.
  • Call Forwarding : Get the unconditional call forwarding status of a mobile phone number.
  • Identity Match : Get confirmation of ownership for a mobile phone number by comparing user-provided information against authoritative phone-based data sources.

You are currently viewing Version 1 content. Lookup v1 will be maintained for the time being, but any new features and development will be on v2. We strongly encourage you to do any new development with Lookup v2. Check out the migration guide(link takes you to an external page) or the API v2 Reference for more information.

The Lookup API provides a way to retrieve additional information about a phone number. Lookup currently supports the following types of data.

  • Region-specific number formatting and validation
  • Carrier Information
  • Caller Name

You can specify one or more types of information you would like to purchase in the request, check the Lookup Product Page(link takes you to an external page) for pricing information.


API URL

api-url page anchor

All URLs referenced in the documentation use the following URL.

https://lookups.twilio.com/v1/PhoneNumbers/{PhoneNumber}

The Twilio REST API is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.

{PhoneNumber} is the phone number you are requesting information about. Phone numbers can be specified either in national formatting or in standard E.164 format(link takes you to an external page). If providing a number in local national format, please also specify the country as an optional parameter. If no country is provided, this will default to US.

(warning)

Warning

In some cases, non-US phone numbers in national format with no + sign or CountryCode query parameter are being processed as valid. This is not changing in V1 in the future but it is an unintended behavior and could lead to ambiguous validation responses.


HTTP requests to the REST API are protected with HTTP Basic authentication(link takes you to an external page). To learn more about how Twilio handles authentication, please refer to our security documentation. In short, you will use your Twilio account SID as the username and your auth token as the password for HTTP Basic authentication.

1
curl -G https://lookups.twilio.com/v1/PhoneNumbers/{PhoneNumber} \
2
-u '[YOUR ACCOUNT SID]:[YOUR AUTH TOKEN]'

You can find your account SID and auth token in your console(link takes you to an external page).

To learn more about authentication and interaction with the Twilio REST API, check out our documentation for requests to the API and Twilio's response .


HTTP GET

http-get page anchor

Returns phone number information matching the specified request. Formatting information is standard. Carrier, Caller Name, and phone number type information can be requested, in addition to using Twilio Marketplace Add-ons to access 3rd party data sources.

The following basic GET query string parameters allow you to specify the phone number you want information about and the types of information you'd like:

Property nameTypeRequiredPIIDescription
PhoneNumberstringrequired
PII MTL: 30 days

The phone number to lookup in E.164 format, which consists of a + followed by the country code and subscriber number.

Property nameTypeRequiredPIIDescription
CountryCodestring

Optional

The ISO country code(link takes you to an external page) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format.


Typearray[string]

Optional

Not PII

The type of information to return. Can be: carrier or caller-name. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with carrier and once with caller-name as the value.


AddOnsarray[string]

Optional

The unique_name of an Add-on you would like to invoke. Can be the unique_name of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the Add-ons documentation.


AddOnsDataobject<prefixed-collapsible-map-AddOns>

Optional

Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on.

The following properties are always returned:

(warning)

Warning

  • Only possible numbers (for a given region, using length and prefix information) will return formatting results. If you attempt to lookup a phone number which is not valid, you will receive an HTTP 404 error.
  • Machine to machine (M2M) phone numbers are not supported in Lookup and will return an HTTP 404 error.
Property nameTypeRequiredDescriptionChild properties
caller_nameobject

Optional

The name of the phone number's owner. If null, that information was not available.


country_codestring

Optional


phone_numberstring<phone-number>

Optional

The phone number in E.164 format, which consists of a + followed by the country code and subscriber number.


national_formatstring

Optional

The phone number, in national format.


carrierobject

Optional

The telecom company that provides the phone number.


add_onsobject

Optional

A JSON string with the results of the Add-ons you specified in the add_ons parameters. For the format of the object, see Using Add-ons.


urlstring<uri>

Optional

The absolute URL of the resource.

(warning)

Warning

The following additional properties are returned if you requested carrier information in your GET request:

NameDescription
MobileCountryCodeThe three digit mobile country code of the carrier, used with the mobile network code to identify a mobile network operator.
MobileNetworkCodeThe two-three digit mobile network code of the carrier, used with the mobile country code to identify a mobile network operator (only returned for mobile numbers).
NameThe name of the carrier; often subject to change.
TypeThe phone number type. Possible values are landline, mobile, or voip. See 'Phone Number Types' below for more information.
ErrorCodeThe error code, if any, associated with your request.

Phone Number Types

phone-number-type-values page anchor

The following are the possible values for the 'Type' property.

TypeDescription
landlineThe phone number is a landline number; generally not capable of receiving SMS messages.
mobileThe phone number is a mobile number; generally capable of receiving SMS messages.
voipAn internet based phone number that may or may not be capable of receiving SMS messages. For example, Google Voice. Returned for U.S. numbers only.
nullThe phone number is valid but no information was returned from our data providers (see limitation for Canada numbers(link takes you to an external page)).

Caller name information

lookups-caller-name page anchor
(warning)

Warning

Caller name information is sourced through CNAM(link takes you to an external page) and only available for phone numbers owned by carriers in the US. We recommend testing the coverage rate of this lookup with your specific dataset of phone numbers.

The following additional properties are returned if you requested caller name in your GET request:

NameDescription
CallerNameString indicating the name of the owner of the phone number. If not available, this will return null.
CallerTypeString indicating whether this caller is a business or consumer. Possible values are BUSINESS, CONSUMER. If not available, this will return null.
ErrorCodeThe error code, if any, associated with your request.

Caller name lookups for US numbers are billed per lookup, even if data is not be available. Requesting Caller name lookups for non-US will return null values and will not be billed.


Carrier Lookup with E.164 Formatted NumberLink to code sample: Carrier Lookup with E.164 Formatted Number
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchPhoneNumber() {
11
const phoneNumber = await client.lookups.v1
12
.phoneNumbers("+15108675310")
13
.fetch({ type: ["carrier"] });
14
15
console.log(phoneNumber.carrier);
16
}
17
18
fetchPhoneNumber();

Output

1
{
2
"caller_name": null,
3
"carrier": {
4
"error_code": null,
5
"mobile_country_code": "310",
6
"mobile_network_code": "456",
7
"name": "verizon",
8
"type": "mobile"
9
},
10
"country_code": "US",
11
"national_format": "(510) 867-5310",
12
"phone_number": "+15108675310",
13
"add_ons": null,
14
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310"
15
}
Carrier Lookup with National Formatted NumberLink to code sample: Carrier Lookup with National Formatted Number
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchPhoneNumber() {
11
const phoneNumber = await client.lookups.v1
12
.phoneNumbers("(510)867-5310")
13
.fetch({
14
countryCode: "US",
15
type: ["carrier"],
16
});
17
18
console.log(phoneNumber.carrier);
19
}
20
21
fetchPhoneNumber();

Output

1
{
2
"caller_name": null,
3
"carrier": {
4
"error_code": null,
5
"mobile_country_code": "310",
6
"mobile_network_code": "456",
7
"name": "verizon",
8
"type": "mobile"
9
},
10
"country_code": "US",
11
"national_format": "(510) 867-5310",
12
"phone_number": "(510)867-5310",
13
"add_ons": null,
14
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310"
15
}
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchPhoneNumber() {
11
const phoneNumber = await client.lookups.v1
12
.phoneNumbers("+15108675310")
13
.fetch({ type: ["caller-name"] });
14
15
console.log(phoneNumber.callerName);
16
}
17
18
fetchPhoneNumber();

Output

1
{
2
"caller_name": {
3
"caller_name": "Delicious Cheese Cake",
4
"caller_type": "CONSUMER",
5
"error_code": null
6
},
7
"carrier": null,
8
"country_code": "US",
9
"national_format": "(510) 867-5310",
10
"phone_number": "+15108675310",
11
"add_ons": null,
12
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310"
13
}

Using Twilio Marketplace Add-ons with Lookup

using-twilio-marketplace-add-ons-with-lookup page anchor

Lookup also supports Twilio Marketplace Add-ons, enabling you to retrieve information from a multitude of 3rd party data sources, available via the Twilio Marketplace(link takes you to an external page).

You can add Lookup supported Add-ons by visiting the Twilio Console(link takes you to an external page) to enable the Add-on. Once it has been enabled, make sure you have 'Lookups' selected in its configuration:

Console screenshot showing that &#x27;Lookups&#x27; is checked for the ekata_phone_valid Add-on.

When you use AddOns, you can pass additional parameters to the Add-on(s):

NameDescription
AddOns.addon_name.param_nameOptional. Passes additional data to the Add-on at request time. See Add-on documentation in Console(link takes you to an external page) to identify if the Add-on requires additional parameters.

Examples with Twilio Marketplace Add-ons

examples-with-twilio-marketplace-add-ons page anchor
Deterministic TCPA Compliance with Lookup and the Payfone Add-onLink to code sample: Deterministic TCPA Compliance with Lookup and the Payfone Add-on
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchPhoneNumber() {
11
const phoneNumber = await client.lookups.v1
12
.phoneNumbers("+16502530000")
13
.fetch({
14
addOns: ["payfone_tcpa_compliance"],
15
addOnsData: {
16
"payfone_tcpa_compliance.RightPartyContactedDate": "20160101",
17
},
18
type: ["carrier"],
19
});
20
21
console.log(phoneNumber.addOns);
22
}
23
24
fetchPhoneNumber();

Output

1
{
2
"caller_name": null,
3
"country_code": "US",
4
"phone_number": "+16502530000",
5
"national_format": "(650) 253-0000",
6
"carrier": {
7
"mobile_country_code": null,
8
"mobile_network_code": null,
9
"name": "Level 3 Communications, LLC",
10
"type": "landline",
11
"error_code": null
12
},
13
"add_ons": {
14
"status": "successful",
15
"message": null,
16
"code": null,
17
"results": {
18
"payfone_tcpa_compliance": {
19
"status": "successful",
20
"request_sid": "XRd3a2991c9108bde3ca9589ed84d31463",
21
"message": null,
22
"code": null,
23
"result": {
24
"Status": 0,
25
"Response": {
26
"MSISDNType": "NonFixedVoIP",
27
"NumberMatch": "I",
28
"VerifyNumberTransactionId": "2019459819"
29
},
30
"RequestId": "XRd3a2991c9108bde3ca9589ed84d31463",
31
"Description": "Success."
32
}
33
}
34
}
35
},
36
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
37
}
Detect Robocallers with Lookup and Nomorobo Spam Score Add-onLink to code sample: Detect Robocallers with Lookup and Nomorobo Spam Score Add-on
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchPhoneNumber() {
11
const phoneNumber = await client.lookups.v1
12
.phoneNumbers("+19892008374")
13
.fetch({ addOns: ["nomorobo_spamscore"] });
14
15
console.log(phoneNumber.addOns);
16
}
17
18
fetchPhoneNumber();

Output

1
{
2
"caller_name": null,
3
"country_code": "US",
4
"phone_number": "+19892008374",
5
"national_format": "(989) 200-8374",
6
"carrier": {
7
"mobile_country_code": "310",
8
"mobile_network_code": null,
9
"name": "Ytel/Blitz",
10
"type": "mobile",
11
"error_code": null
12
},
13
"add_ons": {
14
"status": "successful",
15
"message": null,
16
"code": null,
17
"results": {
18
"nomorobo_spamscore": {
19
"status": "successful",
20
"request_sid": "XR763c8acc4c56d5e3e18d2f0f12345bc1",
21
"message": null,
22
"code": null,
23
"result": {
24
"status": "success",
25
"message": "success",
26
"score": 1
27
}
28
}
29
}
30
},
31
"url": "https://lookups.twilio.com/v1/PhoneNumbers/+19892008374"
32
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.