Generate a one time password and send it to a phone number on WhatsApp.
https://telcomw.com/api-v2/v1.generate_otpSend the parameters as headers.
| Parameter | Sent in | Required | Description |
key |
header | YES | Your API key. |
password |
header | YES | Your account password. |
for |
header | YES | The phone number that receives the OTP, with the country code, for example +265992026866. |
length |
header | NO | How many characters the OTP has, for example 5. |
expire |
header | NO | How long the OTP is valid, in minutes, for example 4. |
name |
header | NO | Your organisation name, shown in the OTP message. |
curl --location --request POST 'https://telcomw.com/api-v2/v1.generate_otp' \ --header 'key: YOUR_API_KEY' \ --header 'password: YOUR_PASSWORD' \ --header 'length: 5' \ --header 'expire: 4' \ --header 'for: +265992026866' \ --header 'name: SMS DELIVERY API'
curl --location --request POST "https://telcomw.com/api-v2/v1.generate_otp" ^ --header "key: YOUR_API_KEY" ^ --header "password: YOUR_PASSWORD" ^ --header "length: 5" ^ --header "expire: 4" ^ --header "for: +265992026866" ^ --header "name: SMS DELIVERY API"
<?php
$headers = [
'key: YOUR_API_KEY',
'password: YOUR_PASSWORD',
'length: 5',
'expire: 4',
'for: +265992026866',
'name: SMS DELIVERY API',
];
$ch = curl_init('https://telcomw.com/api-v2/v1.generate_otp');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
const axios = require('axios');
axios.request({
method: 'post',
url: 'https://telcomw.com/api-v2/v1.generate_otp',
headers: {
'key': 'YOUR_API_KEY',
'password': 'YOUR_PASSWORD',
'length': '5',
'expire': '4',
'for': '+265992026866',
'name': 'SMS DELIVERY API'
}
}).then((res) => console.log(res.data))
.catch((err) => console.error(err.response ? err.response.data : err.message));
import requests
headers = {
'key': 'YOUR_API_KEY',
'password': 'YOUR_PASSWORD',
'length': '5',
'expire': '4',
'for': '+265992026866',
'name': 'SMS DELIVERY API'
}
response = requests.request('POST', 'https://telcomw.com/api-v2/v1.generate_otp', headers=headers)
print(response.json())
The response is JSON.
{
"status": 200,
"message": "Your OTP was generated and sent successfully!",
"ref": 230955,
"expire": "4-mins",
"org": "SMS DELIVERY API"
}
| Field | Description |
status | 200 means the OTP was generated and sent. |
ref | The reference of the OTP. You need it to verify the OTP. |
expire | How long the OTP is valid. |
org | The organisation name used in the OTP message. |