Send Email
Send a single transactional or marketing email.
POST /api/v1/emails
Sends a single email. The from address must belong to a verified domain on the account. Authenticate with an X-API-Key header.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
from | string | Yes | Sender address (must be on a verified domain) |
to | string[] | Yes | Recipient addresses |
subject | string | Yes | Email subject line |
html | string | No | HTML body |
text | string | No | Plain-text body |
cc | string[] | No | Carbon copy recipients |
bcc | string[] | No | Blind carbon copy recipients |
reply_to | string | No | Reply-to address |
tags | string[] | No | Labels for filtering in the dashboard |
type | string | No | "transactional" (default) or "marketing" |
At least one of html or text is required.
Response
Returns 200 OK with an email object:
| Field | Type | Description |
|---|---|---|
id | string | Unique email ID |
status | string | "queued", "sent", or "failed" |
from | string | Sender address |
to | string | Primary recipient address |
subject | string | Subject line |
created_at | string | ISO 8601 timestamp |
{
"email": {
"id": "em_01hx...",
"status": "queued",
"from": "noreply@yourdomain.com",
"to": "user@example.com",
"subject": "Your order has shipped",
"created_at": "2024-01-15T10:30:00Z"
}
}Code examples
curl https://api.smail.dev/api/v1/emails \
-H "X-API-Key: sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"from": "noreply@yourdomain.com",
"to": ["user@example.com"],
"subject": "Your order has shipped",
"html": "<p>Your order #1234 is on its way!</p>",
"text": "Your order #1234 is on its way!"
}'const { email } = await smail.emails.send({
from: "noreply@yourdomain.com",
to: ["user@example.com"],
subject: "Your order has shipped",
html: "<p>Your order #1234 is on its way!</p>",
text: "Your order #1234 is on its way!",
});email, err := client.Emails.Send(ctx, smail.SendEmailRequest{
From: "noreply@yourdomain.com",
To: []string{"user@example.com"},
Subject: "Your order has shipped",
HTML: "<p>Your order #1234 is on its way!</p>",
Text: "Your order #1234 is on its way!",
})Error responses
| Status | Error | Description |
|---|---|---|
401 | unauthorized | Missing or invalid API key |
400 | from domain not verified | The from address domain is not verified |
400 | invalid request | Missing required fields |