Create/update email templates 

You can use this API to create email templates on your MoEngage dashboard. You can access these templates inside your Email Campaigns.

Note 

Templates created using these APIs cannot be edited using the Drag & Drop Editor on MoEngage dashboard. 

MoEngage provides the following APIs to create/update templates:
1. Create/update one template 
2. Bulk create/update templates  

1. Create/update single template 

API Endpoint

POST https://api-0X.moengage.com/upsertEmailTemplate

Here, 0X refers to your datacenter on MoEngage. Read more about MoEngage DCs

Request Headers

Key Sample value Description
Authorization Basic <User:Password>

We accept Base 64 encoded Username:Password

Here,
- Username is the APP_ID. You can access your MoEngage App ID  by navigating to Settings > APIs> APP ID on your MoEngage Dashboard.

- Password is the Data API Key. You can access your MoEngage Data API Key  by navigating to Settings > APIs> Data API Key on your MoEngage Dashboard.

Content-Type application/json --

Request Parameters 

Parameter Type Data type Description
id Optional String If the id passed is already present in MoEngage only then the template will be updated. Else, we will create a new template. 
name Mandatory String Name of the template that you want to create. If the template already exists, it will update the existing template. 
- Only alpha numerics, underscores are allowed.
- Length should be between 5 & 100
subject Optional String Subject of your email campaign template 
attachments Optional Hash map 

Attachments to added in the email campaigns 

- Should start with https & end with valid extension

- Each attachment size should be less than 6 mb

- Total attachment size should be less than 20mb

- Maximum of 10 attachments are allowed within a template

html Mandatory String Message body of your email campaign template.  

- html tag and body tag (with text/tags) is mandatory

- script tag is not allowed not be present

sender_name Optional  String Name of the sender that you want to add in your email campaign
source Mandatory String Source of the template creation - customer name or partner name 

Note- Only alphanumerics, spaces, underscores are allowed

updated_by  Mandatory String User/service that is creating/updating the template  

Note - Only alphanumerics, spaces, hyphen are allowed OR this should be email id in proper format.

Create Sample request- 

{
"name": "template 1",
"subject": "test email",
"attachments": ["public image url"],
"sender_name": "test user",
"html": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title></title><style>\n \n body table{\n border-collapse: collapse;\n }\n\n body table td, body table th{\n border: 1px solid rgb(0, 0, 0);\n }\n\n \t\t\t</style></head><body aria-disabled=\"false\"><p>tstfgkb</p></body></html>",
"source": "partner",
"updated_by": "user@gmail.com"
}

Update Sample request- 

{
"id", "template id 1"
"name": "template 1",
"subject": "test email",
"attachments": ["public image url"],
"sender_name": "test user",
"html": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title></title><style>\n \n body table{\n border-collapse: collapse;\n }\n\n body table td, body table th{\n border: 1px solid rgb(0, 0, 0);\n }\n\n \t\t\t</style></head><body aria-disabled=\"false\"><p>tstfgkb</p></body></html>",
"source": "partner",
"updated_by": "user@gmail.com"
}

Response

Sample response 

{
"status": "success",
"code": 200,
"data": {
"msg": "Custom email template saved",
"id": "template id 1"
}
}

2. Bulk create/update templates 

Template limit  

You can create/update up to 50 templates at a time. 

API Endpoint

POST https://api-0X.moengage.com/bulkUpsertEmailTemplate

Here, 0X refers to your datacenter on MoEngage. Read more about MoEngage DCs

Request Headers

Key Sample value Description
Authorization Basic <User:Password>

We accept Base 64 encoded Username:Password

Here,
- Username is the APP_ID. You can access your MoEngage App ID  by navigating to Settings > APIs> APP ID on your MoEngage Dashboard.

- Password is the Data API Key. You can access your MoEngage Data API Key  by navigating to Settings > APIs> Data API Key on your MoEngage Dashboard.

Content-Type application/json --

Request Parameters 

Parameter Type Data type Description
id Optional String If the id passed is already present in MoEngage only then the template will be updated. Else, we will create a new template. 
name Mandatory String Name of the template that you want to create. If the template already exists, it will update the existing template. 
- Only alpha numerics, underscores are allowed.
- Length should be between 5 & 100
subject Optional String Subject of your email campaign template 
attachments Optional Hash map 

Attachments to added in the email campaigns 

- Should start with https & end with valid extension

- Each attachment size should be less than 6 mb

- Total attachment size should be less than 20mb

- Maximum of 10 attachments are allowed within a template

html Mandatory String Message body of your email campaign template 
sender_name Optional  String Name of the sender that you want to add in your email campaign
source Mandatory String Source of the template creation - customer name or partner name
Note- Only alphanumerics, spaces, underscores are allowed 
updated_by  Mandatory String User/service that is creating/updating the template  

Note - Only alphanumerics, spaces, hyphen are allowed OR this should be email id in proper format.

Sample request- 

[{
"name": "template 1",
"subject": "test email",
"attachments": ["public image url 1", "public image url 2"],
"sender_name": "test",
"html": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title></title><style>\n \n body table{\n border-collapse: collapse;\n }\n\n body table td, body table th{\n border: 1px solid rgb(0, 0, 0);\n }\n\n \t\t\t</style></head><body aria-disabled=\"false\"><p>tstfgkb</p></body></html>",
"source": "partner name",
"updated_by": "user@gmail.com"
},
{
"name": "template 2",
"subject": "test email 2",
"attachments": ["public image url 1", "public image url 2"],
"sender_name": "test",
"html": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title></title><style>\n \n body table{\n border-collapse: collapse;\n }\n\n body table td, body table th{\n border: 1px solid rgb(0, 0, 0);\n }\n\n \t\t\t</style></head><body aria-disabled=\"false\"><p>tstfgkb</p></body></html>",
"source": "partner name",
"updated_by": "user@gmail.com"
}]

Response

Sample response 

{
"status": "success",
"code": 200,
"data": {
"updated_templates": ["template id 1"],
"new_templates": ["template id 2"]
}
}
 

Accessing templates in MoEngage campaigns 

Once the templates are created, you will be able to access them in Step 2 of your Email Campaigns. You will see the newly created templates under the My saved templates section. 
Screenshot_2022-09-20_at_7.46.36_PM.png

Click here to know more about using templates in Email Campaigns. 

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