SendBulkEmail method
Sends multiple template emails from an address in the folder. The folder is selected based on the service account the request originates from.
A single request contains a shared template and emails to send. For each email, you specify recipients, data to populate the template, headers, and tags.
Request
POST /v2/email/outbound-bulk-emails HTTP/2
Request headers
Use common request headers in your requests.
Request body
{
"ConfigurationSetName": "string",
"FromEmailAddress": "<sender_address>",
"ReplyToAddresses": [
"<reply-to_address>"
],
"DefaultEmailTags": [
{
"Name": "<label_name>",
"Value": "<label_value>"
}
],
"DefaultContent": {
"Template": {
"Headers": [
{
"Name": "<header>",
"Value": "<value>"
}
],
"TemplateContent": {
"Html": "<HTML_template>",
"Subject": "<subject_template>",
"Text": "<text_template>"
},
"TemplateData": "<data_to_populate_template>"
}
},
"BulkEmailEntries": [
{
"Destination": {
"ToAddresses": [
"<recipient_address>"
],
"CcAddresses": [
"<copy_recipient_address>"
],
"BccAddresses": [
"<blind_copy_recipient_address>"
]
},
"ReplacementEmailContent": {
"ReplacementTemplate": {
"ReplacementTemplateData": "<data_to_populate_template>"
}
},
"ReplacementHeaders": [
{
"Name": "<header>",
"Value": "<value>"
}
],
"ReplacementTags": [
{
"Name": "<label_name>",
"Value": "<label_value>"
}
]
}
]
}
|
Parameter |
Description |
|
|
Type: String. Name of the configuration used to send emails. If not specified, the system uses the configuration associated with the Yandex Cloud Postbox address. |
|
|
Type: String. Address the emails are sent from. The address must be verified. This is a required setting. |
|
|
Type: Array. Addresses where recipients' replies will be sent. |
|
|
Type: Array. Labels that apply to all emails in the request.
The label name and value may contain Latin letters, numbers, hyphens, and underscores. Maximum length is 256 characters. |
|
|
Type: Object. Object with common email content. |
|
|
Type: Object. Template type. The email template is passed in the request. |
|
|
Type: Array. Headers that apply to all emails in the request.
|
|
|
Type: Object. Contains an email template:
Make sure to specify at least one of the following parameters: either |
|
|
Type: String. Default data used to populate the template. A JSON object serialized to a string. |
|
|
Type: Array. List of emails to send. The request must contain at least one element. |
|
|
Type: Object. Object containing the address for sending the letter.
Make sure to specify at least one address in |
|
|
Type: Object. Data that overrides the email contents for an individual |
|
|
Type: Object. Object with data for substitution into the individual email template. |
|
|
Type: String. Data for filling the template of an individual email. A JSON object serialized to a string. Values from |
|
|
Type: Array. Headers of an individual email. They complement or override the headers from |
|
|
Type: Array. Labels of an individual email. They complement or override the labels from |
Limits
The SendBulkEmail method has the following limits:
- The maximum number of
BulkEmailEntrieselements in a single request is 50. - The maximum total number of recipients across all
BulkEmailEntrieselements is 500. - The maximum total size of
TemplateContent.Subject,TemplateContent.Text, andTemplateContent.Htmlcombined is 1 MB. - The maximum number of variables in a template is 50.
Template uses the Handlebars
Responses
200 OK
{
"BulkEmailEntryResults": [
{
"Status": "SUCCESS",
"MessageId": "<email_ID>"
},
{
"Status": "INVALID_PARAMETER",
"Error": "<error_description>"
}
]
}
|
Parameter |
Description |
|
|
Type: Array. Email sending results. The order of elements in the response corresponds to that |
|
|
Type: String. Status of processing an individual email. If the email is accepted for sending, |
|
|
Type: String. Unique ID of the email. It is returned for emails with the |
|
|
Type: String. Error description. Returned for emails that were not accepted for sending. |
If the error applies to the entire request, the method returns a request-level error. If the error only applies to an individual BulkEmailEntries element, the method returns 200 OK, and the error is indicated in the corresponding BulkEmailEntryResults element.
Errors
For all errors, the response body has the same format:
{
"Code": "<error_name>",
"message": "<error_description>"
}
The name of the error is taken from its code, e.g., BadRequestException.
The possible errors include:
|
Error code |
Description |
|
|
The request contains invalid headers or parameters. |
|
|
The sender is not listed among the allowed senders in the address settings. |
|
|
The service account that sent the request was permanently restricted from sending emails. |
|
|
The service account that sent the request was temporarily restricted from sending emails. |
|
|
The email contains invalid data. |
|
|
The address the email comes from is not verified. |
|
|
The requested resource was not found. |
|
|
The request quota was exceeded. |
|
|
The request limit was exceeded. |