curl -X POST https://api.magpipe.ai/functions/v1/lookup-phone-number \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone_number": "+16045551234"}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone_number: '+16045551234'
}),
}
);
const data = await response.json();
console.log(`Line type: ${data.carrier.linetype}`);
// "wireless" | "landline" | "voip" | null
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={'phone_number': '+16045551234'}
)
data = response.json()
if data['carrier']['linetype'] == 'wireless':
print('Number can receive SMS')
{
"phone_number": "+16045551234",
"carrier": {
"linetype": "wireless",
"name": "Rogers Communications Canada Inc. (Wireless)"
},
"valid": true,
"location": "British Columbia"
}
{
"phone_number": "+16045559999",
"carrier": {
"linetype": "landline",
"name": "Telus Communications Inc."
},
"valid": true,
"location": "British Columbia"
}
{
"error": {
"code": "lookup_failed",
"message": "Lookup failed: 404"
}
}
Phone Numbers
Lookup Phone Number
Look up carrier and line type information for a phone number
POST
/
lookup-phone-number
curl -X POST https://api.magpipe.ai/functions/v1/lookup-phone-number \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone_number": "+16045551234"}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone_number: '+16045551234'
}),
}
);
const data = await response.json();
console.log(`Line type: ${data.carrier.linetype}`);
// "wireless" | "landline" | "voip" | null
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={'phone_number': '+16045551234'}
)
data = response.json()
if data['carrier']['linetype'] == 'wireless':
print('Number can receive SMS')
{
"phone_number": "+16045551234",
"carrier": {
"linetype": "wireless",
"name": "Rogers Communications Canada Inc. (Wireless)"
},
"valid": true,
"location": "British Columbia"
}
{
"phone_number": "+16045559999",
"carrier": {
"linetype": "landline",
"name": "Telus Communications Inc."
},
"valid": true,
"location": "British Columbia"
}
{
"error": {
"code": "lookup_failed",
"message": "Lookup failed: 404"
}
}
Look up carrier information for any phone number. Returns the line type (wireless, landline, VoIP), carrier name, and location. Useful for determining if a number can receive SMS before sending.
Request Body
string
required
Phone number to look up in E.164 format (e.g.,
+16045551234).Response
string
The phone number in E.164 format.
object
Carrier information for the number.
linetype—wireless,landline,voip, ornullif unknownname— Carrier name (e.g., “Rogers Communications Canada Inc.”)
boolean
Whether the number is a valid phone number.
string
Geographic location (state/province) of the number, if available.
Common Use Case
Check if a number is wireless before sending SMS:const lookup = await fetch('https://api.magpipe.ai/functions/v1/lookup-phone-number', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ phone_number: callerPhone }),
}).then(r => r.json());
if (lookup.carrier?.linetype === 'wireless') {
// Safe to send SMS
await sendSms(callerPhone, message);
}
curl -X POST https://api.magpipe.ai/functions/v1/lookup-phone-number \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone_number": "+16045551234"}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone_number: '+16045551234'
}),
}
);
const data = await response.json();
console.log(`Line type: ${data.carrier.linetype}`);
// "wireless" | "landline" | "voip" | null
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/lookup-phone-number',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={'phone_number': '+16045551234'}
)
data = response.json()
if data['carrier']['linetype'] == 'wireless':
print('Number can receive SMS')
{
"phone_number": "+16045551234",
"carrier": {
"linetype": "wireless",
"name": "Rogers Communications Canada Inc. (Wireless)"
},
"valid": true,
"location": "British Columbia"
}
{
"phone_number": "+16045559999",
"carrier": {
"linetype": "landline",
"name": "Telus Communications Inc."
},
"valid": true,
"location": "British Columbia"
}
{
"error": {
"code": "lookup_failed",
"message": "Lookup failed: 404"
}
}
⌘I