Skip to main content
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"}'
{
  "phone_number": "+16045551234",
  "carrier": {
    "linetype": "wireless",
    "name": "Rogers Communications Canada Inc. (Wireless)"
  },
  "valid": true,
  "location": "British Columbia"
}
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

phone_number
string
required
Phone number to look up in E.164 format (e.g., +16045551234).

Response

phone_number
string
The phone number in E.164 format.
carrier
object
Carrier information for the number.
  • linetypewireless, landline, voip, or null if unknown
  • name — Carrier name (e.g., “Rogers Communications Canada Inc.”)
valid
boolean
Whether the number is a valid phone number.
location
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"}'
{
  "phone_number": "+16045551234",
  "carrier": {
    "linetype": "wireless",
    "name": "Rogers Communications Canada Inc. (Wireless)"
  },
  "valid": true,
  "location": "British Columbia"
}