Templates API - Single Email

You can use this API to send emails using templates. Refer to the Templates help documentation to see how you can create templates and to see which API is suitable for you. 

Pre-requisite:

You will require a Send Mail token and the Reference ID of the template you wish to use while sending emails via this API.

Steps to generate Send mail token:

  1. Select the Mail Agent that you want to connect to your application.
  2. Navigate to the Setup Info tab. This will open the Setup Details page.
  3. From here you can copy your Mail Agent specific send mail token under the API tab.
  4. You can either use the default Send Mail Token or generate a new one. 

    Mail Agents >> Setup Info >> Send Mail Token >> Click to copy icon.

Steps to copy Template ID:

  1. Navigate to the Mail Agents tab on the left panel of your ZeptoMail account and select the Mail Agent.
  2. Go to the Templates tab.
  3. Choose the template you wish to use from the pre-existing templates or create a new template.
  4. Copy the template ID of your template using the copy icon.
  5. You have to paste this ID in the body of your code. 

Sending a single email using Templates

Purpose

This API is used to send transactional emails using templates. It can be used to send one email at a time using the template.

Request URL

https://api.zeptomail.com/v1.1/email/template

Authorization token

You need to add send mail token to authenticate your API requests. This is a unique token that you can generate within your Mail Agent in your ZeptoMail account. Use the send mail token as a header when you call ZeptoMail REST Email Sending API.

Example

POST /v1.1/email/template

Query String:

Method: POST
HOST: https://api.zeptomail.com/v1.1/email/template
Header:
Authorization: zoho-enczapikey <space> <send mail token>

Note:

You can scroll down the sample code section of this page to view the sample request and sample response.

Request Body

* - Mandatory parameters

  • template_key* / template_alias  String
    • Unique key identifier for your template.
    • template_alias is the alias name given to the template key. It can be used in place of template_key.
  • bounce_address  String
    • The email address to which bounced emails will be sent.
    • Allowed value - A valid bounce email address as configured in your Mail Agent.
  • from*  JSON object
    • Allowed value - A valid sender email address with address and name key-value pairs.
    • address  String
      • A valid email address containing a domain that is verified in your Mail Agent.
    • name  String
      • Sender's name.
  • to*  JSON array
    • Allowed value - JSON object of email_address.
    • email_address  JSON object
      • A valid recipient email address with address and name key-value pairs.
      • address  String
        • Recipient's email address field.
      • name  String
        • Recipient's name.
  • merge_info*  JSON object
    • You can use merge tags to replace placeholders with multiple values for different recipients.
    • Merge tags can be set in HTML body, text body, subject, and client reference.
    • These tags will be replaced by the value provided in this param for that tag.
    • In the case of single email API, the merge tag is common for all recipients. In batch emails, the merge tag is specific to each recipient.
  • reply_to  JSON array
    • Allowed value - JSON object of reply-to email addresses.
    • address  String
      • The email address to which the recipient's responses will be addressed. Must contain a verified domain.
    • name  String
      • Name for the reply-to parameter.
  • track_clicks  Boolean
    • Enable or disable ema

      Failure Response Parameters

      ParameterData TypeDescription
      errorJSON objectIt consists of code, details, message, and request_id parameters
      codeStringThe code corresponding to the status of the request made
      detailsJSON arrayIt consists of code, message and target parameters
      target_valueStringA unique id which is generated for every request
      codeStringThe code for the error found
      messageStringReason for the error
      targetStringThe field that caused the error
      messageStringThe status of the request made

      HTTP status codes

      Status codeDescription
      2xxSuccess
      4xx

      Failure.

      Action needed at the user end to fix the error.

      5xx

      Failure.

      Action needed at ZeptoMail server to fix the error.

      Error Codes

Note:

Before you get started it is important to know that ZeptoMail is for sending transactional emails like welcome emailers, password resets emails, OTPs. We do not support sending of bulk emails or promotional emails like newsletters or marketing campaign emails. If you are looking for a bulk email provider, you can visit Zoho Campaigns.

Sample Request

Copiedcurl "https://api.zeptomail.com/v1.1/email/template"\
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization:Zoho-enczapikey ***" \
-d {
    "template_key": "ea36f19a.2bec9ad9c994ee6f.k1.7207ab80-da56-11eb-850c-525400256d50.17a6198be38",
    "bounce_address": "bounce@bounce.zylker.com",
    "from": {
        "address": "rebecca@zylker.com",
        "name": "Rebecca"
    },
    "to": [
        {
            "email_address": {
                "address": "paula@zylker.com",
                "name": "Paula M"
            }
        },
        {
            "email_address": {
                "address": "charles@zylker.com",
                "name": "Charles"
            }
        }
    ],
    "cc": [
        {
            "email_address": {
                "address": "tucker@zylker.com",
                "name": "Tucker"
            }
        },
        {
            "email_address": {
                "address": "vienna@zylker.com",
                "name": "Vienna"
            }
        }
    ],
    "bcc": [
        {
            "email_address": {
                "address": "priya@zylker.com",
                "name": "Priya"
            }
        },
        {
            "email_address": {
                "address": "Selena@zylker.com",
                "name": "Selena"
            }
        }
    ],
    "merge_info": {
                  "meeting_link":"https://meeting.zoho.com/join?key=103666049*************22c92ca4"
                      },
    "reply_to": [
        {
            "address": "rebecca@zylker.com",
            "name": "Rebecca"
        }
    ],
    "client_reference": "1234",
    "mime_headers": {
        "X-Test": "test"
    }
}'

Sample Response

Copied{
  "data": [
    {
      "code": "EM_104",
      "additional_info": [],
      "message": "Email request received"
    }
  ],
  "message": "OK",
  "request_id": "ea36f19a.2bec9ad9c994ee6f.m1.cc7d93d0-e966-11eb-95aa-525400ada42a.17ac451bd8d",
  "object": "email"
}