+(923) 111 88 4444
TecniForge, 79/5-L, Sahiwal 57000

OTP – Send OTP

OTP – Send OTP

Send a one-time-password to specified mobile number. Requires “otp” API permission.POST https://androidapi.net/api/send/otp

Parameter #

secretStringThe API secret you copied from (Tools -> API Keys) page
typeStringType of message, it can be SMS or WhatsApp.Allowed values: "sms""whatsapp"
messageStringOTP message to send, you can use {{otp}} shortcode to include the otp anywhere in the message.
phoneStringRecipient mobile number, it will accept E.164 formatted numbers
Example for Philippines
E.164: +639184661533
expireNumberOTP expiration time in seconds. This is optional, default value is 300 seconds or 5 minutes.
priority (optional)NumberFor 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)StringThis 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)StringThis 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)StringThis 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|NumberThis 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)NumberThis is only for sms type. Sim slot number you want to use. For “devices” mode only.Allowed values: 12

Success Response Format #

statusNumberList of Codes
200 = Success
messageStringResponse message
dataArrayArray of data

Error Response Format #

statusNumberList of Codes
400 = Invalid parameters
401 = Invalid API secret
403 = Access denied
404 = Device doesn’t exist
500 = Something went wrong
messageStringResponse message
dataArrayArray of data

PHP Sample #


  $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);

  $result = json_decode($response, true);

  // do something with response

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

Leave A Comment