Sending mail
Queue a message through the outbox, follow its delivery, schedule it, and undo or cancel it.
Send a message from a connected account with one outbox request. This page covers single sends. For other jobs, see:
- Drafts: compose in the user's mailbox and send later.
- Mail merge: one personalized message per recipient in one call.
- Templates: stored, reusable content.
- Tracking: open and click tracking, unsubscribe links.
- Suppression lists: who bulk mail must skip.
Send a message
A send queues an outbox entry for the account and returns 201 at once. The account's provider (Gmail, Microsoft 365 or its SMTP server) sends it in the background.
The key needs the send scope. An account token for that account also works.
curl -X POST "https://api.workwae.com/v1/accounts/$ACCOUNT_ID/outbox" \
-H "Authorization: Bearer $WORKWAE_API_KEY" \
-H "content-type: application/json" \
-d '{
"to": [{ "name": "Ada Lovelace", "address": "ada@example.com" }],
"subject": "Your invoice",
"text": "Hi Ada, your invoice is attached.",
"html": "<p>Hi Ada, your invoice is attached.</p>",
"reference": "invoice-1042"
}'Request fields
| Field | Meaning |
|---|---|
to, cc, bcc, replyTo | Arrays of { name?, address }, up to 500 each. At least one of to, cc or bcc is required (no_recipients otherwise). |
subject, text, html | The content. With format: "markdown", html holds Markdown and is converted to HTML. |
attachments | Up to 50 files; see Attachments. |
from | One of the account's send-as identities (GET /v1/accounts/{accountId}/identities). Omitted, it sends as the account itself. |
signature | Appends the sender identity's signature. Omitted, it follows the account's signByDefault mail setting. |
inReplyToMessageId | The Workwae id of the message being answered. Sets In-Reply-To and References so the reply stays in its thread. |
messageId | Your own Message-ID (<local@domain>) instead of a generated one. It must be new for the account: a second send with it is refused with 409 duplicate_message_id, whose data has the outboxId and status of the entry holding it. Only sends that went out or may have gone out hold it: queued, sending, sent, or any entry an attempt of which ended without knowing whether the provider took the message (outcome_unknown, a timeout, the provider unavailable, or an interrupted send), even if it was cancelled or failed afterwards. After a cancel before any attempt, or a failure that left nothing sent (the provider refused the message), the id can be used again. Consumer Gmail replaces it. |
headers | Extra headers; see Headers. |
calendar | A calendar invite; see Calendar invites. |
priority | high, normal (default) or low, written as the provider's priority headers. |
reference | Your own identifier, echoed in the send.* events. |
sendAt | Schedule the send; see Scheduling and undo. |
template, render | Render stored or inline content; see Templates. |
tracking | Open and click tracking; see Tracking. |
listId | A suppression list for bulk mail; see Tracking. |
An unknown field is refused, not ignored. Every refusal and its reason is listed under Send a message in the API reference.
A send naming no listId skips no one by default. With the suppressionCheck setting always (workspace default, or per account in settings), it is refused with 400 suppressed when any to, cc or bcc address is on the global suppression list. data.addresses names them, as you wrote them; a mail merge entry fails alone with the same reason. The check runs again at delivery, so an address suppressed while the send waits fails it with send.failed code suppressed.
Attachments
attachments takes up to 50 objects of { filename, contentType, content }, with content in base64. Together they can hold at most 25 MiB once decoded; more is refused with 400 attachments_too_large. To show one inline, set its contentId and reference it from the HTML as cid:....
await workwae.outbox.create({
accountId,
to: [{ address: "ada@example.com" }],
subject: "Your invoice",
html: '<p>Invoice attached.</p><img src="cid:logo">',
attachments: [
{ filename: "invoice.pdf", contentType: "application/pdf", content: pdfBase64 },
{ filename: "logo.png", contentType: "image/png", content: logoBase64, contentId: "logo" },
],
});Headers
headers takes up to 50 headers as { name: value }. Any X- header is allowed except X-Workwae-*, X-Priority and X-MSMail-Priority (use priority), and so are List-Unsubscribe, List-Unsubscribe-Post, List-Id, List-Help, List-Subscribe, List-Post, List-Owner, List-Archive, Auto-Submitted, Precedence, In-Reply-To, References, Feedback-ID, Keywords and Disposition-Notification-To. A value is one line of up to 4,096 characters; long ones are folded when the message is written. Any other header, a repeated name or a line break is refused with 400 invalid_input.
In-Reply-ToandReferenceskeep a thread with a message Workwae has not indexed. WithinReplyToMessageId,In-Reply-Tois refused andReferencesreplaces the one Workwae writes.- With
listId, Workwae writes the unsubscribe headers itself, soList-*headers are refused.
await workwae.outbox.create({
accountId,
to: [{ address: "ada@example.com" }],
subject: "Our fall sale",
html: "<p>…</p>",
headers: {
"List-Unsubscribe": "<https://shop.example/unsubscribe?u=42>",
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
"X-Campaign": "fall-2026",
},
});Calendar invites
calendar takes { method, content }: an iTIP method (REQUEST, CANCEL, REPLY, PUBLISH and the others) and the iCalendar object, BEGIN:VCALENDAR to END:VCALENDAR, up to 256 KiB. It goes out as the message's text/calendar alternative, the part mail clients read invites from, and as an invite.ics attachment. method must match the object's own METHOD.
Delivery and events
The entry's status moves from queued to sending, then ends sent, failed or cancelled. Follow it with webhooks or the change feed. Each event carries the entry's id as outboxId and your reference.
| Event | When |
|---|---|
send.sent | The provider accepted the message. |
send.retrying | An attempt failed; the entry will be tried again. |
send.failed | The entry failed for good. |
send.rescheduled | sendAt was moved. |
send.cancelled | A queued entry was cancelled, on its own or with its mail merge. |
message.bounced | A bounce for the sent message arrived later. |
- Delivery is at least once: a retry first looks for a copy that already went out. A Microsoft 365 send whose answer was lost is settled by reading the message it sent and, if that is still a draft, sending the same draft again, so it is neither duplicated nor lost; if that does not settle it, the entry fails as
outcome_unknownand the draft stays in the account's Drafts. - A throttled or unavailable provider is retried with a delay that doubles from 30 seconds to an hour, with jitter, and never sooner than the provider's
Retry-After. An entry fails with its last error after 8 attempts, or when its next attempt would fall more than 24 hours after itssendAt. - A provider's sending limit (Gmail's daily limits, Exchange Online's submission and recipient quotas) is retried as
sending_limit, after the provider's stated wait or an hour. It fails under the same rules, withsend.failedcodesending_limit. - An account sends one message at a time, and its sends start at least a gap apart. A Microsoft 365 account has a 2 second minimum, which keeps it under Exchange Online's 30 messages a minute. The
sendsPerMinutesetting (1 to 600; a workspace default that an account's own settings override,nullfor none) spreads an account's sends further: the gap is 60 seconds divided by it, so6starts a send at most every 10 seconds. The longer of the two applies. The gap runs from when a send starts, so a slow send does not stretch it, and it applies to retries too. - Exchange Online also limits external recipients for the whole Microsoft 365 organization (a tenant limit, refused with
5.7.232,5.7.233or5.7.236). When one account hits it, the workspace's other Microsoft 365 accounts that send from the same address domain wait out the same time, the provider's stated wait or an hour, without sending. Their queued entries keep their attempts and emit no event until the hold ends; the account that hit the limit retries assending_limit. Accounts carry no organization id, so the organization is matched by the address domain: an organization with several domains is held per domain. A limit on one user's own allowance holds only that account. send.failedwith codeoutcome_unknownmeans the server may have accepted the message but its reply was lost. Workwae does not send it again; decide yourself whether to resend.- A recipient the SMTP server refuses (IMAP accounts) fails the send as
invalid_request, andsend.failednames the refused recipients inrejectedRecipients(address,status,diagnostic); it is empty for every other failure. Gmail and Microsoft 365 do not name refused recipients when they accept a send, so a recipient they refuse is reported later asmessage.bounced. - The entry carries the same list as
rejectedRecipients, so you can read an outcome by polling (wait, orGET .../outbox/{outboxId}) without webhooks: afailedentry names the recipients that refused the whole send, asentone those refused while the others were taken. It is[]for every other entry, including one stillqueuedorsending; a retried entry shows its latest outcome's. GET /v1/accounts/{accountId}/outboxlists entries newest first (filter withstatus).GET .../outbox/{outboxId}reads one.- Once the account's sync has indexed the sent copy, it carries the same
outboxId, and the entry names it: see The sent copy.
Full payloads are in the mail events catalog.
The sent copy
Once the message the provider sent is indexed, the entry names it. sentMessageId is the message's id, which GET /v1/accounts/{accountId}/messages/{messageId} reads, and threadId is its thread. Both are null until the entry is sent and its copy is indexed.
- Gmail and Microsoft 365: the send role reads the sent message as soon as it records
sent, so both are set within moments ofsend.sent. Microsoft 365 moves a sent message to Sent Items a moment after the send is accepted, so the read waits for it, up to 15 seconds. If a read fails or runs out, the next sync sets them. - SMTP accounts: both are set when the next sync reads the Sent folder. The send role asks the account's sync to run as soon as the send is recorded.
- A Microsoft 365 send briefly exists as a draft in Drafts, which Workwae sends by its id; that draft is never indexed or announced, and it is deleted again if the send is refused.
- A Microsoft 365 account connected with
mailPermissions: "read_send"cannot create drafts, so it sends without one. The send names no message, so Workwae finds the copy in Sent Items by its Message-ID:sentMessageIdandthreadIdare normally set within moments andwaitsees them (if the copy is not found in time, the account's next sync sets them). A send that gets no answer is not retried: if its copy is in Sent Items it issent, otherwise it fails withoutcome_unknown. - A message sent to the account's own address leaves a second, received message with the same
outboxId. The entry names the one in the account's Sent mailbox, else the oldest outbound one. - A
failedentry'slastErrorreads<code>: <message>, wherecodeis theerror.codeof itssend.failedevent.
Wait for the outcome
POST .../outbox with wait: N in the body holds the request after queueing, up to N seconds (a whole number from 1 to 30), until the entry is sent, failed or cancelled. For a sent entry it also waits for sentMessageId, if the copy is linked in time. It then answers the entry as it stands, with the same 201 and body. Anything outside 1 to 30 is a 400 invalid_input naming wait.
curl -X POST "https://api.workwae.com/v1/accounts/$ACCOUNT_ID/outbox" \
-H "Authorization: Bearer $WORKWAE_API_KEY" \
-H "content-type: application/json" \
-d '{ "to": [{ "address": "ada@example.com" }], "subject": "Your invoice", "text": "Hi Ada.", "wait": 10 }'
```ts tab="TypeScript"
const entry = await workwae.outbox.create({
accountId,
to: [{ address: "ada@example.com" }],
subject: "Your invoice",
text: "Hi Ada.",
wait: 10,
});- A
statusofqueuedorsendingin the answer means the wait ran out, not that the send failed: pollGET .../outbox/{outboxId}.sentwith anullsentMessageIdmeans the copy is not linked yet. - A send that is not due within the wait, because of the account's undo window or a later
sendAt, is answered at once, stillqueued. - A client that disconnects ends the wait. The send stays queued and goes out.
- A waiting request counts toward the API's in-flight limit for its whole wait, so a key's concurrent waiting sends are bounded by it (429
too_many_requestspast it). Self-hosted: the API'sAPI_IDLE_TIMEOUT_SECONDS(default 60) must be at leastwait, or the connection is closed first. - With an
Idempotency-Key,waitis part of the request the key is bound to: the same key with anotherwait(or none) is 422idempotency_key_reused. A retry with the samewaitafter the first request answered gets that answer (the entry as it stood when the first request ended) without waiting again. While the first request still waits, a retry is 409idempotency_key_in_progress.
Scheduling and undo
sendAtschedules a send. Omitted or in the past, it goes as soon as possible.- The account's
undoSendSecondssetting (0 to 60) holds every send at least that long. - While an entry waits,
undoUntilsays until when cancelling undoes it.
# Move a queued send
curl -X PATCH "https://api.workwae.com/v1/accounts/$ACCOUNT_ID/outbox/$OUTBOX_ID" \
-H "Authorization: Bearer $WORKWAE_API_KEY" \
-H "content-type: application/json" \
-d '{ "sendAt": "2026-11-02T09:00:00Z" }'
# Cancel (undo) it
curl -X DELETE "https://api.workwae.com/v1/accounts/$ACCOUNT_ID/outbox/$OUTBOX_ID" \
-H "Authorization: Bearer $WORKWAE_API_KEY"Cancelling announces send.cancelled, with mailMergeId when the entry came from a mail merge, which can cancel all its queued entries at once.
Once it is sending, it is too late
Cancelling or rescheduling an entry that is no longer queued returns 409 send_not_cancellable or send_not_reschedulable. The message says which state it is in.
Send limits
- The tenant's plan caps the sends it may queue per day (UTC). Past the cap, a send returns 403
plan_limit_sendsand a mail merge entry fails with that reason.GET /v1/usageshows the cap (sendsPerDay) andsendsToday. - A tenant whose payment is past due beyond the grace period is refused new sends with 402
billing_past_due. Sends already queued still go out.
Details are in Daily sends; request rate limits and other plan limits are in Rate limits.