> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Bulk Email

> Sends the same email to multiple recipients in a single API request. This endpoint is identical to the send email endpoint, with the only difference being that `recipients` is an array of recipients instead of a single recipient. Maximum limit: 100 recipients per request.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.autosend.com/v1/mails/bulk \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "recipients": [
      {
        "email": "customer1@example.com",
        "name": "Jane Smith",
        "dynamicData": {
          "firstName": "Jane",
          "orderNumber": "ORD-123",
          "orderTotal": "$19.99"
        }
      },
      {
        "email": "customer2@example.com",
        "name": "John Doe",
        "dynamicData": {
          "firstName": "John",
          "orderNumber": "ORD-124",
          "orderTotal": "$29.99"
        }
      }
    ],
    "from": {
      "email": "hello@mail.yourdomain.com",
      "name": "Your Company"
    },
    "subject": "Welcome to Our Platform!",
    "html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
    "replyTo": {
      "email": "support@yourdomain.com"
    }
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.autosend.com/v1/mails/bulk"

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  payload = {
      "recipients": [
          {
              "email": "customer1@example.com",
              "name": "Jane Smith",
              "dynamicData": {
                  "firstName": "Jane",
                  "orderNumber": "ORD-123",
                  "orderTotal": "$19.99"
              }
          },
          {
              "email": "customer2@example.com",
              "name": "John Doe",
              "dynamicData": {
                  "firstName": "John",
                  "orderNumber": "ORD-124",
                  "orderTotal": "$29.99"
              }
          }
      ],
      "from": {
          "email": "hello@mail.yourdomain.com",
          "name": "Your Company"
      },
      "subject": "Welcome to Our Platform!",
      "html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
      "replyTo": {
          "email": "support@yourdomain.com"
      }
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  fetch('https://api.autosend.com/v1/mails/bulk', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      recipients: [
        {
          email: 'customer1@example.com',
          name: 'Jane Smith',
          dynamicData: {
            firstName: 'Jane',
            orderNumber: 'ORD-123',
            orderTotal: '$19.99'
          }
        },
        {
          email: 'customer2@example.com',
          name: 'John Doe',
          dynamicData: {
            firstName: 'John',
            orderNumber: 'ORD-124',
            orderTotal: '$29.99'
          }
        }
      ],
      from: {
        email: 'hello@mail.yourdomain.com',
        name: 'Your Company'
      },
      subject: 'Welcome to Our Platform!',
      html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
      replyTo: {
        email: 'support@yourdomain.com'
      }
    })
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```php PHP theme={null}
  <?php

  $url = 'https://api.autosend.com/v1/mails/bulk';

  $data = [
      'recipients' => [
          [
              'email' => 'customer1@example.com',
              'name' => 'Jane Smith',
              'dynamicData' => [
                  'firstName' => 'Jane',
                  'orderNumber' => 'ORD-123',
                  'orderTotal' => '$19.99'
              ]
          ],
          [
              'email' => 'customer2@example.com',
              'name' => 'John Doe',
              'dynamicData' => [
                  'firstName' => 'John',
                  'orderNumber' => 'ORD-124',
                  'orderTotal' => '$29.99'
              ]
          ]
      ],
      'from' => [
          'email' => 'hello@mail.yourdomain.com',
          'name' => 'Your Company'
      ],
      'subject' => 'Welcome to Our Platform!',
      'html' => '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
      'replyTo' => [
          'email' => 'support@yourdomain.com'
      ]
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer <token>',
      'Content-Type: application/json'
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      url := "https://api.autosend.com/v1/mails/bulk"
      
      payload := map[string]interface{}{
          "recipients": []map[string]interface{}{
              {
                  "email": "customer1@example.com",
                  "name":  "Jane Smith",
                  "dynamicData": map[string]interface{}{
                      "firstName":   "Jane",
                      "orderNumber": "ORD-123",
                      "orderTotal":  "$19.99",
                  },
              },
              {
                  "email": "customer2@example.com",
                  "name":  "John Doe",
                  "dynamicData": map[string]interface{}{
                      "firstName":   "John",
                      "orderNumber": "ORD-124",
                      "orderTotal":  "$29.99",
                  },
              },
          },
          "from": map[string]string{
              "email": "hello@mail.yourdomain.com",
              "name":  "Your Company",
          },
          "subject": "Welcome to Our Platform!",
          "html":     "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
          "replyTo": map[string]string{
              "email": "support@yourdomain.com",
          },
      }
      
      jsonData, _ := json.Marshal(payload)
      
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")
      
      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println("Error:", err)
          return
      }
      defer resp.Body.Close()
      
      fmt.Println("Response Status:", resp.Status)
  }
  ```

  ```java Java theme={null}
  import java.io.OutputStream;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.nio.charset.StandardCharsets;

  public class SendBulkEmail {
      public static void main(String[] args) {
          try {
              URL url = new URL("https://api.autosend.com/v1/mails/bulk");
              HttpURLConnection con = (HttpURLConnection) url.openConnection();
              
              con.setRequestMethod("POST");
              con.setRequestProperty("Authorization", "Bearer <token>");
              con.setRequestProperty("Content-Type", "application/json");
              con.setDoOutput(true);
              
              String jsonInputString = "{\n" +
                  "  \"recipients\": [\n" +
                  "    {\n" +
                  "      \"email\": \"customer1@example.com\",\n" +
                  "      \"name\": \"Jane Smith\",\n" +
                  "      \"dynamicData\": {\n" +
                  "        \"firstName\": \"Jane\",\n" +
                  "        \"orderNumber\": \"ORD-123\",\n" +
                  "        \"orderTotal\": \"$19.99\"\n" +
                  "      }\n" +
                  "    },\n" +
                  "    {\n" +
                  "      \"email\": \"customer2@example.com\",\n" +
                  "      \"name\": \"John Doe\",\n" +
                  "      \"dynamicData\": {\n" +
                  "        \"firstName\": \"John\",\n" +
                  "        \"orderNumber\": \"ORD-124\",\n" +
                  "        \"orderTotal\": \"$29.99\"\n" +
                  "      }\n" +
                  "    }\n" +
                  "  ],\n" +
                  "  \"from\": {\n" +
                  "    \"email\": \"hello@mail.yourdomain.com\",\n" +
                  "    \"name\": \"Your Company\"\n" +
                  "  },\n" +
                  "  \"subject\": \"Welcome to Our Platform!\",\n" +
                  "  \"html\": \"<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>\",\n" +
                  "  \"replyTo\": {\n" +
                  "    \"email\": \"support@yourdomain.com\"\n" +
                  "  }\n" +
                  "}";
              
              try (OutputStream os = con.getOutputStream()) {
                  byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                  os.write(input, 0, input.length);
              }
              
              int status = con.getResponseCode();
              System.out.println("Response Status: " + status);
              
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  uri = URI('https://api.autosend.com/v1/mails/bulk')

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri.path)
  request['Authorization'] = 'Bearer <token>'
  request['Content-Type'] = 'application/json'

  request.body = {
    recipients: [
      {
        email: 'customer1@example.com',
        name: 'Jane Smith',
        dynamicData: {
          firstName: 'Jane',
          orderNumber: 'ORD-123',
          orderTotal: '$19.99'
        }
      },
      {
        email: 'customer2@example.com',
        name: 'John Doe',
        dynamicData: {
          firstName: 'John',
          orderNumber: 'ORD-124',
          orderTotal: '$29.99'
        }
      }
    ],
    from: {
      email: 'hello@mail.yourdomain.com',
      name: 'Your Company'
    },
    subject: 'Welcome to Our Platform!',
    html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
    replyTo: {
      email: 'support@yourdomain.com'
    }
  }.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "batchId": "ae22c1e0-2022-4f6b-bdca-ce94901fbc6e",
      "totalRecipients": 2,
      "successCount": 2,
      "failedCount": 0
    }
  }
  ```
