Skip to main content
Build custom phone validation workflows using the Loqate API. This guide covers implementation patterns and integration strategies for JavaScript, PHP, and .NET. For pre-built solutions, see Tag integrations or platform integrations. Security and configuration details are in API Security.
These examples demonstrate core integration patterns. Adapt error handling and configuration for your production environment.

Architecture Decisions

Client-side validation
Quick to implement and requires less technical expertise, but exposes your API key in client code. Mitigate with domain restrictions in account settings. Best for real-time form validation.
Server-side validation
Keeps credentials secure and provides full control over validation logic. Best for backend workflows and batch processing.

API Overview

Phone Validation uses a single endpoint that returns validation status, carrier information, and formatted numbers. Endpoint: POST /PhoneNumberValidation/Interactive/Validate/v2.20/json6.ws Parameters:
  • Key - Your API key
  • Phone - Phone number to validate
  • Country - ISO country code (optional if number includes country prefix)
Response:

Basic Implementation

Handling Results

The IsValid field returns "Yes", "No", or "Maybe". A "Maybe" response indicates temporary carrier network issues—treat it as potentially valid.

Error Handling

The API returns standard HTTP status codes. Handle errors based on your application’s requirements. Retry logic:

Integration Patterns

Real-Time Form Validation

Validate phone numbers on blur with debouncing to reduce API calls.

Batch Validation

Process multiple numbers with rate limiting.

Multi-Country Support

Auto-detect user location and adjust validation accordingly.

Data Storage

Store validated numbers in international format for consistency.

Testing

Test with numbers in various formats and countries:

Security

Configure API key restrictions in your account settings:
  • Add domain restrictions for client-side implementations
  • Use IP allowlists for server-side implementations
  • Set rate limits to prevent abuse
  • Rotate keys periodically
See API Security for detailed guidance.

Additional Resources