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:
- Select the Mail Agent that you want to connect to your application.
- Navigate to the Setup Info tab. This will open the Setup Details page.
- From here you can copy your Mail Agent specific send mail token under the API tab.
- 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:
- Navigate to the Mail Agents tab on the left panel of your ZeptoMail account and select the Mail Agent.
- Go to the Templates tab.
- Choose the template you wish to use from the pre-existing templates or create a new template.
- Copy the template ID of your template using the copy icon.
- 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 oftemplate_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
andname
key-value pairs.
- address String
- A valid email address containing a domain that is verified in your Mail Agent.
- name String
- Sender's name.
- Allowed value - A valid sender email address with
- to* JSON array
- Allowed value - JSON object of
email_address
.
- email_address JSON object
- A valid recipient email address with
address
andname
key-value pairs.
- address String
- Recipient's email address field.
- name String
- Recipient's name.
- A valid recipient email address with
- Allowed value - JSON object of
- 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
Parameter Data Type Description error JSON object It consists of code, details, message, and request_id parameters code String The code corresponding to the status of the request made details JSON array It consists of code, message and target parameters target_value String A unique id which is generated for every request code String The code for the error found message String Reason for the error target String The field that caused the error message String The status of the request made HTTP status codes
Status code Description 2xx Success 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"
}