Adding email templates

Purpose

This API can be used to add an email template.

Request URL

Method : POST

https://api.zeptomail.com/v1.1/mailagents/{mailagent-alias}/templates

OAuth scope

Any one of the following scopes can be used to access this API

scope=Zeptomail.MailTemplates.All

or

scope=Zeptomail.MailTemplates.CREATE

ALL - This will give the basic CRUD access too all the email templates APIs.

The steps to generate and use OAuth token can be found here.

Path parameters

ParameterTypeDescription
mailagent-aliasStringUnique alias value given to the Mail Agent. It is available in the Setup info section of your Mail Agent.

Request body

ParameterTypeDescription
template_name*StringName of the template
template_aliasStringUnique alias for the template. It can be used instead of the template key. It can be obtained from the Edit template section in your ZeptoMail account.
subject*StringSubject to be added in the email template.
htmlbody**StringThe corresponding HTML content of the body in the email template.
textbody**StringPlain text body of the email in the template.

*-Mandatory parameter

**- Atleast one of them is mandatory.

Note:

Templates API can be used while send single emails and batch emails. Refer our help articles on single and batch email template APIs to help you get started with it.

Sample request

Copiedcurl "https://api.zeptomail.com/v1.1/mailagents/{mailagent-alias}/templates\"
-X POST
-H "Authorization : Zoho-oauthtoken ***"\
-H "Content-Type : application/json" \
-d '{
    "template_name": "E-invite",
    "subject": "Invitation to the event",
    "htmlbody": "<h1> Hi {{name}}</h1>, invitation link {{link}}",
    "template_alias": "e-invite emails"
}'

Sample response

Copied{
  "data": [
    {
      "htmlbody": "<h1> Hi {{name}}</h1>, invitation link {{link}}",
      "upload_time": "19 Sep 2022 11:32 AM",
      "template_name": "E-invite",
      "template_key": "ea****607",
      "template_size": 9,
      "modified_time": "19 Sep 2022 11:32 AM",
      "subject": "Invitation to the event",
    }
  ],
  "message": "OK",
  "object": "templates"
}