Generate OTP

Legacy APIs - WhatsApp
Legacy WhatsApp API We only offer this type of WhatsApp API to customers who specifically request it. We have now moved to the official WhatsApp. To use official WhatsApp, contact us on WhatsApp +265992026866.
Starting a new integration? This is a legacy API. It stays available for existing integrations, but new integrations should use the SMS V3 APIs.

Generate a one time password and send it to a phone number on WhatsApp.

POSThttps://telcomw.com/api-v2/v1.generate_otp

Send the parameters as headers.

Parameters

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.

Example request

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())

Response

The response is JSON.

{
  "status": 200,
  "message": "Your OTP was generated and sent successfully!",
  "ref": 230955,
  "expire": "4-mins",
  "org": "SMS DELIVERY API"
}

Fields explained

FieldDescription
status200 means the OTP was generated and sent.
refThe reference of the OTP. You need it to verify the OTP.
expireHow long the OTP is valid.
orgThe organisation name used in the OTP message.