</ResponseExample>

***

### Authorizations

<ParamField path="Authorizations" type="string | header" required>
  Bearer authentication header of the form Bearer `<token>`, where `<token>` is your auth token.
</ParamField>

### Body

Email data to send to multiple recipients

<ParamField path="recipients" type="object[]" required>
  Array of recipient email addresses and names (maximum 100 recipients)

  <Note>
    Maximum 100 recipients per request.
  </Note>

  <Expandable title="child attributes">
    <ParamField path="email" type="string<email>" required>
      Email address

      Example: `"customer1@example.com"`
    </ParamField>

    <ParamField path="name" type="string">
      Display name

      Example: `"Jane Smith"`
    </ParamField>

    <ParamField path="dynamicData" type="object">
      Key-value pairs for template variable substitution (Handlebars syntax)

      Example:

      ```jsx theme={null}
      {
      "firstName": "Jane",
      "orderNumber": "ORD-123",
      "orderTotal": "$19.99"
      }
      ```
    </ParamField>

    <ParamField path="cc" type="object[]">
      Cc Recipients array of email address and name object

      <Expandable title="child attributes">
        <ParamField path="email" type="string<email>" required>
          Email address

          Example: `"cc@example.com"`
        </ParamField>

        <ParamField path="name" type="string">
          Cc User name

          Example: `"Cc User Name"`
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField path="bcc" type="object[]">
      Bcc Recipients array of email address and name object

      <Expandable title="child attributes">
        <ParamField path="email" type="string<email>" required>
          Email address

          Example: `"bcc@example.com"`
        </ParamField>

        <ParamField path="name" type="string">
          Bcc User name

          Example: `"Bcc User Name"`
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="from" type="object" required>
  Sender email address (must be from a verified domain) and name

  <Expandable title="child attributes">
    <ParamField path="from.email" type="string<email>" required>
      Email address

      Example: `"hello@mail.yourdomain.com"`
    </ParamField>

    <ParamField path="from.name" type="string">
      Display name

      Example: `"Your Company"`
    </ParamField>

    <ParamField path="dynamicData" type="object">
      Key-value pairs for template variable substitution (Handlebars syntax)

      Example:

      ```jsx theme={null}
      {
      "firstName": "Jane",
      "orderNumber": "ORD-123",
      "orderTotal": "$19.99"
      }
      ```
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="subject" type="string" required>
  Email subject line (max 998 characters). Required if not using templateId.

  Maximum length: `998`

  Example: `"Welcome to Our Platform!"`
