Sending
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.
POST
/
mails
/
bulk
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"
}
}'
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())
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
$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;
?>
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)
}
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();
}
}
}
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
{
"success": true,
"data": {
"batchId": "ae22c1e0-2022-4f6b-bdca-ce94901fbc6e",
"totalRecipients": 2,
"successCount": 2,
"failedCount": 0
}
}
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"
}
}'
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())
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
$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;
?>
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)
}
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();
}
}
}
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
{
"success": true,
"data": {
"batchId": "ae22c1e0-2022-4f6b-bdca-ce94901fbc6e",
"totalRecipients": 2,
"successCount": 2,
"failedCount": 0
}
}
Authorizations
Bearer authentication header of the form Bearer
<token>, where <token> is your auth token.Body
Email data to send to multiple recipientsArray of recipient email addresses and names (maximum 100 recipients)
Maximum 100 recipients per request.
Show child attributes
Show child attributes
Key-value pairs for template variable substitution (Handlebars syntax)Example:
{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
Sender email address (must be from a verified domain) and name
Email subject line (max 998 characters). Required if not using templateId.Maximum length:
998Example: "Welcome to Our Platform!"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: Provide the values for these variables in the
{{variableName}}.
Example:<h1>Hello {{firstName}}!</h1>
<p>Your order #{{orderNumber}} has been shipped.</p>
<p>Total: {{orderTotal}}</p>
dynamicData field (either at the root level for all recipients, or per recipient).Example:html: "<p>Hello {{firstName}}! Sending this email via AutoSend.</p>"
Key-value pairs for template variable substitution (Handlebars syntax). Same data will be used for all recipients.Example:
dynamicData: {
"name": "Valued Customer",
"firstName": "Valued",
"orderNumber": "ORD-12345",
"orderTotal": "$99.99"
}
Reply-to email address and name
Show child attributes
Show child attributes
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:
falseEnable 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:
falseCustom email headers to include with the message as key-value pairs. Applied to every recipient in the batch. Example:
- 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, andX-SES-Message-Tags.
headers: {
"X-Entity-Ref-ID": "order-12345",
"X-Campaign-ID": "welcome-series"
}
Response
Bulk send completedWas this page helpful?
⌘I
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"
}
}'
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())
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
$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;
?>
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)
}
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();
}
}
}
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
{
"success": true,
"data": {
"batchId": "ae22c1e0-2022-4f6b-bdca-ce94901fbc6e",
"totalRecipients": 2,
"successCount": 2,
"failedCount": 0
}
}