OTP API Documentation
The OTP API on WaSMS.Net provides functionality for sending and verifying one-time passwords (OTP) via SMS or WhatsApp. Below are the endpoints for sending and verifying OTPs.
1. OTP - Send OTP
This endpoint allows you to send an OTP to a specified mobile number. It requires the otp
API permission.
POST: https://sys.wasms.net/api/send/otp
Parameters:
Field | Type | Description |
secret |
String | The API secret from the Tools -> API Keys page. |
type |
String | Type of message, either sms or whatsapp . |
message |
String | OTP message to send (use {{otp}} as a placeholder). |
phone |
String | Recipient mobile number (formatted as E.164). |
expire |
Number | (Optional) OTP expiration time in seconds (default: 300 seconds). |
priority |
Number | (Optional, for WhatsApp) Send message as priority (1 for yes, 2 for no). Default is 2. |
account |
String | (Optional, for WhatsApp) WhatsApp account ID. |
mode |
String | (Required for SMS) Can be devices or credits . |
device |
String | (Optional for SMS) Linked device unique ID. |
gateway |
String/Number | (Optional for SMS) Partner device or gateway ID. |
sim |
Number | (Optional for SMS) SIM slot to use (1 or 2). |
Success Response Format:
Field | Type | Description |
---|---|---|
status |
Number | Status code (200 = Success). |
message |
String | Response message. |
data |
Array | Details of the OTP sent (e.g., phone number, OTP). |
Example Success Response:
{
"status": 200,
"message": "OTP has been sent!",
"data": {
"phone": "+923012345678",
"message": "Your OTP is 345678",
"otp": 345678
}
}
Error Response Format:
Field | Type | Description |
---|---|---|
status |
Number | Status codes (400, 401, 403, 404, 500). |
message |
String | Error message. |
data |
Array | Any additional data (usually empty). |
Example PHP Request:
$message = [
"secret" => "API_SECRET", // your API secret
"mode" => "sms",
"device" => "00000000-0000-0000-d57d-f30cb6a89289",
"sim" => 1,
"phone" => "+923012345678",
"message" => "Your OTP is {{otp}}"
];
$cURL = curl_init("https://sys.wasms.net/api/send/otp");
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_POSTFIELDS, $message);
$response = curl_exec($cURL);
curl_close($cURL);
$result = json_decode($response, true);
print_r($result);
2. OTP - Verify OTP
This endpoint allows you to verify an OTP provided by a user. It requires the otp
API permission.
GET: https://sys.wasms.net/api/get/otp
Parameters:
Field | Type | Description |
---|---|---|
secret |
String | The API secret from the Tools -> API Keys page. |
otp |
String | The OTP entered by the user. |
Success Response Format:
Field | Type | Description |
---|---|---|
status |
Number | Status code (200 = Success). |
message |
String | Response message. |
data |
Array | Details about the verification result. |
Example Success Response:
{
"status": 200,
"message": "OTP has been verified!",
"data": false
}
Error Response Format:
Field | Type | Description |
---|---|---|
status |
Number | Status codes (400, 401, 403, 500). |
message |
String | Error message. |
data |
Array | Any additional data (usually empty). |
Example PHP Request:
$apiSecret = "API_SECRET"; // your API secret
$otp = "123456"; // user-supplied OT
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, "https://sys.wasms.net/api/get/otp?secret={$apiSecret}&otp={$otp}");
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($cURL);
curl_close($cURL);
$result = json_decode($response, true);
print_r($result);
Conclusion
The OTP API allows you to securely send and verify one-time passwords via SMS or WhatsApp, providing enhanced security for user authentication. For more information, visit the Tools -> API Keys page in your WaSMS.Net account or contact our support team.