Get all templates

The Get All Templates API fetches the list of all the email templates available in your MoEngage account.

API Endpoint

API Endpoint
GET  https://api-x.moengage.com/v2/email-templates?page=1

Each customer is hosted on a different data center; you can find your data center number (value of X) by checking the data center and API endpoint mapping page.

Authentication

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. It encodes a 'username:password' string in Base64 and appends the encoded string with 'Basic '. This string is included in the authorization header as shown below:

{"Authorization":"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}

The username and password details can be obtained from the MoEngage Dashboard. We've revamped the settings UI in the Dashboard. If you're using the API for the first time, follow these steps for the revamped and old UIs:

Revamped UI

  1. Navigate to Settings -> Account -> APIs.
  2. Click Generate Key in the Data tile in the API Keys section, and click Save.
  3. Use the App ID as the username and the Data API Key as the password to generate the authentication header.

Old UI

  1. Navigate to Settings -> APIs -> DATA API Settings.
  2. Click Generate Key.
  3. Click Save on the Data APIs settings section. 
  4. Use the DATA API ID as the username and the DATA API KEY as the password to generate the authentication header.

Request Parameter

Key Required Value Description

page

Required

Integer

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

Example: /v2/email-templates?page=1

Request Headers

Key Required Sample Values Description

MOE-APPKEY

Required

{"MOE-APPKEY": "APP ID"}

This is your MoEngage account's APP ID that has to be passed along with the request. You can find your MoEngage APP ID in the following navigation on the Dashboard:

Revamped UI: Settings -> Account -> APIs -> App ID

Old UI: Settings -> API -> General Settings -> DATA API

Content-Type

Required

{"Content-Type": "application/json"}

Set the Content-Type header to application/json.

Authorization

Required

{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}

This authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, refer to Authentication.

Response

Key Data Type Description
status String

This field contains the status of the request and denotes whether it was successful or not.

Example: "status": "success", "status": "error"

data JSON Object

This field contains the id of the created template when the request is successful and the error details in case of an unsuccessful request.

Successful Request

The data object contains the following fields in the case of a successful request:

Structure:

    "data": {

        "templates": [

        {
           "template_id": "<Template ID 1>",
            "template_name": "<TemplateName>",
            "is_archived": <true/false>,
            "builder_supported": false,
            "editor": "Froala Editor",
            "created_date": "<Creation Timestamp>",
            "updated_at": "<Updation Timestamp>",
            "updated_by": "<details about who created or updated the template>"
        },
        {
           "template_id": "<Template ID 2>",
            "template_name": "<TemplateName>",
            "is_archived": <true/false>,
            "builder_supported": false,
            "editor": "Froala Editor",
            "created_date": "<Creation Timestamp>",
            "updated_at": "<Updation Timestamp>",
            "updated_by": "<details about who created or updated the template>"
        },
        {
           "template_id": "<Template ID 3>",
            "template_name": "<TemplateName>",
            "is_archived": <true/false>,
            "builder_supported": false,
            "editor": "Froala Editor",
            "created_date": "<Creation Timestamp>",
            "updated_at": "<Updation Timestamp>",
            "updated_by": "<details about who created or updated the template>"
        },...{}

         ],

       "no_of_templates": "<no of templates returned in the page>"

}

For each of the templates fetched, the following information is available:

        "template_id": "<Template id - the unique identifier that is created at the time of template creation>",

        "template_name": "<name of the template being fetched>",

        "is_archived": "false",

        "builder_supported": "false",

        "editor": "Froala Editor",

        "created_date": "<timestamp of template creation>",

        "updated_at": "<timestamp of when the template was last updated>",

        "updated_by": "<details about who created or updated the template"

Note:

  • For the Froala editor, the builder_supported value is false. Thus, for all the templates created using APIs, this would be false. Also, the number of templates returned is also available in the response.

Unsuccessful Request

The data object contains the following fields in the case of errors:

Structure:

 "data": {

    "code": "<error_code>", 

    "title": "<type of error>",

    "description": "<error_message>"

}

The error object contains the following fields:

  • code - This field contains the error code and is a String. Example: 400 (for a Bad Request), 401( for Authentication failures), and so on. This field is present in the response only in the case of errors.
  • title - This field contains the type of error encountered. Example: Bad Request, Authentication Required, and so on. This field is present in the response only in the case of errors.
  • description - This field describes why the request has failed and is a String. Example: 'MOE-APPKEY header is invalid or empty'.

Response Codes

Status Code Request State Description

200

Success

This response is returned when the request is processed successfully. 

400

Bad Request

This response is returned when the required parameters are missing from the request or when the provided parameters are invalid, or when a template already exists with the same version, name, or id.

401

Authorization Failure

This response is returned when the authorization parameters are missing in the HTTP Auth Header.

429

Rate Limit Breach

This response is returned when the number of requests per minute has exceeded the rate limit or the number of templates has exceeded the allowed quota per channel.

5xx

Internal Server Error

This response is returned when the system runs into an unexpected error.

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.

Sample cURL Request

cURL
curl --location --request GET 'https://api-x.moengage.com/v2/email-templates/?page=1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic e3tEQVRBX0FQSV9JRH19Ont7REFUQV9BUElfS0VZfX0=' \
--header 'MOE-APPKEY: {DATA_API_ID}' \
--data-raw ''

Sample Response

200 400 401 429 5xx
Sample Response for a successful request
{
   "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"
         },
         {
           "template_id": "645a2c0d10e0307e6d7f7719",
           "template_name": "Season_Sale_Template",
           "is_archived": false,
           "builder_supported": false,
           "editor": "Froala Editor",
           "created_date": "2023-05-09 11:18:35.398000",
           "updated_at": "2023-05-09 11:18:35.398000",
           "updated_by": "john.doe@example.com"
          },
          {
            "template_id": "645a2bf510e0307e6d7f7718",
            "template_name": "Season_Sale_Template",
            "is_archived": false,
            "builder_supported": false,
            "editor": "Froala Editor",
            "created_date": "2023-05-09 11:18:11.500000",
            "updated_at": "2023-05-09 11:18:11.500000",
            "updated_by": "john.doe@example.com"
           }
      ],
      "no_of_templates": 13
    }
  }

Postman Collections

We have made it easy for you to test the APIs. Click here to view it in Postman.

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?