Locanium
All guides
Phone ValidationE.164SMS

Format and verify international phone numbers before you send an SMS

Normalize any phone input to E.164, detect the line type, and drop unreachable numbers before you pay for an SMS that can't be delivered.

1 min read
On this page

A phone field is where clean data goes to die: brackets, spaces, missing country codes, landlines entered for SMS. Validate once at input and you'll never fire an OTP into the void again.

The problem with raw phone input

Users type (0532) 123 45 67, +90 532 123 4567, and 05321234567 for the same number. Your SMS provider wants exactly one format — E.164 — and charges you whether or not the message lands. The Phone Validation endpoint normalizes the input and tells you whether it's even reachable.

bash
curl "https://api.locabium.com/v1/validate/phone?number=%2B905321234567" \
  -H "Authorization: Bearer $LOCABIUM_KEY"
response.json
{
  "number": "+905321234567",
  "valid": true,
  "e164": "+905321234567",
  "country": "TR",
  "line_type": "mobile",
  "carrier": "Turkcell"
}

Use the parts that matter

  • e164 → the canonical form to store and hand to your SMS gateway.
  • valid: false → reject before you spend a message credit.
  • line_type → block landline and voip when you specifically need an SMS-capable mobile for OTP.
  • country and carrier → useful for routing and fraud scoring.

Validate on the client, confirm on the server

Format as the user types with react-phone-number-input, then confirm server-side before you trust it. Store only the e164 value.

otp.ts
const r = await fetch(
  `https://api.locabium.com/v1/validate/phone?number=${encodeURIComponent(input)}`,
  { headers: { Authorization: `Bearer ${process.env.LOCABIUM_KEY}` } },
);
const p = await r.json();

if (!p.valid || p.line_type !== "mobile") {
  return { ok: false, reason: "Enter a mobile number that can receive SMS." };
}
await sendOtp(p.e164);

Block landlines and VoIP only when the channel truly requires a mobile. For a contact form, a landline is a perfectly good phone number — don't over-reject.

Ready to build this?

View API docs
Get started

One API for geolocation, currency and identity checks. Book a demo and get a sandbox key the same day.