curl --request GET \
--url https://api-{dc}.moengage.com/v2/email-templates \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: <content-type>' \
--header 'MOE-APPKEY: <moe-appkey>'import requests
url = "https://api-{dc}.moengage.com/v2/email-templates"
headers = {
"MOE-APPKEY": "<moe-appkey>",
"Content-Type": "<content-type>",
"Authorization": "Basic <encoded-value>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'MOE-APPKEY': '<moe-appkey>',
'Content-Type': '<content-type>',
Authorization: 'Basic <encoded-value>'
}
};
fetch('https://api-{dc}.moengage.com/v2/email-templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-{dc}.moengage.com/v2/email-templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: <content-type>",
"MOE-APPKEY: <moe-appkey>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-{dc}.moengage.com/v2/email-templates"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("MOE-APPKEY", "<moe-appkey>")
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-{dc}.moengage.com/v2/email-templates")
.header("MOE-APPKEY", "<moe-appkey>")
.header("Content-Type", "<content-type>")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{dc}.moengage.com/v2/email-templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["MOE-APPKEY"] = '<moe-appkey>'
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"templates": [
{
"template_id": "645a2bd910e0307e6d7f7717",
"template_name": "Coupon_code_template",
"is_archived": false,
"builder_supported": false,
"editor": "Froala Editor",
"created_date": "2023-05-09 11:17:43.112000",
"updated_at": "2023-05-09 11:18:37.692000",
"updated_by": "jane.doe@example.com"
}
],
"no_of_templates": 13
}
}{
"status": "error",
"data": {
"code": 400,
"title": "Invalid template id",
"description": "Please provide a valid template id"
}
}{
"status": "error",
"data": {
"code": 401,
"title": "Authentication required",
"description": "Invalid APP_ID used in Authentication Header"
}
}{
"status": "error",
"data": {
"code": 429,
"title": "rate limiter exception",
"description": "Exceeded rate limit for this app"
}
}{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}Get All Templates
The Get All Templates API fetches the list of all the email templates available in your MoEngage account.
curl --request GET \
--url https://api-{dc}.moengage.com/v2/email-templates \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: <content-type>' \
--header 'MOE-APPKEY: <moe-appkey>'import requests
url = "https://api-{dc}.moengage.com/v2/email-templates"
headers = {
"MOE-APPKEY": "<moe-appkey>",
"Content-Type": "<content-type>",
"Authorization": "Basic <encoded-value>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'MOE-APPKEY': '<moe-appkey>',
'Content-Type': '<content-type>',
Authorization: 'Basic <encoded-value>'
}
};
fetch('https://api-{dc}.moengage.com/v2/email-templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-{dc}.moengage.com/v2/email-templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: <content-type>",
"MOE-APPKEY: <moe-appkey>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-{dc}.moengage.com/v2/email-templates"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("MOE-APPKEY", "<moe-appkey>")
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-{dc}.moengage.com/v2/email-templates")
.header("MOE-APPKEY", "<moe-appkey>")
.header("Content-Type", "<content-type>")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{dc}.moengage.com/v2/email-templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["MOE-APPKEY"] = '<moe-appkey>'
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"templates": [
{
"template_id": "645a2bd910e0307e6d7f7717",
"template_name": "Coupon_code_template",
"is_archived": false,
"builder_supported": false,
"editor": "Froala Editor",
"created_date": "2023-05-09 11:17:43.112000",
"updated_at": "2023-05-09 11:18:37.692000",
"updated_by": "jane.doe@example.com"
}
],
"no_of_templates": 13
}
}{
"status": "error",
"data": {
"code": 400,
"title": "Invalid template id",
"description": "Please provide a valid template id"
}
}{
"status": "error",
"data": {
"code": 401,
"title": "Authentication required",
"description": "Invalid APP_ID used in Authentication Header"
}
}{
"status": "error",
"data": {
"code": 429,
"title": "rate limiter exception",
"description": "Exceeded rate limit for this app"
}
}{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}Rate Limit
The rate limits are at the app level, and a maximum of thousand (sum of all the API requests per app)requests are allowed for an app per minute.Authorizations
The API request will be authenticated through Basic Authentication. Basic Authentication sends a Base64-encoded string containing your username and password with every API request.
The username and password details can be obtained from the MoEngage Dashboard. If you're using the API for the first time, follow these steps:
- Navigate to Settings -> Account -> APIs.
- Copy the following details:
- Username: Under Workspace ID (earlier app id), click the copy icon to copy the username.
- Password: In the API keys section, click the copy icon in the Data tile to copy the API key.
- Use these details to authenticate the API requests.
Headers
This is your MoEngage account's WORKSPACE ID which must be passed along with the request. You can find your MoEngage WORKSPACE ID at Settings -> Account -> APIs -> WORKSPACE ID.
Set the Content-Type header to application/json.
application/json This authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, refer to Authentication.
Query Parameters
This parameter represents the page number. If this value is not specified, it will be considered as one by default. Each page will have a batch size of 20( 20 templates will be returned in a page).
1
Response
This response is returned when the request is processed successfully.
Was this page helpful?