</ParamField>

<ParamField path="html" type="string">
  HTML content of the email. Required if not using templateId.

  **Handlebars Template Variables:**

  Use Handlebars syntax for template variables in your HTML. Variables are wrapped in double curly braces: `{{variableName}}`.
  Example:

  ```html theme={null}
  <h1>Hello {{firstName}}!</h1>
  <p>Your order #{{orderNumber}} has been shipped.</p>
  <p>Total: {{orderTotal}}</p>
  ```

  Provide the values for these variables in the `dynamicData` field (either at the root level for all recipients, or per recipient).

  Example:

  ```jsx theme={null}
  html: "<p>Hello {{firstName}}! Sending this email via AutoSend.</p>"
  ```
</ParamField>

<ParamField path="dynamicData" type="object">
  Key-value pairs for template variable substitution (Handlebars syntax). Same data will be used for all recipients.

  Example:

  ```jsx theme={null}
  dynamicData: {
    "name": "Valued Customer",
    "firstName": "Valued",
    "orderNumber": "ORD-12345",
    "orderTotal": "$99.99"
  }
  ```
</ParamField>

<ParamField path="text" type="string">
  Plain text version of the email

  Example: `"Welcome! Thanks for signing up."`
</ParamField>

<ParamField path="templateId" type="string">
  ID of the email template to use. Required if not providing html/text.

  Example: `"A-abc123"`
