Table of Contents
Send a one-time-password to specified mobile number. Requires “otp” API permission.POST https://androidapi.net/api/send/otp
Parameter #
Field | Type | Description |
---|---|---|
secret | String | The API secret you copied from (Tools -> API Keys) page |
type | String | Type of message, it can be SMS or WhatsApp.Allowed values: "sms" , "whatsapp" |
message | String | OTP message to send, you can use {{otp}} shortcode to include the otp anywhere in the message. |
phone | String | Recipient mobile number, it will accept E.164 formatted numbers Example for Philippines E.164: +639184661533 |
expire | Number | OTP expiration time in seconds. This is optional, default value is 300 seconds or 5 minutes. |
priority (optional) | Number | For WhatsApp only. If you want to send the message as priority, it will be sent immediately. 1 for yes and 2 for no.Default value: 2 |
account (optional) | String | This is only for whatsapp type. WhatsApp account you want to use for sending, you can get account unique ID’s from /get/wa.accounts or in the dashboard. |
mode (optional) | String | This is only required for sms type. This is the mode of sending the message, it can be “devices” which will allow you to use your linked android devices or “credits” which will allow you to use gateways and partner devices. “credits” requires you to have enough credit balance to send messages.Allowed values: "devices" , "credits" |
device (optional) | String | This is only for sms type. Linked device unique ID, this is required if you will send with “devices” mode. You can get linked device unique ID from /get/devices (Your devices). |
gateway (optional) | String|Number | This is only for sms type. Partner device unique ID or gateway ID, this is required if you will send with “credits” mode. You can get a partner device unique ID and gateway ID from /get/rates |
sim (optional) | Number | This is only for sms type. Sim slot number you want to use. For “devices” mode only.Allowed values: 1 , 2 |
Success Response Format #
Field | Type | Description |
---|---|---|
status | Number | List of Codes 200 = Success |
message | String | Response message |
data | Array | Array of data |
Error Response Format #
Name | Type | Description |
---|---|---|
status | Number | List of Codes 400 = Invalid parameters 401 = Invalid API secret 403 = Access denied 404 = Device doesn’t exist 500 = Something went wrong |
message | String | Response message |
data | Array | Array of data |
PHP Sample #
<?php
$message = [
"secret" => "API_SECRET", // your API secret from (Tools -> API Keys) page
"mode" => "sms",
"mode" => "devices",
"device" => "00000000-0000-0000-d57d-f30cb6a89289",
"sim" => 1,
"phone" => "+923012345678",
"message" => "Your OTP is {{otp}}"
];
$cURL = curl_init("https://androidapi.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);
// do something with response
print_r($result);
Python Sample #
import requests
# your API secret from (Tools -> API Keys) page
apiSecret = "API_SECRET"
message = {
"secret": apiSecret,
"type": "sms",
"mode": "devices",
"device": "00000000-0000-0000-d57d-f30cb6a89289",
"sim": 1,
"phone": "+923012345678",
"message": "Your OTP is {{otp}}"
}
r = requests.post(url = "https://androidapi.net/api/send/otp", params = message)
# do something with response object
result = r.json()
Successful Response #
{
"status": 200,
"message": "OTP has been sent!",
"data": {
phone: "+923012345678",
message: "Your OTP is 345678",
otp: 345678
}
}
Error Response #
{
"status": 400,
"message": "Invalid Parameters!",
"data": false
}