Send batch and bulk emails

Send batch and bulk emails with attachments.

You can send 'Batch' and 'Bulk' emails to recipients using the same API call.

In a Batch email request, you can send an email to one or more recipients. The email recipients can see all the other recipient names to whom the email is sent. Also, you can send different emails(different email body) to recipients in the same email request.

In a Bulk email request, you can send an email to one or more recipients; however, the recipients cannot see the other Email recipient names.

Send batch emails

Use 'batch email', to send emails to different groups of recipients with different content using a single API.
Use the endpoint: https://api.kaleyra.io/v1/<SID>/email/batch

API Request to send multiple emails to multiple recipients

The following API sends emails to multiple recipients using POST method.

{
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “Sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  : {}
  },
  {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  :  {}
  }

📘

Note:

You can add up to 50 email addresses in the 'To' parameter of the email API.

The following success response is displayed.

HTTP/1.1 202 OK
Content-Type: application/json

{
    "data": [
      {
          "message_id": "123e4567-e89b-12d3-a456-426655440001",
          "to": "[email protected],[email protected]",
          "from": "[email protected]",
          "subject":"sample subject"
      },
     {
          "message_id": "123e4567-e89b-12d3-a456-426655440002",
          "to": "[email protected],[email protected]",
          "from": "[email protected]",
          "subject":"sample subject"
      }
    ],
    "error":[]
}

Request for multiple emails with one invalid request

[
  {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  :{"Model”:”Volkswagen”, “Client-Id”:”786"}
  },
  {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  : {"Model”:”Volkswagen”, “Client-Id”:”786"}
  },
 {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected] ,aaa,[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
  }
]

For the emails that are successfully delivered, a success response is displayed. For the emails that are not sent, an error message is displayed.

The success and the error messages are displayed as follows:

[
  {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello"</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  :{"campaign”:”christmas”, “Client-Id”:”786"}
  },
  {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
        “metadata”  : {"Model”:”Volkswagen”, “Client-Id”:”786"}
  },
 {
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected] ,aaa,[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
  }
]

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": 
    [
      {
          "message_id": "123e4567-e89b-12d3-a456-426655440001",
          "to": "[email protected],[email protected]",
          "from": "[email protected]",
          "subject":"sample subject"
      },
      {
          "message_id": "123e4567-e89b-12d3-a456-426655440003",
          "to": "[email protected],[email protected]",
          "from": "[email protected]",
          "Subject":"sample subject"
      }
    ],
    "error": 
    [ {
    "code": "E12501",
    "type": "Invalid input",
    "parameter": "to",
            "message": "The value [ [email protected] ,aaa,[email protected]] for to parameter is invalid. ",
    "reference": ""
}
    ]
}

Email API with multiple requests and multiple attachments

The following email API example has multiple email requests and multiple attachments in each request.

[
{
"from" : "[email protected]",
"from_name": "Sender Name",
"to": "[email protected]",
"subject": "subject",
"tag": "Sample",
"html_body": "<b>Hello</b>",
"text_body": "Hello",
"reply_to": "[email protected]",
"attachments" :
[
    {
           "content":"https://github.com/kaleyra/kaleyra-python/blob/master/requirements.txt",
           "content_type": "text/plain",
           "filename":"requirements.txt"
    },
        {
           "content":"https://github.com/kaleyra/kaleyra-python/blob/master/requirements.txt",
           "content_type": "text/plain",
           "filename":"requirements.txt"
    }
],
           "metadata": {}
},
{
"from" : "[email protected]",
"from_name": "Sender Name",
"to": "[email protected]",
"subject": "subject",
"tag": "Sample",
"html_body": "<b>Hello</b>",
"text_body": "Hello",
"reply_to": "[email protected]",
"attachments" :
[
    {
           "content":"https://github.com/kaleyra/kaleyra-python/blob/master/requirements.txt",
           "content_type": "text/plain",
           "filename":"requirements.txt"
    },
        {
           "content":"https://github.com/kaleyra/kaleyra-python/blob/master/requirements.txt",
           "content_type": "text/plain",
           "filename":"requirements.txt"
    }
],
"metadata": {}
}
]

The following example success response is displayed.

HTTP/1.1 202 Accepted
Content-Type: application/json


{
    "data": [
        {
               "message_id": "a84fa56e-3be8-49ad-9fd9-eb8454b452f3:1",
               "to": "[email protected],[email protected]",
               "from": "[email protected]",
               "subject": "subject"
        },
        {
               "message_id": "a84fa56e-3be8-49ad-9fd9-eb8454b452f3:2",
               "to": "[email protected],[email protected]",
               "from": "[email protected]",
               "subject": "subject"
        }
    ],

    "error": []
}

Send bulk emails

In a bulk email API, you can send the same email content to multiple recipients using a single email API. Each individual recipient receives an email addressed only to them.

To send batch email, use the endpoint: https://api.kaleyra.io/v1/<SID>/email/bulk

{
        “from”: ”[email protected]”
        “from_name”: “sender”
        “to” : “[email protected],[email protected]”,
        “Subject” : “sample subject”,
        “tag” : “invitation”,
        “html_body” : “<b>Hello</b>”,
        “text_body” : “Hello”,
        “reply_to”  : “[email protected]”
  }

Each individual recipient receives an email addressed only to them and cannot view other recipients' addresses.

{
    "data": [
        {
            "message_id": "716a84bb-7815-4da6-abc3-ee95470c1297:1",
            "to": "[email protected]",
            "from": "[email protected]",
            "subject": "sample subject"
        },
        {
            "message_id": "716a84bb-7815-4da6-abc3-ee95470c1297:2",
            "to": "[email protected]",
            "from": "[email protected]",
            "subject": "sample subject"
        }
    ],
    "error": []
}

Did this page help you?