Email Token

The email token API enables you to send one-time-passwords from your application through our email channel to an email address. Only one-time-passwords (OTP) are allowed for now and these OTPs can not be verified using our Verify Token API.

Endpoint : https://BASE_URL/api/email/otp/send

Request Type : POST

Body params

OptionsRequiredDescription
api_keyyesstring
Your API key (It can be found on your Termii dashboard.
email_addressyesstring
Represents the email address you are sending to (Example: test@termii.com).
codeyesstring
Represents the OTP sent to the email address
email_configuration_idyesstring
This is represents the email configuration you have added on your Termii dashboard. It can be found on your Termii dashboard.


{
    "email_address": "shola.olu@term.ii",
    "code": "092471",
    "api_key": "Your API key",
    "email_configuration_id": "0a53c416-uocj-95af-ab3c306aellc"
}
var data = {
        "email_address": "shola.olu@term.ii",
        "code": "092471",
        "api_key": "Your API key",
        "email_configuration_id": "0a53c416-uocj-95af-ab3c306aellc"
  };

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/email/otp/send");
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",
 "email_address" : "shola.olu@term.ii",
   "code": "98340",
   "email_configuration_id": "00cfcw93-pc0d-43bc-9f7f-589a3f306ae5"
};
var options = {
'method': 'POST',
'url': 'https://BASE_URL/api/email/otp/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/email/otp/send"
payload = {
            "api_key" : "Your API Key",
            "email_address" : "shola.olu@term.ii",
              "code": "98340",
              "email_configuration_id": "00cfcw93-pc0d-43bc-9f7f-589a3f306ae5"
       }
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/email/otp/send");
  
  //Creating Json object
  JObject objectBody = new JObject();
  objectBody.Add("api_key","Your API Key");
  objectBody.Add("email_address","shola.olu@term.ii");
  objectBody.Add("code", "092471");
  objectBody.Add("email_configuration_id", "0a53c416-uocj-95af-ab3c306aellc");

  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/email/otp/send")
.header("Content-Type", "application/json")
.body(" {\n   \"api_key\" : \"Your API Key\",\n   \"email_address\" : \"shola.olu@term.ii\",\n\t \"code\": \"98340\",\n\t \"email_configuration_id\": \"f0cfce83-ac1d-43bc-9f8f-589a3f356bc2\"\n }")
.asString();



$curl = curl_init();
$data = array("email_address" => "shola.olu@term.ii", "code" => "092471", "api_key" => "Your API Key",  "email_configuration_id" => "0a53c416-uocj-95af-ab3c306aellc" );

$post_data = json_encode($data);

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://BASE_URL/api/email/otp/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;


Response

   {
      "code": "ok",
      "message_id": "9122821270554876574",
      "message": "Successfully Sent",
      "balance": 9,
      "user": "Shola Olu"
   }
Updated at, Wednesday, November 20, 2024