</ParamField>

<ParamField path="replyTo" type="object">
  Reply-to email address and name

  <Expandable title="child attributes">
    <ParamField path="replyTo.email" type="string<email>" required>
      Email address

      Example: `"support@yourdomain.com"`
    </ParamField>

    <ParamField path="replyTo.name" type="string">
      Display name

      Example: `"John Doe"`
    </ParamField>

    <ParamField path="replyTo.dynamicData" type="object">
      Key-value pairs for template variable substitution (Handlebars syntax)

      Example:

      ```jsx theme={null}
      {
      "name": "Jane",
      "firstName": "Jane",
      "orderNumber": "ORD-12345",
      "orderTotal": "$99.99"
      }
      ```
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="unsubscribeGroupId" type="string">
  ID of the unsubscribe group

  Example: `"unsub_group_123"`
</ParamField>

<ParamField path="trackingClick" type="boolean">
  Enable or disable click tracking for links in the email. When enabled, links are rewritten so clicks can be tracked. If omitted, the project-level setting configured in your AutoSend dashboard is used.

  Example: `false`
</ParamField>

<ParamField path="trackingOpen" type="boolean">
  Enable or disable open tracking for the email. When enabled, a tracking pixel is added to record opens. If omitted, the project-level setting configured in your AutoSend dashboard is used.

  Example: `false`
</ParamField>

<ParamField path="headers" type="object">
  Custom email headers to include with the message as key-value pairs. Applied to every recipient in the batch.

  <Note>
    * Maximum 20 custom headers per email.
    * Header names must match `^[A-Za-z0-9-]{1,76}$` (ASCII letters, digits, and hyphens, up to 76 characters).
    * Header values can be up to 1000 characters.
    * Reserved headers managed by AutoSend or the underlying mail transport cannot be overridden, including: `From`, `To`, `Cc`, `Bcc`, `Subject`, `Date`, `Message-ID`, `Return-Path`, `Sender`, `Reply-To`, `Received`, `DKIM-Signature`, `MIME-Version`, `Content-Type`, `Content-Transfer-Encoding`, `List-Unsubscribe`, `List-Unsubscribe-Post`, `X-SES-Configuration-Set`, and `X-SES-Message-Tags`.
  </Note>

  Example:

  ```jsx theme={null}
  headers: {
    "X-Entity-Ref-ID": "order-12345",
    "X-Campaign-ID": "welcome-series"
  }
  ```
</ParamField>

### Response

<span className="text-sm">Bulk send completed</span>

<ResponseField name="success" type="boolean">
  Indicates if the request was successful

  Example: `true`
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="child attributes">
    <ResponseField name="data.batchId" type="string">
      Unique identifier for the batch

      Example: `"ae22c1e0-2022-4f6b-bdca-ce94901fbc6e"`
    </ResponseField>

    <ResponseField name="data.totalRecipients" type="integer">
      Total number of recipients

      Example: `2`
    </ResponseField>

    <ResponseField name="data.successCount" type="integer">
      Number of successfully queued emails

      Example: `2`
    </ResponseField>

    <ResponseField name="data.failedCount" type="integer">
      Number of failed emails

      Example: `0`
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /mails/bulk
openapi: 3.1.0
info:
  title: AutoSend API
  description: AutoSend REST API for managing contacts and sending emails
  version: 1.0.0
servers:
  - url: https://api.autosend.com/v1
security:
  - bearerAuth: []
paths:
  /mails/bulk:
    post:
      summary: Bulk Send Email
      description: >-
        Sends the same email to multiple recipients in a single API request.
        This endpoint is identical to the send email endpoint, with the only
        difference being that `recipients` is an array of recipients instead of
        a single recipient. Maximum limit: 100 recipients per request.
components: {}

````