Send OTP SMS Bulk SMS API Documentation

Send OTP SMS

Generate and Deliver One Time Password Token to the Recipient.

Application API URL:

https://www.smsgateway.center/OTPApi/send

 

Import Send OTP SMS API postman collection.

Postman Collection

 

 

Key Value Description
Login Credentials (Required Parameters)
Authenticate your API request using userId-password or apiKey. You should use either one to authenticate your login.
userId Your Registered Username The registered username parameter to be passed. You can use this if apiKey is not being used.
password Your password The password needs to be urlencoded if there are any special characters used in the password field. You can use this if apiKey is not being used.
apiKey Your unique apiKey apiKey needs to be sent as HTTP header when you are not using userId and password credentials. You can avail this from your user control panel and use instead of userId and password HTTP Request parameter. Please do not disclose this to anyone.
Required Parameters
mobile Mobile Number with Country Code Enter your Customer's mobile number which needs to be verified.

Comments: Keep number in International format (with country code).
senderId Approved Sender Name For Indian customers, sender name would be of 6 alpha characters. For International customers, sender name depends on country to country basis.
msgType text|unicode This is to define simple or UNICODE message. For simple English, you can give value as text or for non-English messages, give value as unicode.
sendMethod generate

Required: This value required for send OTP code to recipient's mobile number.

msg Your text message with $otp$ variable Message content to send. (Default Message Content: Your verification code is $otp$)

Comments: Include variable as {{OTP}}, rest content can be sent as per requirement.
Default Parameters (Optional)
codeExpiry Time in seconds Optional. Minimum 60 Seconds, Maximum 1800 Seconds, System default is 60 Seconds.

Comments: Expiry Time of OTP Token to Verify, in Seconds.
codeLength OTP Token Length Optional. Minimum Length 4, Maximum Length 10, System default Length is 4.

Comments: Number of Digits/Characters in Length for OTP Token.
codeType num|alpha|alphanum Optional. num for Numeric token, alpha for Alphabetic token and alphanum for AlphaNumeric token. System default is num.

Comments: Type of the OTP token to be generated.
retryExpiry Retry Time in seconds Optional. Minimum 15 Seconds, Maximum 1800 Seconds, System default is 60 Seconds.

Comments: Maximum time to allow your users to regenerate OTP. E.g. If you have set 60 seconds, then user cannot request OTP again for next 60 seconds.
renew true|false Optional. Set to True to resend/regenerate new OTP Token. System default is false.

Comments: If OTP token needs to be resent/regenerated.
medium sms|email Optional. Name of the medium to deliver OTP to. You can deliver on 2 medium simultaneously. System default is sms.

Comments: You can use comma separated with maximum 2 mediums, that is sms,email. OTP token will be delivered to both sms and email.
emailId valid Email ID Optional. Give valid email id to deliver OTP code. Use only if OTP needs to be delivered to customer's Email ID.System default is null.

Comments: From Email ID will be shown as registered Email ID and From Name will be shown as Registered Full Name as per your account settings.
callback Valid callback script URL with http or https protocol Optional. To save data on your database or by capturing the response you can further email or use voice call to send OTP token.

Comments: To receive generated OTP token details, you can set a callback URL. Response Parameters will be sent to your url as status=success&type=new&generationTime=2017-12-06%2023%3A18%3A15&validity=120%20secs&otp=6754
format plain|json|xml Value for response format.

System default is plain. If you need responses in JSON or XML then you have to give value as JSON or XML.

Save this Page on your Favorite Social Media

Sample Request Code

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://www.smsgateway.center/OTPApi/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "userId=YourUserName&password=YourPassword&mobile=91xxxxxxxxxx&codeExpiry=60&msg=Your%20SMSGatewayCenter%20OTP%20is%20%24otp%24&codeLength=4&codeType=num&senderId=SGCSMS&renew=false&callback=http%3A%2F%2Fwww.example.com%2FgetOTPResponse.php&format=json&sendMethod=generate",
  CURLOPT_HTTPHEADER => array(
    "Cache-Control: no-cache",
    "Content-Type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://www.smsgateway.center/OTPApi/send?userId=YourUserName&password=YourPassword&mobile=91xxxxxxxxxx&codeExpiry=60&msg=Your%20SMSGatewayCenter%20OTP%20is%20$otp$&codeLength=4&codeType=num&senderId=SGCSMS&renew=false&callback=http://www.example.com/getOTPResponse.php&format=json&sendMethod=generate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "authKey=02d725f6bddd4d3299493a3448341a41",
  CURLOPT_HTTPHEADER => array(
    "Cache-Control: no-cache",
    "Content-Type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Response - Success

{
    "status": "success",
    "mobile": "91xxxxxxxxxx",
    "transactionId": "aa40b4b8-7bb8-4bf6-b94a-fa5b82df4511",
    "statusCode": "900",
    "type": "new",
    "reason": "OTP successfully generated.",
    "createTime": "1513772384340",
    "expiryTime": "1513772444340",
    "retryAfter": "1513772444340"
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<simpleMessageSuccessResponse>
    <mobile>91xxxxxxxxxx</mobile>
    <status>success</status>
    <statusCode>900</statusCode>
    <reason>OTP successfully generated.</reason>
    <transactionId>9754e2de-5306-41cb-8602-836c5e7bb065</transactionId>
    <createTime>1513772182439</createTime>
    <expiryTime>1513772242439</expiryTime>
    <retryAfter>1513772242439</retryAfter>
</simpleMessageSuccessResponse>
status=success | mobile=91xxxxxxxxxx | reason=OTP successfully generated. | transactionId=975d55f6-f983-4a79-907e-71f69a62154b | errorCode=900 | type=new | createTime=1513772280207 | expiryTime=1513772340207 | retryExpiry=1513772340207

Response - Error

{
    "status": "error",
    "statusCode": "922",
    "reason": "Invalid mobile numbers."
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<errorResponse>
    <status>error</status>
    <statusCode>922</statusCode>
    <reason>Invalid mobile numbers.</reason>
</errorResponse>
status=error | errorCode=922 | reason=Invalid mobile numbers.