Send an email
Every option of POST /v1/emails: recipients, content, attachments, tags, headers and scheduling. It also covers sending up to 100 emails in one call, resending, and finding emails you sent.
Send an email
POST/v1/emails
Send from, to, subject and at least one of html or text. Sendfern checks the request, stores the email and answers with 201 Created right away. Sending happens in the background, so the first status is queued.
curl https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@acme.com>",
"to": "user@example.com",
"reply_to": "support@acme.com",
"subject": "Your order has shipped",
"html": "<p>Your order <strong>#1042</strong> is on its way.</p>",
"text": "Your order #1042 is on its way.",
"tags": {"type": "shipping"}
}'In live mode, your account must be approved and the From address must be on a verified domain (or a subdomain of one). Otherwise the request is 403 with account_not_active or domain_not_verified, and nothing is stored. Test keys need neither. See Going live.
Body parameters
fromstringrequired- The sender, as
hello@acme.comorAcme <hello@acme.com>. The display name is kept and the address is lower-cased. At most 320 characters, no line breaks. tostring | string[]required- One address or a list. Addresses are stored lower-cased, without display names, and duplicates are removed.
to,ccandbcctogether may have at most 50 recipients. ccstring | string[]- Copy recipients. Same rules as to.
bccstring | string[]- Blind copy recipients. Same rules as to.
reply_tostring | string[]- Where replies go. One address or a list.
subjectstringrequired- At most 998 characters, with no line breaks. Required unless you send a
template_id. htmlstring- The HTML body. Send
html,textor both. textstring- The plain-text body.
headersobject- Extra headers as name to value. See Custom headers for the rules.
tagsobject- Up to 10 name to value pairs for your own bookkeeping, for example
{"type": "welcome"}. Each value is a string of at most 256 characters. See Tags. attachmentsobject[]- Files as
{filename, content, content_type}, withcontentbase64-encoded. At most 7 MB in total, decoded. See Attachments. scheduled_atstring- An ISO 8601 time in the future, at most 30 days ahead, for example
2026-12-01T09:00:00Z. See Scheduling. template_idstring- Send a stored template (
tpl_...) instead ofsubject,htmlandtext. Sending any of those three with a template is a400. See Templates. variablesobject- Values for the template's placeholders, as strings or numbers. Only allowed with
template_id.
A request that breaks a rule is 400 with code invalid_parameter, and param names the field. See Errors.
The email object
The response is the email Sendfern created:
{
"id": "em_VNqV5JEIqYYeYbZRhbPrJ6",
"object": "email",
"mode": "live",
"status": "queued",
"from": "Acme <hello@acme.com>",
"to": ["user@example.com"],
"cc": [],
"bcc": [],
"reply_to": ["support@acme.com"],
"subject": "Your order has shipped",
"tags": {"type": "shipping"},
"broadcast_id": null,
"error": null,
"scheduled_at": null,
"sent_at": null,
"created_at": "2026-11-28T10:19:04Z"
}idstring- The email's id, starting with
em_. modestringliveortest, from the key that created it.statusstring- Where the email is now:
queuedorscheduledat first. See Email lifecycle for every status. from, to, cc, bcc, reply_to, subject, tagsas sent- What you sent, after cleaning. Recipient fields are always lists.
broadcast_idstring | null- The broadcast this email belongs to, or
nullfor an email you sent through the API. errorstring | null- Why the email failed, when its status is
failed. scheduled_atstring | null- When a scheduled email is due.
sent_atstring | null- When Sendfern handed the email over for delivery.
created_atstring- When the email was created.
HTML and plain text
Send html, text or both. When you send both, mail clients show the HTML and fall back to the text. Sending both is a good habit, because some people read mail in text-only clients.
Sendfern sends your HTML as you wrote it. Write it the way email clients expect: tables for layout and inline styles. To keep a body in Sendfern and fill it in per email, use templates.
Attachments
Each attachment is an object with a filename and its content encoded as base64. The total size of all attachments, decoded, may be at most 7 MB.
filenamestringrequired- The name the recipient sees, at most 255 characters. It may not contain
/,\, double quotes or control characters. contentstringrequired- The file, base64-encoded. Anything that is not valid base64 is rejected.
content_typestring- The MIME type, for example
application/pdforimage/png. At most 100 characters.
curl https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <billing@acme.com>",
"to": "user@example.com",
"subject": "Your invoice",
"text": "Your invoice for November is attached.",
"attachments": [
{
"filename": "invoice-1042.pdf",
"content": "'"$(base64 < invoice-1042.pdf | tr -d '\n')"'",
"content_type": "application/pdf"
}
]
}'Tags
Tags are name to value pairs that you attach to an email, for example {"type": "shipping"} or {"user_id": "u_123"}. You can set up to 10 per email, and each value is a string of at most 256 characters. Recipients never see them.
Tags come back on the email object and in every webhook event for the email, so you can match an event to your own records without storing the email id. To find emails by tag, filter the list with ?tag=name:value:
curl -G https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
--data-urlencode "tag=type:shipping"The filter matches emails where the tag name has exactly that value. A tag without a colon is a 400.
Custom headers
Use headers to add your own headers to the message, as an object of name to value.
curl https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@acme.com>",
"to": "user@example.com",
"subject": "Your order has shipped",
"text": "Your order #1042 is on its way.",
"headers": {"X-Order-Id": "1042", "X-Entity-Ref-ID": "order-1042"}
}'- Names are 1 to 100 characters: letters, digits and hyphens.
- Values are at most 998 characters and may not contain line breaks.
- Sendfern sets the envelope headers itself, so you cannot set
From,To,Cc,Bcc,Subject,Date,Reply-To,Sender,Return-Path,Message-ID,MIME-Version,Content-Type,Content-Transfer-Encoding,DKIM-SignatureorReceived. The check ignores case. Use the body fields for From, recipients, Reply-To and Subject.
A header that breaks these rules is a 400 with the message "The header 'X' cannot be set."
Scheduling
Add scheduled_at to send later. It must be in the future and at most 30 days ahead. Give a time zone (a Z or an offset like +01:00); times are stored in UTC. The email is created with status scheduled and goes out within about a minute of that time.
curl https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@acme.com>",
"to": "user@example.com",
"subject": "Your trial ends tomorrow",
"text": "Your Acme trial ends tomorrow.",
"scheduled_at": "2026-12-01T09:00:00Z"
}'Your account and domain are checked when you schedule the email, and the account again when it goes out. Suppressed recipients are removed at send time, not when you schedule. See Email lifecycle.
Cancel a scheduled email
POST/v1/emails/{id}/cancel
Cancel an email before it goes out. The response is the email with status canceled. Only a scheduled email can be canceled: any other status, including one that has started sending, is 400 not_cancelable. A canceled email cannot be scheduled again; send a new one instead.
curl -X POST https://api.sendfern.com/v1/emails/em_VNqV5JEIqYYeYbZRhbPrJ6/cancel \
-H "Authorization: Bearer $SENDFERN_API_KEY"Batch sending
POST/v1/emails/batch
Send up to 100 emails in one request. The body is a JSON array of 1 to 100 objects, each with the same fields as POST /v1/emails, including template_id and scheduled_at. Each email gets its own id, recipients and status, so use a batch for many separate emails, not one email to many people.
curl https://api.sendfern.com/v1/emails/batch \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{
"from": "Acme <hello@acme.com>",
"to": "jane@example.com",
"subject": "Your weekly report",
"text": "Hi Jane, here is your report."
},
{
"from": "Acme <hello@acme.com>",
"to": "sam@example.com",
"subject": "Your weekly report",
"text": "Hi Sam, here is your report."
}
]'{
"data": [
{"id": "em_4kQ0sJr1N2cE8xZa5bTq9w", "object": "email", "status": "queued", ...},
{"id": "em_7hM2pLw6V9dR3yKe1uFs0c", "object": "email", "status": "queued", ...}
]
}The data array is in the same order as your request.
Validation is all-or-nothing. Sendfern checks every item, including the domain of each From address and your monthly quota for the whole batch, before it queues any. If one item is invalid, nothing is sent and the error message names the item by its position, counting from 0:
{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Item 1: {\"to\": [\"'sam@' is not a valid email address.\"]}"
}
}Fix the item and send the whole batch again. To make that retry safe, send an Idempotency-Key.
Resending
POST/v1/emails/{id}/resend
Send a copy of an earlier email. The copy is a new email, with a new id and the same mode, and the same from, to, cc, bcc, reply_to, subject, html, text, headers, tags and attachments. It goes out now, whatever the original's status: scheduled_at is never copied. The original is not changed.
curl -X POST https://api.sendfern.com/v1/emails/em_VNqV5JEIqYYeYbZRhbPrJ6/resend \
-H "Authorization: Bearer $SENDFERN_API_KEY"The copy goes through the same checks as a new email: your account and domain when you call resend, and the suppression list when it sends. So a resend to an address that hard-bounced is suppressed again. Some emails cannot be resent, and the request is 400 not_resendable:
- Emails older than 30 days, whose body has been cleared (see Body retention).
- Emails sent by a broadcast, because the contact may have unsubscribed since. Send a new broadcast instead.
Resend does not take an Idempotency-Key. Every successful call sends one more copy.
Listing and filtering
GET/v1/emails
List the emails of the key's mode, newest first: a test key sees only test emails, a live key only live ones. The list is paginated with limit (1 to 100, default 20) and next; see Pagination. List items have no body or events; get one email for those.
Query parameters
statusstring- Only emails with this status, for example
bounced. tostring- Only emails with this exact address in
to. Case-insensitive. It does not search cc or bcc. tagstring- Only emails with this tag, written
name:value. broadcast_idstring- Only emails sent by this broadcast.
created_afterstring- Only emails created after this time. An ISO 8601 datetime or a date; a date means 00:00 UTC, and a time without an offset is UTC. URL-encode a
+in an offset as%2B. created_beforestring- Only emails created before this time. Same format as created_after. Both bounds are exclusive.
qstring- Only emails whose subject contains this text. Case-insensitive.
limitinteger- Page size, 1 to 100. Default 20.
Filters combine: each one narrows the list. A bad tag or date is 400 invalid_parameter naming the parameter.
curl -G https://api.sendfern.com/v1/emails \
-H "Authorization: Bearer $SENDFERN_API_KEY" \
--data-urlencode "status=bounced" \
--data-urlencode "created_after=2026-11-01" \
-d limit=50Retrieving an email
GET/v1/emails/{id}
Get one email with its body and timeline. An email of the other mode, or of another account, is 404.
curl https://api.sendfern.com/v1/emails/em_VNqV5JEIqYYeYbZRhbPrJ6 \
-H "Authorization: Bearer $SENDFERN_API_KEY"{
"id": "em_VNqV5JEIqYYeYbZRhbPrJ6",
"object": "email",
"mode": "live",
"status": "delivered",
"from": "Acme <hello@acme.com>",
"to": ["user@example.com"],
"cc": [],
"bcc": [],
"reply_to": ["support@acme.com"],
"subject": "Your order has shipped",
"tags": {"type": "shipping"},
"broadcast_id": null,
"error": null,
"scheduled_at": null,
"sent_at": "2026-11-28T10:19:05Z",
"created_at": "2026-11-28T10:19:04Z",
"html": "<p>Your order <strong>#1042</strong> is on its way.</p>",
"text": "Your order #1042 is on its way.",
"body_cleared_at": null,
"events": [
{"type": "sent", "recipient": null, "data": {}, "occurred_at": "2026-11-28T10:19:05Z"},
{"type": "delivered", "recipient": "user@example.com", "data": {}, "occurred_at": "2026-11-28T10:19:07Z"}
]
}On top of the email object, the response has:
htmlstring- The HTML body, or
""once cleared. textstring- The text body, or
""once cleared. body_cleared_atstring | null- When the body and attachments were deleted, or null while they are still stored.
eventsobject[]- The timeline, oldest first. Each event has
type,recipient(ornullfor events about the whole email),datawith details such as the bounce type, andoccurred_at. See Email lifecycle for every event type.
Body retention
Sendfern keeps the body of an email (html, text and attachments) for 30 days after it was created. After that the body is deleted and body_cleared_at says when. Everything else stays: the recipients, subject, tags, status and events. A body is only cleared once the email is no longer waiting to send, so a scheduled email keeps its content until it goes out.
Limits
| Limit | Value |
|---|---|
| Recipients per email (to + cc + bcc) | 50 |
| Subject | 998 characters, no line breaks |
| Tags per email | 10, values up to 256 characters |
| Attachments per email | 7 MB in total, decoded |
| Emails per batch | 1 to 100 |
| Scheduling | Up to 30 days ahead |
| Body retention | 30 days |
Requests are also rate-limited, and live emails count toward your monthly quota. See Rate limits and quotas. Every endpoint on this page is in the API reference.