Send up to 100 transactional emails in a single API request. Reduce overhead and improve throughput for notifications, alerts, and bulk transactional email.
from ark import Arkclient = Ark()result = client.emails.send_batch( emails=[ { "from_": "notifications@yourdomain.com", "to": ["user1@example.com"], "subject": "Your weekly digest", "html": "<p>Here is what happened this week...</p>" }, { "from_": "notifications@yourdomain.com", "to": ["user2@example.com"], "subject": "Your weekly digest", "html": "<p>Here is what happened this week...</p>" } ])print(f"Accepted: {result.data.accepted}, Failed: {result.data.failed}")
import Ark from 'ark';const client = new Ark();const result = await client.emails.sendBatch({ emails: [ { from: 'notifications@yourdomain.com', to: ['user1@example.com'], subject: 'Your weekly digest', html: '<p>Here is what happened this week...</p>', }, { from: 'notifications@yourdomain.com', to: ['user2@example.com'], subject: 'Your weekly digest', html: '<p>Here is what happened this week...</p>', }, ],});console.log(`Accepted: ${result.data.accepted}, Failed: ${result.data.failed}`);
require "ark_email"client = ArkEmail::Client.newresult = client.emails.send_batch( emails: [ { from: "notifications@yourdomain.com", to: ["user1@example.com"], subject: "Your weekly digest", html: "<p>Here is what happened this week...</p>" }, { from: "notifications@yourdomain.com", to: ["user2@example.com"], subject: "Your weekly digest", html: "<p>Here is what happened this week...</p>" } ])puts "Accepted: #{result.data.accepted}, Failed: #{result.data.failed}"
client := ark.NewClient()result, err := client.Emails.SendBatch(ctx, ark.EmailSendBatchParams{ Emails: []ark.BatchEmail{ { From: "notifications@yourdomain.com", To: []string{"user1@example.com"}, Subject: "Your weekly digest", HTML: ark.String("<p>Here is what happened this week...</p>"), }, { From: "notifications@yourdomain.com", To: []string{"user2@example.com"}, Subject: "Your weekly digest", HTML: ark.String("<p>Here is what happened this week...</p>"), }, },})if err != nil { log.Fatal(err)}fmt.Printf("Accepted: %d, Failed: %d\n", result.Data.Accepted, result.Data.Failed)
curl -X POST https://api.arkhq.io/v1/emails/batch \ -H "Authorization: Bearer $ARK_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "emails": [ { "from": "notifications@yourdomain.com", "to": ["user1@example.com"], "subject": "Your weekly digest", "html": "<p>Here is what happened this week...</p>" }, { "from": "notifications@yourdomain.com", "to": ["user2@example.com"], "subject": "Your weekly digest", "html": "<p>Here is what happened this week...</p>" } ] }'
users = get_usersemails = users.map do |user| { from: "hello@yourdomain.com", to: [user.email], subject: "Welcome, #{user.first_name}!", html: "<h1>Hello #{user.first_name}</h1><p>Thanks for joining us!</p>", metadata: { user_id: user.id } }endresult = client.emails.send_batch(emails: emails)
users := getUsers()emails := make([]ark.BatchEmail, len(users))for i, user := range users { emails[i] = ark.BatchEmail{ From: "hello@yourdomain.com", To: []string{user.Email}, Subject: fmt.Sprintf("Welcome, %s!", user.FirstName), HTML: ark.String(fmt.Sprintf("<h1>Hello %s</h1><p>Thanks for joining us!</p>", user.FirstName)), Metadata: map[string]string{"user_id": user.ID}, }}result, _ := client.Emails.SendBatch(ctx, ark.EmailSendBatchParams{Emails: emails})
Metadata in webhooks: Each email’s metadata is returned in webhook events, letting you correlate delivery events back to your users. See metadata validation rules for limits (10 keys, 40 char keys, 500 char values).
import timebatch_id = f"weekly-digest-{int(time.time())}"emails = [ { "from_": "digest@yourdomain.com", "to": [user.email], "subject": "Your Weekly Digest", "html": generate_digest(user), "tag": batch_id # Single tag for filtering this batch } for user in users]result = client.emails.send_batch(emails=emails)# Later, filter emails by batchbatch_emails = client.emails.list(tag=batch_id)
const batchId = `weekly-digest-${Date.now()}`;const emails = users.map(user => ({ from: 'digest@yourdomain.com', to: [user.email], subject: 'Your Weekly Digest', html: generateDigest(user), tag: batchId, // Single tag for filtering this batch}));const result = await client.emails.sendBatch({ emails });// Later, filter emails by batchconst batchEmails = await client.emails.list({ tag: batchId });
batch_id = "weekly-digest-#{Time.now.to_i}"emails = users.map do |user| { from: "digest@yourdomain.com", to: [user.email], subject: "Your Weekly Digest", html: generate_digest(user), tag: batch_id # Single tag for filtering this batch }endresult = client.emails.send_batch(emails: emails)# Later, filter emails by batchbatch_emails = client.emails.list(tag: batch_id)
batchID := fmt.Sprintf("weekly-digest-%d", time.Now().Unix())emails := make([]ark.BatchEmail, len(users))for i, user := range users { emails[i] = ark.BatchEmail{ From: "digest@yourdomain.com", To: []string{user.Email}, Subject: "Your Weekly Digest", HTML: ark.String(generateDigest(user)), Tag: ark.String(batchID), // Single tag for filtering this batch }}result, _ := client.Emails.SendBatch(ctx, ark.EmailSendBatchParams{Emails: emails})// Later, filter emails by batchbatchEmails, _ := client.Emails.List(ctx, ark.EmailListParams{Tag: ark.String(batchID)})