Templates API - Batch Emails
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:
- Navigate to the Mail Agents tab on the left panel of your ZeptoMail account and select a Mail Agent that you want to connect to your application.
- On the top right section, click on Setup Info (gear icon). 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 use the default Send Mail Token or generate a new one.
Steps to copy Template ID:
- Navigate to the Mail Agents tab on the left panel of your ZeptoMail account and select the Mail Agent.
- Hover 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.
Sending batch emails using Templates
Purpose
This API is used to send transactional emails using templates. It can be used to send a batch of emails using the template.
Request URL
https://api.zeptomail.com/v1.1/email/template/batch
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/batch
Query String:
POST
HOST: https://api.zeptomail.com
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
Parameter | Data Type | Description | |
template_key*/ template_alias | String | Unique key identifier for your template. | |
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 the placeholders with multiple values for different recipients. The merge tags of the mail to be sent. Merge Tags can be set in HTML body, text body, subject and client reference. Merge tags are tags that are set in the string. 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. Whereas in the case of 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 email responses will be addressed. Allowed value - A valid email address containing a domain that is verified in your Mail Agent. | |
name | String | Name for the reply-to parameter. | |
track_clicks | Boolean | You can enable or disable email click tracking here. You can also enable email click tracking in your Mail Agent under Email Tracking section. Note: The API setting will override the Mail Agent settings in your ZeptoMail account. Allowed value True - Enable email click tracking. False - Disable email click tracking. | |
track_opens | Boolean | You can enable or disable email open tracking. You can also enable email open tracking in your Mail Agent under Email Tracking section. Note: The API setting will override the Mail Agent settings in your ZeptoMail account. Allowed value True - Enable email open tracking. False - Disable email open tracking. | |
client_reference | String | An identifier set by the user to track a particular transaction. | |
mime_headers | JSON object | The additional headers to be sent in the email for your reference purposes. | |
attachments | JSON array | The attachments you want to add to your transactional emails. Click here to view the list of unsupported formats. Allowed value - JSON object of attachments. It can either be a base64 encoded content or file_cache_key or both. | |
content | String | The content of your attachment. Allowed value - Base64 encoded value of a file. | |
mime_type | String | Indicates the content type in your attachment. Allowed value | |
name | The file name of your attachment. | ||
file_cache_key | String | The unique key for your attached files in a Mail Agent. Obtain file_cache_key from the File Cache section in your Mail Agent. | |
name | String | The file name of your attachment as in the File Cache section in your Mail Agent. Obtain file name from the File Cache section in your Mail Agent. | |
cid | String | the content id used by html body for content lookup. Each content should be given a separate cid value. Allowed value It can either a base64 encoded content or a file_cache_key or both. |
Success Response Parameters
Parameter | Data Type | Description |
data | JSON array | It consists of code, additional_info and message parameters |
code | String | The code corresponding to a success response |
additional_info | JSON array | Provides additional information about the action performed in the request |
message | String | The action taken for this request |
message | String | The status of the request made |
request_id | String | A unique id which is generated for every request |
object | It signifies that the response is for email API |
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/batch" \
-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"
},
"merge_info": {
"contact": "960*******23",
"company": "Zylker"
}
},
{
"email_address": {
"address": "charles@zylker.com",
"name": "Charles"
},
"merge_info": {
"contact": "860*******13",
"company": "Zillum"
}
}
],
"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.b1.1567dc40-e96c-11eb-bfc9-525400256d50.17ac4746004",
"object": "email"
}