curl --request POST \
--url https://api.sapt.ai/emails/batch/queue \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"email": "[email protected]",
"params": {
"name": "Alice",
"company": "Acme"
}
},
{
"email": "[email protected]",
"params": {
"name": "Bob",
"company": "Tech Co"
}
},
{
"email": "[email protected]"
}
],
"template": {
"subject": "Welcome {{name}}!",
"html": "<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>",
"text": "Hello {{name}}! Welcome to {{company}}"
},
"trackingId": "campaign_2024_11_newsletter",
"emailType": "marketing",
"clientProjectId": "550e8400-e29b-41d4-a716-446655440000",
"metadata": {
"campaign": "november-newsletter",
"source": "api"
}
}
'import requests
url = "https://api.sapt.ai/emails/batch/queue"
payload = {
"recipients": [{
"email": "[email protected]",
"params": {
"name": "Alice",
"company": "Acme"
}
}, {
"email": "[email protected]",
"params": {
"name": "Bob",
"company": "Tech Co"
}
}, { "email": "[email protected]" }],
"template": {
"subject": "Welcome {{name}}!",
"html": "<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>",
"text": "Hello {{name}}! Welcome to {{company}}"
},
"trackingId": "campaign_2024_11_newsletter",
"emailType": "marketing",
"clientProjectId": "550e8400-e29b-41d4-a716-446655440000",
"metadata": {
"campaign": "november-newsletter",
"source": "api"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipients: [
{email: '[email protected]', params: {name: 'Alice', company: 'Acme'}},
{email: '[email protected]', params: {name: 'Bob', company: 'Tech Co'}},
{email: '[email protected]'}
],
template: {
subject: 'Welcome {{name}}!',
html: '<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>',
text: 'Hello {{name}}! Welcome to {{company}}'
},
trackingId: 'campaign_2024_11_newsletter',
emailType: 'marketing',
clientProjectId: '550e8400-e29b-41d4-a716-446655440000',
metadata: {campaign: 'november-newsletter', source: 'api'}
})
};
fetch('https://api.sapt.ai/emails/batch/queue', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sapt.ai/emails/batch/queue",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipients' => [
[
'email' => '[email protected]',
'params' => [
'name' => 'Alice',
'company' => 'Acme'
]
],
[
'email' => '[email protected]',
'params' => [
'name' => 'Bob',
'company' => 'Tech Co'
]
],
[
'email' => '[email protected]'
]
],
'template' => [
'subject' => 'Welcome {{name}}!',
'html' => '<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>',
'text' => 'Hello {{name}}! Welcome to {{company}}'
],
'trackingId' => 'campaign_2024_11_newsletter',
'emailType' => 'marketing',
'clientProjectId' => '550e8400-e29b-41d4-a716-446655440000',
'metadata' => [
'campaign' => 'november-newsletter',
'source' => 'api'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sapt.ai/emails/batch/queue"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sapt.ai/emails/batch/queue")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapt.ai/emails/batch/queue")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"trackingId": "<string>",
"totalBatches": 123,
"totalRecipients": 123,
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}Queue batch email send
Queue a batch email send for asynchronous processing via Cloudflare Queue. Supports template-based emails with parameter substitution. Requires X-App-Key header for authentication.
curl --request POST \
--url https://api.sapt.ai/emails/batch/queue \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"email": "[email protected]",
"params": {
"name": "Alice",
"company": "Acme"
}
},
{
"email": "[email protected]",
"params": {
"name": "Bob",
"company": "Tech Co"
}
},
{
"email": "[email protected]"
}
],
"template": {
"subject": "Welcome {{name}}!",
"html": "<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>",
"text": "Hello {{name}}! Welcome to {{company}}"
},
"trackingId": "campaign_2024_11_newsletter",
"emailType": "marketing",
"clientProjectId": "550e8400-e29b-41d4-a716-446655440000",
"metadata": {
"campaign": "november-newsletter",
"source": "api"
}
}
'import requests
url = "https://api.sapt.ai/emails/batch/queue"
payload = {
"recipients": [{
"email": "[email protected]",
"params": {
"name": "Alice",
"company": "Acme"
}
}, {
"email": "[email protected]",
"params": {
"name": "Bob",
"company": "Tech Co"
}
}, { "email": "[email protected]" }],
"template": {
"subject": "Welcome {{name}}!",
"html": "<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>",
"text": "Hello {{name}}! Welcome to {{company}}"
},
"trackingId": "campaign_2024_11_newsletter",
"emailType": "marketing",
"clientProjectId": "550e8400-e29b-41d4-a716-446655440000",
"metadata": {
"campaign": "november-newsletter",
"source": "api"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipients: [
{email: '[email protected]', params: {name: 'Alice', company: 'Acme'}},
{email: '[email protected]', params: {name: 'Bob', company: 'Tech Co'}},
{email: '[email protected]'}
],
template: {
subject: 'Welcome {{name}}!',
html: '<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>',
text: 'Hello {{name}}! Welcome to {{company}}'
},
trackingId: 'campaign_2024_11_newsletter',
emailType: 'marketing',
clientProjectId: '550e8400-e29b-41d4-a716-446655440000',
metadata: {campaign: 'november-newsletter', source: 'api'}
})
};
fetch('https://api.sapt.ai/emails/batch/queue', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sapt.ai/emails/batch/queue",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipients' => [
[
'email' => '[email protected]',
'params' => [
'name' => 'Alice',
'company' => 'Acme'
]
],
[
'email' => '[email protected]',
'params' => [
'name' => 'Bob',
'company' => 'Tech Co'
]
],
[
'email' => '[email protected]'
]
],
'template' => [
'subject' => 'Welcome {{name}}!',
'html' => '<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>',
'text' => 'Hello {{name}}! Welcome to {{company}}'
],
'trackingId' => 'campaign_2024_11_newsletter',
'emailType' => 'marketing',
'clientProjectId' => '550e8400-e29b-41d4-a716-446655440000',
'metadata' => [
'campaign' => 'november-newsletter',
'source' => 'api'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sapt.ai/emails/batch/queue"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sapt.ai/emails/batch/queue")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapt.ai/emails/batch/queue")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipients\": [\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Alice\",\n \"company\": \"Acme\"\n }\n },\n {\n \"email\": \"[email protected]\",\n \"params\": {\n \"name\": \"Bob\",\n \"company\": \"Tech Co\"\n }\n },\n {\n \"email\": \"[email protected]\"\n }\n ],\n \"template\": {\n \"subject\": \"Welcome {{name}}!\",\n \"html\": \"<html><body><h1>Hello {{name}}!</h1><p>Welcome to {{company}}</p></body></html>\",\n \"text\": \"Hello {{name}}! Welcome to {{company}}\"\n },\n \"trackingId\": \"campaign_2024_11_newsletter\",\n \"emailType\": \"marketing\",\n \"clientProjectId\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"metadata\": {\n \"campaign\": \"november-newsletter\",\n \"source\": \"api\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"trackingId": "<string>",
"totalBatches": 123,
"totalRecipients": 123,
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}Authorizations
JWT token obtained from /api/auth/token endpoint. Token is verified using JWKS and must include a valid user identifier.
Body
List of recipients with optional per-recipient template parameters (1-10,000)
1 - 10000 elementsShow child attributes
Show child attributes
[
{
"email": "[email protected]",
"params": { "name": "Alice", "company": "Acme" }
},
{
"email": "[email protected]",
"params": { "name": "Bob", "company": "Tech Co" }
},
{ "email": "[email protected]" }
]
Email template with variable placeholders for per-recipient substitution
Show child attributes
Show child attributes
Custom tracking ID for this batch send
1 - 100"campaign_2024_11_newsletter"
Email category for tracking (optional)
"marketing"
Client project ID for tracking (optional)
"550e8400-e29b-41d4-a716-446655440000"
Additional metadata for tracking (optional)
Show child attributes
Show child attributes
{
"campaign": "november-newsletter",
"source": "api"
}