Purpose
The API is used to send a batch of transactional emails.
Request URL
Method : POST
https://api.zeptomail.com/POST/v1.1/email/batch
Header: Authorization: zoho-enczapikey ***
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
Steps to generate Send mail token
Select the Mail Agent that you want to connect to your application. Navigate to the Setup Info. 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.
Recipient-specific merge field details
Merge fields are dynamic values that will replace the content provided within them. They can set be set in HTML body, text body, client reference and subject. Let's look at the different placements of merge info tag and what they mean.
- Merge info is added within the "to" information :
- The merge info will be applied for the recipient in "to" tag.
- Merge info is added both within and outside the "to" information
- The merge info available within "to" will be applied for the recipient in "to" tag.
- The merge info available outside, will be used for recipients that do not have merge info within the "to" body.
Request Body
- from* JSON object
Allowed value - A valid sender email address with "address" and "name" key-value pairs. The following items should be included in the object :
- 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
- They represent the merge fields of the mail to be sent. The merge fields will be replaced by the values provided within them. They can be set in HTML body, text body, client reference and subject. Merge fields within "to" will be applied to the recipients they are available under.
- subject* String
- The subject of the email to be sent.
- HTML body/textbody String
- This is the body content for your email.Allowed value - Your email body can either be a textbody or a htmlbody
- cc JSON array
- Email addresses of cc'd recipients.
- Allowed value - JSON object of email_address.
- bcc JSON array
- Email addresses of bcc'd recipients.
- Allowed value - JSON object of email_address.
- track_clicks Boolean
- You can enable or disable email click tracking using this. You can enable this tracking under the Email tracking section of your Mail Agent too.
- Allowed value :
- True : Enable email click tracking.
- False : Disable email click tracking
- track_opens Boolean
- You can enable or disable email open tracking using this. You can enable this tracking under the Email tracking section of your Mail Agent too.
- 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.
- attachment 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 : simple text message - plain / text ; image file - image / jpg
- name String
- 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.
- inline_images JSON array
- This is the Inline image added to your email.
- Allowed value - It can either be a base64 encoded content or a file_cache_key or both.
- The base64 content contains mime_type, content and cid parameters.
- 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 be a base64 encoded content or a file_cache_key or both.
- The base64 content contains mime_type, content and cid parameters.
Merge tag within "to"
Copiedcurl "https://api.zeptomail.com/v1.1/email/batch" \
-X POST
-H 'Authorization: Zoho-enczapikey ***'\
-H 'Content-Type: application/json' \
-d '{
"from": { "address": "invoice@zylker.com", "name": "Invoice" },
"subject":"Batch mail Test",
"to": [
{
"email_address":
{
"address": "paul.s@zfashions.com",
"name": "Paul"
},
"merge_info" :
{
"contact" : "98********" ,
"company" : "Z fashions"
}
},
{
"email_address":
{
"address": "rebecca@zcorp.com",
"name": "Rebecca"
},
"merge_info" :
{
"contact" : "87********" ,
"company" : "Z Inc."
}
},
{
"email_address":
{
"address": "george@zfashions.com",
"name": "George"
},
"merge_info" : {
"contact" : "87********" ,
"company" : "Z fashions" }
}
],
"htmlbody":"<div><b>This is a sample email.{{contact}} {{company}}</b></div",
"textbody" : "This is a sample email",
} '
Merge tag within and outside "to"
Copiedcurl 'https://api.zeptomail.com/v1.1/email/batch' \
-X POST
-H 'Authorization: Zoho-enczapikey ***'\
-H 'Content-Type: application/json' \
-d '{
"from": { "address": "invoice@zylker.com", "name": "Invoice" },
"subject":"Batch mail Test",
"to": [
{
"email_address":
{
"address": "paul.s@zfashions.com",
"name": "Paul"
},
"merge_info" :
{
"contact" : "98********" ,
"company" : "Z fashions"
}
},
{
"email_address":
{
"address": "rebecca@zcorp.com",
"name": "Rebecca"
},
"merge_info" :
{
"contact" : "87********" ,
"company" : "Z Inc."
}
},
{
"email_address":
{
"address": "george@zfashions.com",
"name": "George"
},
}
],
"htmlbody":"<div><b>This is a sample email.{{contact}} {{company}}</b></div",
"textbody" : "This is a sample email",
"merge_info" : {
"contact" : "87********" ,
"company" : "Z fashions" }
} '