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": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}'
import requests
url = "https://api.autosend.com/v1/mails/bulk"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"recipients": [
{
"email": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}
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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
})
})
.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' => '[email protected]',
'name' => 'Jane Smith',
'dynamicData' => [
'firstName' => 'Jane',
'orderNumber' => 'ORD-123',
'orderTotal' => '$19.99'
]
],
[
'email' => '[email protected]',
'name' => 'John Doe',
'dynamicData' => [
'firstName' => 'John',
'orderNumber' => 'ORD-124',
'orderTotal' => '$29.99'
]
]
],
'from' => [
'email' => '[email protected]',
'name' => 'Your Company'
],
'subject' => 'Welcome to Our Platform!',
'html' => '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
'replyTo' => [
'email' => '[email protected]'
]
];
$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": "[email protected]",
"name": "Jane Smith",
"dynamicData": map[string]interface{}{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99",
},
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": map[string]interface{}{
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99",
},
},
},
"from": map[string]string{
"email": "[email protected]",
"name": "Your Company",
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": map[string]string{
"email": "[email protected]",
},
}
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\": \"[email protected]\",\n" +
" \"name\": \"Jane Smith\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"Jane\",\n" +
" \"orderNumber\": \"ORD-123\",\n" +
" \"orderTotal\": \"$19.99\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"email\": \"[email protected]\",\n" +
" \"name\": \"John Doe\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"John\",\n" +
" \"orderNumber\": \"ORD-124\",\n" +
" \"orderTotal\": \"$29.99\"\n" +
" }\n" +
" }\n" +
" ],\n" +
" \"from\": {\n" +
" \"email\": \"[email protected]\",\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\": \"[email protected]\"\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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
}.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": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}'
import requests
url = "https://api.autosend.com/v1/mails/bulk"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"recipients": [
{
"email": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}
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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
})
})
.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' => '[email protected]',
'name' => 'Jane Smith',
'dynamicData' => [
'firstName' => 'Jane',
'orderNumber' => 'ORD-123',
'orderTotal' => '$19.99'
]
],
[
'email' => '[email protected]',
'name' => 'John Doe',
'dynamicData' => [
'firstName' => 'John',
'orderNumber' => 'ORD-124',
'orderTotal' => '$29.99'
]
]
],
'from' => [
'email' => '[email protected]',
'name' => 'Your Company'
],
'subject' => 'Welcome to Our Platform!',
'html' => '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
'replyTo' => [
'email' => '[email protected]'
]
];
$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": "[email protected]",
"name": "Jane Smith",
"dynamicData": map[string]interface{}{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99",
},
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": map[string]interface{}{
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99",
},
},
},
"from": map[string]string{
"email": "[email protected]",
"name": "Your Company",
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": map[string]string{
"email": "[email protected]",
},
}
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\": \"[email protected]\",\n" +
" \"name\": \"Jane Smith\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"Jane\",\n" +
" \"orderNumber\": \"ORD-123\",\n" +
" \"orderTotal\": \"$19.99\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"email\": \"[email protected]\",\n" +
" \"name\": \"John Doe\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"John\",\n" +
" \"orderNumber\": \"ORD-124\",\n" +
" \"orderTotal\": \"$29.99\"\n" +
" }\n" +
" }\n" +
" ],\n" +
" \"from\": {\n" +
" \"email\": \"[email protected]\",\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\": \"[email protected]\"\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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
}.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
string | header
required
Bearer authentication header of the form Bearer
<token>, where <token> is your auth token.Body
Email data to send to multiple recipientsobject[]
required
Array of recipient email addresses and names (maximum 100 recipients)
Maximum 100 recipients per request.
Show child attributes
Show child attributes
string<email>
required
Email addressExample:
"[email protected]"string
Display nameExample:
"Jane Smith"object
Key-value pairs for template variable substitution (Handlebars syntax)Example:
{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
object[]
Cc Recipients array of email address and name object
Show child attributes
Show child attributes
string<email>
required
Email addressExample:
"[email protected]"string
Cc User nameExample:
"Cc User Name"object[]
Bcc Recipients array of email address and name object
Show child attributes
Show child attributes
string<email>
required
Email addressExample:
"[email protected]"string
Bcc User nameExample:
"Bcc User Name"object
required
Sender email address (must be from a verified domain) and name
Show child attributes
Show child attributes
string<email>
required
Email addressExample:
"[email protected]"string
Display nameExample:
"Your Company"object
Key-value pairs for template variable substitution (Handlebars syntax)Example:
{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
string
required
Email subject line (max 998 characters). Required if not using templateId.Maximum length:
998Example: "Welcome to Our Platform!"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: 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>"
object
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"
}
string
Plain text version of the emailExample:
"Welcome! Thanks for signing up."string
ID of the email template to use. Required if not providing html/text.Example:
"A-abc123"object
Reply-to email address and name
Show child attributes
Show child attributes
string<email>
required
Email addressExample:
"[email protected]"string
Display nameExample:
"John Doe"object
Key-value pairs for template variable substitution (Handlebars syntax)Example:
{
"name": "Jane",
"firstName": "Jane",
"orderNumber": "ORD-12345",
"orderTotal": "$99.99"
}
string
ID of the unsubscribe groupExample:
"unsub_group_123"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:
falseboolean
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:
falseobject
Custom 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 completedboolean
Indicates if the request was successfulExample:
trueWas 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": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}'
import requests
url = "https://api.autosend.com/v1/mails/bulk"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"recipients": [
{
"email": "[email protected]",
"name": "Jane Smith",
"dynamicData": {
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99"
}
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": {
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99"
}
}
],
"from": {
"email": "[email protected]",
"name": "Your Company"
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": {
"email": "[email protected]"
}
}
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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
})
})
.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' => '[email protected]',
'name' => 'Jane Smith',
'dynamicData' => [
'firstName' => 'Jane',
'orderNumber' => 'ORD-123',
'orderTotal' => '$19.99'
]
],
[
'email' => '[email protected]',
'name' => 'John Doe',
'dynamicData' => [
'firstName' => 'John',
'orderNumber' => 'ORD-124',
'orderTotal' => '$29.99'
]
]
],
'from' => [
'email' => '[email protected]',
'name' => 'Your Company'
],
'subject' => 'Welcome to Our Platform!',
'html' => '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
'replyTo' => [
'email' => '[email protected]'
]
];
$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": "[email protected]",
"name": "Jane Smith",
"dynamicData": map[string]interface{}{
"firstName": "Jane",
"orderNumber": "ORD-123",
"orderTotal": "$19.99",
},
},
{
"email": "[email protected]",
"name": "John Doe",
"dynamicData": map[string]interface{}{
"firstName": "John",
"orderNumber": "ORD-124",
"orderTotal": "$29.99",
},
},
},
"from": map[string]string{
"email": "[email protected]",
"name": "Your Company",
},
"subject": "Welcome to Our Platform!",
"html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
"replyTo": map[string]string{
"email": "[email protected]",
},
}
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\": \"[email protected]\",\n" +
" \"name\": \"Jane Smith\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"Jane\",\n" +
" \"orderNumber\": \"ORD-123\",\n" +
" \"orderTotal\": \"$19.99\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"email\": \"[email protected]\",\n" +
" \"name\": \"John Doe\",\n" +
" \"dynamicData\": {\n" +
" \"firstName\": \"John\",\n" +
" \"orderNumber\": \"ORD-124\",\n" +
" \"orderTotal\": \"$29.99\"\n" +
" }\n" +
" }\n" +
" ],\n" +
" \"from\": {\n" +
" \"email\": \"[email protected]\",\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\": \"[email protected]\"\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: '[email protected]',
name: 'Jane Smith',
dynamicData: {
firstName: 'Jane',
orderNumber: 'ORD-123',
orderTotal: '$19.99'
}
},
{
email: '[email protected]',
name: 'John Doe',
dynamicData: {
firstName: 'John',
orderNumber: 'ORD-124',
orderTotal: '$29.99'
}
}
],
from: {
email: '[email protected]',
name: 'Your Company'
},
subject: 'Welcome to Our Platform!',
html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
replyTo: {
email: '[email protected]'
}
}.to_json
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"batchId": "ae22c1e0-2022-4f6b-bdca-ce94901fbc6e",
"totalRecipients": 2,
"successCount": 2,
"failedCount": 0
}
}