In-App Token

This API returns OTP codes in JSON format which can be used within any web or mobile app. Tokens are numeric or alpha-numeric codes generated to authenticate login requests and verify customer transactions.

Endpoint : https://BASE_URL/api/sms/otp/generate

Request Type : POST

OptionsRequiredDescription
api_keyyesstring
Your live API key (It can be found on your Termii dashboard).
pin_typeyesSpecifies the format of the OTP to be generated and sent.

Use NUMERIC to generate an OTP containing only numbers (e.g., 457891).

Use ALPHANUMERIC to generate an OTP containing both letters and numbers (e.g., AD4891F)
phone_numberyesstring
Represents the recipient's phone number. The phone number must be provided in international format (e.g. 2347065250817), without spaces or special characters.
pin_attemptsyesinteger
Example: 3
Represents the number of times the PIN can be attempted before expiration. It has a minimum of one attempt
pin_time_to_liveyesinteger
Example: 1
Represents how long the PIN is valid before expiration. The time is in minutes. The minimum time value is 0 and the maximum time value is 60
pin_lengthyesinteger
Example: 4
The length of the PIN code. It has a minimum of 4 and maximum of 8.
 {
   "api_key": "Your API Key",
   "pin_type": "NUMERIC",
   "phone_number": "2348109477743",
   "pin_attempts": 3,
   "pin_time_to_live": 0,
   "pin_length": 4
 }
var data = {
          "api_key": "Your API Key",
          "pin_type": "NUMERIC",
          "phone_number": "2348109477743",
          "pin_attempts": 3,
          "pin_time_to_live": 0,
          "pin_length": 4
          };

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/otp/generate");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);

var request = require('request');
var data = {
             "api_key": "Your API Key",
             "pin_type": "NUMERIC",
             "phone_number": "2348109477743",
             "pin_attempts": 3,
             "pin_time_to_live": 0,
             "pin_length": 4
          };
var options = {
'method': 'POST',
'url': 'https://BASE_URL/api/sms/otp/generate',
'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/otp/generate"
payload = {
           "api_key": "Your API Key",
            "pin_type": "NUMERIC",
            "phone_number": "2348109477743",
            "pin_attempts": 3,
            "pin_time_to_live": 0,
            "pin_length": 4
       }
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
RestClient restClient = new RestClient("https://BASE_URL/api/sms/otp/generate");

//Creating Json object
JObject objectBody = new JObject();
objectBody.Add("api_key","Your API Key");
objectBody.Add("pin_type","NUMERIC");
objectBody.Add("phone_number","2348109477743");
objectBody.Add("pin_attempts", 3);
objectBody.Add("pin_time_to_live", 0);
objectBody.Add("pin_length",4);


RestRequest restRequest = new RestRequest(Method.POST);

restRequest.AddHeader("Content-Type", "application/json");
restRequest.AddParameter("application/json", objectBody,  ParameterType.RequestBody);
IRestResponse restResponse = restClient.Execute(restRequest);
Console.WriteLine(restResponse.Content);  
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://BASE_URL/api/sms/otp/generate")
.header("Content-Type", "application/json")
.body("{\r\n  \"api_key\": \"Your API Key\",\r\n    \"pin_type\": \"NUMERIC\",\r\n  \"phone_number\": \"2348109477743\",\r\n    \"pin_attempts\": 3,\r\n   \"pin_time_to_live\": 0,\r\n    \"pin_length\": 4\r\n }")
.asString();

$curl = curl_init();
$data = array("api_key" => "Your API key", "pint_type" => "NUMERIC", 
"phone_number" => "2348109477743", "pin_attempts" => 3, "pin_time_to_live" => 0, "pin_length" => 4 );

$post_data = json_encode($data);

curl_setopt_array($curl, array(
CURLOPT_URL => "https://BASE_URL/api/sms/otp/generate",
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

  {
      "phone_number_other": "2347065250817",
      "phone_number": "2347065250817",
      "otp": "5635",
      "pin_id": "1f6294bc-8db4-48ee-864b-45cf9e3493d9"
  }
Updated at, Thursday, September 11, 2025