Email Product Notification
The Email Product Notification API enables you to send templated email notifications dynamically using the email templates and configurations created on your account dashboard.
Endpoint : https://BASE_UR/api/templates/send-email
Request Type : POST
Body params
| Options | Required | Description |
|---|---|---|
| api_key | yes | string Your API key (It can be found on your Termii dashboard. |
| yes | string Represents the email address you are sending to (Example: test@termii.com). | |
| subject | yes | string This is a short text field representing the email subject line that will appear in the recipient’s inbox. |
| email_configuration_id | yes | string This represents the email configuration you have added on your Termii dashboard. It can be found on your Termii dashboard. |
| template_id | yes | string This represents the template you created on your Termii dashboard. It can be found on your Termii dashboard. |
| variables | yes | Object This is a key-value object containing dynamic data to be inserted into the email template. Each key represents the variable name defined in your template, and each value is the actual content that will replace the variable when the email is sent. For example, if the template created includes variables {{customer_name}}, {{order_id}}, {{current_year}}, {{company_name}}, you must provide corresponding values for each key inside the variables object. |
{
"template_id": "8e9c8d77-2799-435a-b146-47db3406494f",
"email_configuration_id":"00e6dd8a-ecff-4f9d-a256-d0840e15c9c9",
"api_key":"Your API key",
"email":"testa@gmail.com",
"subject": "Your Balance of Wallet",
"variables":{
"name": "Priscilla",
"balance": "333444"
}
}
var data = {
"template_id": "8e9c8d77-2799-435a-b146-47db3406494f",
"email_configuration_id":"00e6dd8a-ecff-4f9d-a256-d0840e15c9c9",
"api_key":"Your API key",
"email":"testa@gmail.com",
"subject": "Your Balance of Wallet",
"variables":{
"name": "Priscilla",
"balance": "333444"
}
}
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_UR/api/templates/send-email");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
var request = require('request');
var data = {
"template_id": "8e9c8d77-2799-435a-b146-47db3406494f",
"email_configuration_id":"00e6dd8a-ecff-4f9d-a256-d0840e15c9c9",
"api_key":"Your API key",
"email":"testa@gmail.com",
"subject": "Your Balance of Wallet",
"variables":{
"name": "Priscilla",
"balance": "333444"
}
}
var options = {
'method': 'POST',
'url': 'https://BASE_UR/api/templates/send-email',
'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_UR/api/templates/send-email"
payload = {
"template_id": "8e9c8d77-2799-435a-b146-47db3406494f",
"email_configuration_id":"00e6dd8a-ecff-4f9d-a256-d0840e15c9c9",
"api_key":"Your API key",
"email":"testa@gmail.com",
"subject": "Your Balance of Wallet",
"variables":{
"name": "Priscilla",
"balance": "333444"
}
}
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
RestClient restClient = new RestClient("https://BASE_UR/api/templates/send-email");
// Create JSON object for the request body
JObject objectBody = new JObject();
objectBody.Add("template_id", "8e9c8d77-2799-435a-b146-47db3406494f");
objectBody.Add("email_configuration_id", "00e6dd8a-ecff-4f9d-a256-d0840e15c9c9");
objectBody.Add("api_key", "Your API key");
objectBody.Add("email", "testa@gmail.com");
objectBody.Add("subject", "Your Balance of Wallet");
JObject variables = new JObject();
variables.Add("name", "Priscilla");
variables.Add("balance", "333444");
objectBody.Add("variables", variables);
RestRequest restRequest = new RestRequest(Method.POST);
restRequest.AddHeader("Content-Type", "application/json");
restRequest.AddParameter("application/json", objectBody.ToString(), ParameterType.RequestBody);
IRestResponse restResponse = restClient.Execute(restRequest);
Console.WriteLine(restResponse.Content);
JSONObject variables = new JSONObject();
variables.put("name", "Priscilla");
variables.put("balance", "333444");
JSONObject payload = new JSONObject();
payload.put("template_id", "8e9c8d77-2799-435a-b146-47db3406494f");
payload.put("email_configuration_id", "00e6dd8a-ecff-4f9d-a256-d0840e15c9c9");
payload.put("api_key", "Your API Key");
payload.put("email", "testa@gmail.com");
payload.put("subject", "Your Balance of Wallet");
payload.put("variables", variables);
// Send POST request
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://BASE_URL/api/email/otp/send")
.header("Content-Type", "application/json")
.body(payload.toString())
.asString();
// Print response
System.out.println(response.getBody());
<?php
$curl = curl_init();
$variables = array(
"name" => "Priscilla",
"balance" => "333444"
);
$data = array(
"template_id" => "8e9c8d77-2799-435a-b146-47db3406494f",
"email_configuration_id" => "00e6dd8a-ecff-4f9d-a256-d0840e15c9c9",
"api_key" => "Your API Key",
"email" => "testa@gmail.com",
"subject" => "Your Balance of Wallet",
"variables" => $variables
);
$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;
Sample Response - 200 OK
{
"code": "ok",
"balance": "11054.9",
"message_id": "3017640904658191180894777",
"message": "Successfully Sent",
"user": "Tobi"
}