Skip to the page

Sending email

One request sends an email. The same request takes attachments, a template, a time to send at and a key that makes a retry safe.

Send one email

An email needs a sender, at least one recipient, a subject and a body. The sender is an address on a domain the workspace has verified. The body is html, text or both.

curl -X POST "$OPENSEND_API_URL/v1/emails" \  -H "Authorization: Bearer $OPENSEND_API_KEY" \  -H "Content-Type: application/json" \  -d '{  "from": "Acme <hello@mail.example.com>",  "to": "ada@example.com",  "subject": "Your receipt for November",  "html": "<p>Thanks for your order.</p>"}'
  • to, cc and bcc each take one address or a list. One email goes to at most 50 addresses, counting all three together.
  • replyTo is where a reply goes when it should not go to the sender. Without it the email gets the reply address of its template, then the default of the workspace, which you set in the settings of the workspace or with workspace.update.
  • headers adds up to 20 headers of your own. The ones the platform writes itself are refused.
  • tags are up to 10 labels of your own, such as { "category": "receipt" }. They come back on the email and in every webhook about it.

The Emails reference lists every field.

Attachments

An email takes up to 10 files, 10 MB together. Give each file as Base64 in content, or as an https:// address in path that the file is fetched from. A file needs a filename, and contentType when the name does not say what it is.

JSON
{  "from": "Acme <hello@mail.example.com>",  "to": "ada@example.com",  "subject": "Your invoice",  "text": "The invoice is attached.",  "attachments": [    { "filename": "invoice.pdf", "path": "https://example.com/invoices/2026-11.pdf" },    { "filename": "note.txt", "content": "VGhhbmsgeW91Lg==" }  ]}

The email the API keeps lists the name, type and size of each file. The content of a file is not kept after sending.

Send from a template

Give template in place of subject, html and text. id is the id or the alias of a published template, and variables holds a value for each {{NAME}} in it. A value is escaped before it goes into the HTML.

JSON
{  "from": "Acme <hello@mail.example.com>",  "to": "ada@example.com",  "template": {    "id": "monthly-receipt",    "variables": { "MONTH": "November", "PRICE": "$24.00" }  }}

A template that is not published is refused with template_missing, and a variable without a value with template_variable_missing. Templates explains publishing.

A template can carry a sender, a reply address and a default for a variable. Then from and replyTo can be left out of the request, and so can a variable that has a default. What you do give wins over the template.

Send later

Give scheduledAt as an ISO 8601 time with an offset, up to 30 days ahead. The email is kept with the status scheduled and sent at that time.

Until then you can move it to another time, or cancel it.

curl -X PATCH "$OPENSEND_API_URL/v1/emails/em_09" \  -H "Authorization: Bearer $OPENSEND_API_KEY" \  -H "Content-Type: application/json" \  -d '{  "scheduledAt": "2026-12-05T09:00:00Z"}'
curl -X POST "$OPENSEND_API_URL/v1/emails/em_09/cancel" \  -H "Authorization: Bearer $OPENSEND_API_KEY" \  -H "Content-Type: application/json" \  -d '{}'

Both work only while the email is still scheduled. After that the answer is 409 with the code email_not_scheduled.

Send a batch

One request sends up to 100 emails. Each takes the same fields as one email, without attachments or a schedule.

curl -X POST "$OPENSEND_API_URL/v1/emails/batch" \  -H "Authorization: Bearer $OPENSEND_API_KEY" \  -H "Content-Type: application/json" \  -d '{  "emails": [    {      "from": "Acme <hello@mail.example.com>",      "to": "ada@example.com",      "subject": "Your receipt for November",      "html": "<p>Thanks for your order.</p>"    }  ]}'

Every email is checked first, and one that is wrong refuses the whole batch. After that each email is accepted or refused by itself. The answer has one entry per email, in the order you sent them, with the id of the email or the reason it was refused.

emails.batch
{  "object": "list",  "data": [    {      "index": 0,      "id": "em_10",      "status": "queued",      "error": null    }  ],  "sent": 1,  "failed": 0}

Retry without sending twice

A request can fail on the way back, after the email was accepted. To make a retry safe, send a key of your own with the request: the idempotency-key header, or idempotencyKey in the body. A repeat with the same key answers with the first result and sends nothing.

TypeScript
import { OpenSend } from '@open-send/opensend' const opensend = new OpenSend() const receipt = {  from: 'Acme <hello@mail.example.com>',  to: 'ada@example.com',  subject: 'Your receipt for November',  html: '<p>Thanks for your order.</p>',} const first = await opensend.emails.send(receipt, { idempotencyKey: 'receipt-2026-11-ada' })const again = await opensend.emails.send(receipt, { idempotencyKey: 'receipt-2026-11-ada' }) console.log(first.id === again.id)
  • A key is 1 to 256 letters, digits, _, ., : or -, and is kept for 24 hours.
  • The same key with a different request is refused with idempotency_mismatch.
  • A repeat that arrives while the first request is still being handled gets idempotency_busy. Try again in a moment.
  • When the first request was refused, the key is free again.

What happens to an email

The status of an email is where it stands now, and events is everything that happened to it, oldest first.

Status
scheduled
Meaning
Kept until the time you set.
Status
queued
Meaning
Accepted by the API and handed to the sending platform.
Status
sent
Meaning
On its way to the receiving mail server.
Status
delivered
Meaning
Taken by the receiving mail server.
Status
delayed
Meaning
The receiving mail server asked to try again later.
Status
bounced
Meaning
Refused by the receiving mail server for good.
Status
complained
Meaning
Marked as spam by the recipient.
Status
failed
Meaning
It could not be sent at all.
Status
opened, clicked
Meaning
The recipient opened it or followed a link, when tracking is on.
Status
canceled
Meaning
Canceled while it was still scheduled.
curl "$OPENSEND_API_URL/v1/emails/em_02" \  -H "Authorization: Bearer $OPENSEND_API_KEY"
emails.get
{  "object": "email",  "id": "em_02",  "from": "Acme <hello@mail.example.com>",  "to": [    "grace@example.com"  ],  "subject": "Confirm your new address",  "status": "opened",  "mode": "live",  "domain": "mail.example.com",  "cc": [],  "bcc": [],  "replyTo": null,  "scheduledAt": null,  "createdAt": "2026-11-27T09:16:00.000Z",  "html": "<p>Confirm your new address</p>",  "text": "Confirm your new address",  "headers": {},  "tags": {},  "attachments": [],  "templateId": null,  "automation": null,  "events": [    {      "type": "queued",      "at": "2026-11-27T09:16:00.000Z",      "detail": "Accepted by the API and queued."    },    {      "type": "sent",      "at": "2026-11-27T09:17:00.000Z",      "detail": "Handed to the sending provider."    },    {      "type": "delivered",      "at": "2026-11-27T09:18:00.000Z",      "detail": "The receiving server answered 250 OK."    },    {      "type": "opened",      "at": "2026-11-27T09:19:00.000Z",      "detail": "Opened once, on a phone."    }  ]}