Send WhatsApp Token
The Send WhatsApp Token API allows businesses to deliver one-time passwords (OTPs) directly to customers via WhatsApp.
Please note: This endpoint is not enabled by default. To activate it for your account, kindly contact our support team.
Endpoint : https://BASE_URL/api/sms/send
Request Type : POST
Body params
Options | Required | Description |
---|---|---|
api_key | yes | string Your API key (It can be found on your Termii dashboard. |
to | yes | string Represents the destination phone number. Phone number must be in the international format ( Example: 23490126727 ). You can also send to multiple numbers. To do so put numbers in an array (Example: ["23490555546", "23423490126999"] ) Please note: the array takes only 100 phone numbers at a time |
from | yes | string Represents a sender ID for sms which can be Alphanumeric or Device name for Whatsapp. Alphanumeric sender ID length should be between 3 and 11 characters (Example: CompanyName ) |
sms | yes | string Specifies the OTP to be sent to the customer’s WhatsApp number. The OTP must contain only numeric characters with a minimum of 4 and maximum of 6 characters. |
channel | yes | string This is the route through which the message is sent. It is either dnd or generic . |
type | yes | string Specifies the format of the message being sent. Supported types include:
Note: For encrypted messages you must provide the following details: |
{
"api_key": "Your API Key",
"to": "2347015250000",
"from": "Great",
"sms": "77678",
"type": "plain",
"channel": "whatsapp_otp"
}
var data = {
"to":"2347880234567",
"from":"talert",
"sms":"Hi there, testing Termii",
"type":"plain",
"api_key":"Your API key",
"channel":"whatsapp_otp"
};
var data = JSON.stringify(data);
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://BASE_URL/api/sms/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
var request = require('request');
var data = {
"to":"2347880234567",
"from":"talert",
"sms":"Hi there, testing Termii",
"type":"plain",
"api_key":"Your API key",
"channel":"whatsapp_otp",
};
var options = {
'method': 'POST',
'url': 'https://BASE_URL/api/sms/send',
'headers': {
'Content-Type': ['application/json', 'application/json']
},
body: JSON.stringify(data)
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "https://BASE_URL/api/sms/send"
payload = {
"to": "2347880234567",
"from": "talert",
"sms": "Hi there, testing Termii ",
"type": "plain",
"channel": "whatsapp_otp",
"api_key": "Your API Key",
}
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
var client = new RestClient("https://BASE_URL/api/sms/send");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\r\n \"to\":\"2347880234567\",\r\n \"from\":\"talert\",\r\n \"sms\":\"Hi there, testing Termii\",\r\n
\"type\":\"plain\",\r\n \"api_key\":\"Your API key\",\r\n \"channel\":\"whatsapp_otp\",\r\n };",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://BASE_URL/api/sms/send")
.header("Content-Type", "application/json")
.body("{\r\n \"to\":\"2347880234567\",\r\n \"from\":\"talert\",\r\n \"sms\":\"Hi there, testing Termii\",\r\n \"type\":\"plain\",\r\n \"api_key\":\"Your API key\",\r\n \"channel\":\"whatsapp_otp\",\r\n };")
.asString();
$curl = curl_init();
$data = array("api_key" => "Your API key", "to" => "2347880234567", "from" => "talert",
"sms" => "Hi there, testing Termii ", "type" => "plain", "channel" => "whatsapp_otp" );
$post_data = json_encode($data);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://BASE_URL/api/sms/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Sample Response - 200 OK
{
"code": "ok",
"balance": 1047.57,
"message_id": "3017544054459083819856413",
"message": "Successfully Sent",
"user": "Oluwatobiloba Fatunde",
"message_id_str": "3017544054459083819856413"
}