Complete guide for integrating WhatsApp OTP into your standalone website
Fast WhatsApp OTP provides a REST API for sending and verifying OTP codes via WhatsApp. This documentation will help you integrate OTP functionality into your standalone website.
Base URL:
https://otpmore.hirelan.com/api/
All API requests require authentication using API Key and API Secret. You can get these from your dashboard after logging in.
| HEADER | DESCRIPTION | EXAMPLE |
|---|---|---|
Authorization |
Bearer token with your API Key | Bearer your_api_key_here |
X-API-Secret |
Your API Secret Key | your_api_secret_here |
Content-Type |
Request content type | application/json |
Endpoint: POST https://otpmore.hirelan.com/api/send-otp
{
"mobile": "919876543210"
}
{
"status": "sent",
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"message": "OTP sent successfully",
"expires_at": "2024-01-01 12:05:00"
}
{
"error": "Error message here"
}
curl -X POST https://otpmore.hirelan.com/api/send-otp \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-API-Secret: YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-d '{"mobile":"919876543210"}'
Endpoint: POST https://otpmore.hirelan.com/api/verify-otp
{
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"otp": "123456"
}
{
"status": "verified",
"message": "OTP verified successfully"
}
{
"error": "Invalid OTP"
}
Possible errors: "Invalid OTP", "OTP has expired", "Maximum retry attempts exceeded"
curl -X POST https://otpmore.hirelan.com/api/verify-otp \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-API-Secret: YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-d '{"transaction_id":"550e8400-e29b-41d4-a716-446655440000","otp":"123456"}'
// Send OTP
async function sendOTP(mobile) {
const response = await fetch('https://otpmore.hirelan.com/api/send-otp', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
},
body: JSON.stringify({ mobile: mobile })
});
const data = await response.json();
if (response.ok) {
console.log('OTP sent! Transaction ID:', data.transaction_id);
return data.transaction_id;
} else {
console.error('Error:', data.error);
throw new Error(data.error);
}
}
// Verify OTP
async function verifyOTP(transactionId, otp) {
const response = await fetch('https://otpmore.hirelan.com/api/verify-otp', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
},
body: JSON.stringify({
transaction_id: transactionId,
otp: otp
})
});
const data = await response.json();
if (response.ok && data.status === 'verified') {
console.log('OTP verified successfully!');
return true;
} else {
console.error('Verification failed:', data.error);
return false;
}
}
// Usage
const mobile = '919876543210';
sendOTP(mobile).then(transactionId => {
// Show OTP input form
const userOTP = prompt('Enter OTP:');
verifyOTP(transactionId, userOTP).then(verified => {
if (verified) {
alert('OTP verified! Proceed with login.');
} else {
alert('Invalid OTP. Please try again.');
}
});
});
// Send OTP
function sendOTP($mobile) {
$url = 'https://otpmore.hirelan.com/api/send-otp';
$data = json_encode(['mobile' => $mobile]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'X-API-Secret: YOUR_API_SECRET',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Verify OTP
function verifyOTP($transactionId, $otp) {
$url = 'https://otpmore.hirelan.com/api/verify-otp';
$data = json_encode([
'transaction_id' => $transactionId,
'otp' => $otp
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'X-API-Secret: YOUR_API_SECRET',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
return isset($result['status']) && $result['status'] === 'verified';
}
| HTTP CODE | ERROR MESSAGE | DESCRIPTION |
|---|---|---|
400 |
Mobile number is required | Missing mobile parameter in request |
400 |
Transaction ID and OTP are required | Missing parameters in verify request |
400 |
Invalid OTP | OTP code doesn't match |
400 |
OTP has expired | OTP expired (default: 5 minutes) |
400 |
Maximum retry attempts exceeded | Too many failed verification attempts (default: 3) |
401 |
Missing or invalid Authorization header | API Key not provided or invalid |
401 |
Invalid API secret | API Secret doesn't match |
401 |
Domain not allowed for this API key | Request origin domain not in allowed list |
403 |
Insufficient wallet balance | User wallet balance is too low |
To get your API Key and API Secret: