Secure one-time password (OTP) verification service for SMS and WhatsApp channels.
POST /otp/send
x-api-key: YOUR_API_KEY
Content-Type: application/json
{
"phone_number": "+233201234567",
"app": "my_ecommerce_app",
"channel": "sms",
"expiry": 10,
"length": 6
}
Response:
{
"id": "otp_64f8a1b2c3d4e5f6",
"phone_number": "+233201234567",
"app": "my_ecommerce_app",
"channel": "sms",
"expiry_minutes": 10,
"length": 6,
"status": "sent",
"created_at": "2024-01-15T10:20:00Z",
"expires_at": "2024-01-15T10:30:00Z"
}
GET /otp/{id}/status
x-api-key: YOUR_API_KEY
Response:
{
"id": "otp_64f8a1b2c3d4e5f6",
"phone_number": "+233201234567",
"app": "my_ecommerce_app",
"channel": "sms",
"status": "pending",
"attempts": 0,
"max_attempts": 3,
"created_at": "2024-01-15T10:20:00Z",
"expires_at": "2024-01-15T10:30:00Z",
"verified_at": null
}
POST /otp/{id}/verify
x-api-key: YOUR_API_KEY
Content-Type: application/json
{
"code": "123456"
}
Response:
{
"success": true,
"message": "OTP verified successfully",
"verified_at": "2024-01-15T10:25:00Z",
"attempts_remaining": 2
}
POST /otp/send
Send a one-time password to a phone number.
Request Body:
{
"phone_number": "+233201234567",
"app": "my_ecommerce_app",
"channel": "sms",
"expiry": 10,
"length": 6
}
Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
phone_number | string | ✅ | Phone number in international format |
app | string | ✅ | Application identifier |
channel | string | ✅ | sms or whatsapp |
expiry | number | ❌ | Expiry time in minutes (default: 10) |
length | number | ❌ | OTP length (default: 6) |
GET /otp/{id}/status
Check the status of an OTP.
POST /otp/{id}/verify
Verify an OTP code.
Request Body:
{
"code": "123456"
}
GET /otp/analytics
Get OTP analytics and statistics.
Query Parameters:
app (optional): Filter by applicationdays (optional): Number of days to analyze (default: 30)| Status | Description |
|---|---|
sent | OTP sent successfully |
pending | Waiting for verification |
verified | Successfully verified |
expired | OTP expired |
failed | Verification failed |
{
"success": false,
"message": "Invalid OTP code",
"attempts_remaining": 2
}
// Send OTP
const response = await fetch('https://api.tryzend.com/otp/send', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone_number: '+233201234567',
app: 'my_ecommerce_app',
channel: 'sms',
expiry: 10,
length: 6
})
});
const { id } = await response.json();
// Verify OTP
const verifyResponse = await fetch(`https://api.tryzend.com/otp/${id}/verify`, {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ code: '123456' })
});
const result = await verifyResponse.json();
console.log(result.success); // true if verified