Send Email
curl --request POST \
--url https://api.example.com/api/v1/emails \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"templateId": "<string>",
"variables": {},
"attachmentIds": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"replyTo": "<string>",
"headers": {},
"idempotencyKey": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/emails"
payload = {
"from": "<string>",
"to": ["<string>"],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"templateId": "<string>",
"variables": {},
"attachmentIds": ["<string>"],
"cc": ["<string>"],
"bcc": ["<string>"],
"replyTo": "<string>",
"headers": {},
"idempotencyKey": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
to: ['<string>'],
subject: '<string>',
html: '<string>',
text: '<string>',
templateId: '<string>',
variables: {},
attachmentIds: ['<string>'],
cc: ['<string>'],
bcc: ['<string>'],
replyTo: '<string>',
headers: {},
idempotencyKey: '<string>'
})
};
fetch('https://api.example.com/api/v1/emails', 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.example.com/api/v1/emails",
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([
'from' => '<string>',
'to' => [
'<string>'
],
'subject' => '<string>',
'html' => '<string>',
'text' => '<string>',
'templateId' => '<string>',
'variables' => [
],
'attachmentIds' => [
'<string>'
],
'cc' => [
'<string>'
],
'bcc' => [
'<string>'
],
'replyTo' => '<string>',
'headers' => [
],
'idempotencyKey' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/emails"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/emails")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "<string>",
"messageId": "<string>",
"createdAt": "<string>"
}Emails
Send Email
Send transactional email
POST
/
api
/
v1
/
emails
Send Email
curl --request POST \
--url https://api.example.com/api/v1/emails \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"templateId": "<string>",
"variables": {},
"attachmentIds": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"replyTo": "<string>",
"headers": {},
"idempotencyKey": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/emails"
payload = {
"from": "<string>",
"to": ["<string>"],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"templateId": "<string>",
"variables": {},
"attachmentIds": ["<string>"],
"cc": ["<string>"],
"bcc": ["<string>"],
"replyTo": "<string>",
"headers": {},
"idempotencyKey": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
to: ['<string>'],
subject: '<string>',
html: '<string>',
text: '<string>',
templateId: '<string>',
variables: {},
attachmentIds: ['<string>'],
cc: ['<string>'],
bcc: ['<string>'],
replyTo: '<string>',
headers: {},
idempotencyKey: '<string>'
})
};
fetch('https://api.example.com/api/v1/emails', 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.example.com/api/v1/emails",
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([
'from' => '<string>',
'to' => [
'<string>'
],
'subject' => '<string>',
'html' => '<string>',
'text' => '<string>',
'templateId' => '<string>',
'variables' => [
],
'attachmentIds' => [
'<string>'
],
'cc' => [
'<string>'
],
'bcc' => [
'<string>'
],
'replyTo' => '<string>',
'headers' => [
],
'idempotencyKey' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/emails"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/emails")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"templateId\": \"<string>\",\n \"variables\": {},\n \"attachmentIds\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"replyTo\": \"<string>\",\n \"headers\": {},\n \"idempotencyKey\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "<string>",
"messageId": "<string>",
"createdAt": "<string>"
}Send an email using raw content or a pre-built template.
Option 2: Template
Request Body
Sender email address. Must match a verified domain. Supports display name format:
"Name" <email@domain.com>Recipient email address(es). If array, all recipients see each other (single email, not batch).
Email subject line (max 998 characters, no newlines). Required unless using a template.
HTML content of the email. Required if not using
templateId.Plain text fallback content.
Template ID to use instead of raw
html/text. Subject comes from template unless overridden.Key-value pairs for template variable substitution (
{{variable}}).IDs of attachments to include (from the attachments upload flow).
CC recipients.
BCC recipients.
Reply-to email address.
Custom email headers to include.
Unique key to prevent duplicate sends. Valid for 24 hours, max 256 characters.
Content Options
You must provide content in one of two ways: Option 1: Direct Content{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Welcome!",
"html": "<h1>Welcome!</h1>",
"text": "Welcome!"
}
{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"templateId": "welcome-template",
"variables": {
"name": "John",
"plan": "Pro"
}
}
Examples
import { MailBreeze } from "mailbreeze";
const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });
// Send with direct content
const result = await mailbreeze.emails.send({
from: "hello@yourdomain.com",
to: "user@example.com",
subject: "Welcome!",
html: "<h1>Welcome to our platform!</h1>",
text: "Welcome to our platform!",
});
console.log(result.id); // "msg_xxx"
// Send with template
const result = await mailbreeze.emails.send({
from: "hello@yourdomain.com",
to: "user@example.com",
templateId: "welcome-template",
variables: {
name: "John",
plan: "Pro",
},
});
from mailbreeze import MailBreeze
client = MailBreeze(api_key="sk_live_xxx")
# Send with direct content
result = await client.emails.send(
from_="hello@yourdomain.com",
to="user@example.com",
subject="Welcome!",
html="<h1>Welcome to our platform!</h1>",
text="Welcome to our platform!",
)
print(result.id) # "msg_xxx"
# Send with template
result = await client.emails.send(
from_="hello@yourdomain.com",
to="user@example.com",
template_id="welcome-template",
variables={"name": "John", "plan": "Pro"},
)
client := mailbreeze.NewClient("sk_live_xxx")
// Send with direct content
email, err := client.Emails.Send(ctx, &mailbreeze.SendEmailParams{
From: "hello@yourdomain.com",
To: []string{"user@example.com"},
Subject: "Welcome!",
HTML: "<h1>Welcome to our platform!</h1>",
Text: "Welcome to our platform!",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(email.ID) // "msg_xxx"
// Send with template
email, err := client.Emails.Send(ctx, &mailbreeze.SendEmailParams{
From: "hello@yourdomain.com",
To: []string{"user@example.com"},
TemplateID: "welcome-template",
Variables: map[string]any{"name": "John", "plan": "Pro"},
})
$mailbreeze = new MailBreeze('sk_live_xxx');
// Send with direct content
$result = $mailbreeze->emails->send([
'from' => 'hello@yourdomain.com',
'to' => ['user@example.com'],
'subject' => 'Welcome!',
'html' => '<h1>Welcome to our platform!</h1>',
'text' => 'Welcome to our platform!',
]);
echo $result['messageId']; // "abc123@mailbreeze.com"
// Send with template
$result = $mailbreeze->emails->send([
'from' => 'hello@yourdomain.com',
'to' => ['user@example.com'],
'template_id' => 'welcome-template',
'variables' => ['name' => 'John', 'plan' => 'Pro'],
]);
let client = Client::new("sk_live_xxx");
// Send with direct content
let email = client.emails().send(SendEmailParams {
from: "hello@yourdomain.com".to_string(),
to: vec!["user@example.com".to_string()],
subject: Some("Welcome!".to_string()),
html: Some("<h1>Welcome to our platform!</h1>".to_string()),
text: Some("Welcome to our platform!".to_string()),
..Default::default()
}).await?;
println!("{}", email.id); // "msg_xxx"
// Send with template
let email = client.emails().send(SendEmailParams {
from: "hello@yourdomain.com".to_string(),
to: vec!["user@example.com".to_string()],
template_id: Some("welcome-template".to_string()),
variables: Some(json!({"name": "John", "plan": "Pro"})),
..Default::default()
}).await?;
curl -X POST https://api.mailbreeze.com/api/v1/emails \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourdomain.com",
"to": ["user@example.com"],
"subject": "Welcome!",
"html": "<h1>Welcome to our platform!</h1>",
"text": "Welcome to our platform!"
}'
Response
Unique email ID.
Current status:
queued, sent, delivered, bounced, or failed.SMTP message ID.
ISO 8601 timestamp when queued.
Success Response
{
"success": true,
"data": {
"messageId": "ea296955-b253-424b-9bf4-761381e8dedc"
},
"meta": {
"timestamp": "2025-12-27T13:36:06.342Z",
"requestId": "e69b115b-21e5-4051-a0bf-550c39ad7c1a",
"path": "/api/v1/emails"
}
}
Test Mode Response
When using a test API key (sk_test_*), emails are simulated:
Sandbox Response
{
"success": true,
"data": {
"sandbox": true,
"messageId": "sandbox_abc123xyz",
"message": "Email simulated (test mode) - no real email was sent",
"recipients": ["user@example.com"]
},
"meta": {
"timestamp": "2024-01-15T10:30:00.000Z",
"requestId": "req_abc123",
"path": "/api/v1/emails"
}
}
SDKs automatically extract the
data field, so you access result.messageId directly.Errors
| Code | Description |
|---|---|
DNS_VERIFICATION_FAILED | Domain DNS records not verified |
DOMAIN_VALIDATION_FAILED | Domain not active or verified |
FROM_DOMAIN_MISMATCH | From address domain must match verified domain |
TEMPLATE_NOT_FOUND | Template ID doesn’t exist |
TEMPLATE_RENDER_ERROR | Template variable substitution failed |
ATTACHMENT_NOT_FOUND | Attachment ID doesn’t exist |
ATTACHMENT_TOO_LARGE | Attachment exceeds 10MB limit |
EMAIL_TOO_LARGE | Total email exceeds 10MB limit |
SPAM_SCORE_TOO_HIGH | Content flagged as spam |
RECIPIENT_SUPPRESSED | Recipient is on suppression list |
⌘I