---
title: "Mail · Workwae"
description: "Mail sync, search and sending for Gmail, Microsoft 365 and IMAP: provider push, threads, an outbox with undo and scheduling, templates and tracking."
url: https://workwae.com/features/mail
---

1. [Features](https://workwae.com/features/)
2. Mail

Mail

# Every mailbox, in sync and ready to send.

One index of every Gmail, Microsoft 365 and IMAP mailbox, synced by provider push, and an outbox that queues, retries and reports each send.

[Request early access](https://workwae.com/early-access/) [Read the quickstart](https://docs.workwae.com/guides/quickstart)

inbox.tsinbox.py

```ts
// Unread, high-priority mail, newest first
const { items } = await workwae.messages.list({
  accountId,
  unread: true,
  importance: "high",
});

// Body and attachments, stored or fetched
const message = await workwae.messages.get({
  accountId,
  messageId: items[0].id,
});
console.log(message.body.html, message.attachments);

// To the provider and the index at once
await workwae.messages.update({
  accountId,
  messageId: message.id,
  isRead: true,
});
```

```python
# Unread, high-priority mail, newest first
listing = workwae.messages.list(
    account_id=account_id,
    unread=True,
    importance="high",
)

# Body and attachments, stored or fetched
message = workwae.messages.get(
    account_id=account_id,
    message_id=listing.items[0].id,
)
print(message.body.html, message.attachments)

# To the provider and the index at once
workwae.messages.update(
    account_id=account_id,
    message_id=message.id,
    is_read=True,
)
```

What you get

## One mail API for every provider.

Gmail, Microsoft 365 (including [GCC High](https://workwae.com/glossary#gcc-high) and [DoD](https://workwae.com/glossary#dod)) and any IMAP server answer through one API, with typed SDKs for TypeScript and Python.

### One index

Folders and labels with roles; messages with thread, direction, categories and priority.

### Push first

Gmail Pub/Sub, Graph notifications and [IMAP IDLE](https://workwae.com/glossary#imap-idle) and NOTIFY, behind a backstop poll.

### Optional body storage

Fetched on request by default, or cached or kept, encrypted per tenant.

### Two kinds of search

Ranked full-text over the index, or Gmail search, KQL or IMAP SEARCH as written.

### Threads and drafts

Conversations with participants and unread counts, whole-thread actions, and drafts you can send.

### Outbox

One send at a time per account, retried, scheduled or undone.

### Identities and signatures

Send-as, proxy and Send As addresses or IMAP aliases, with signatures per message or on every send.

### Templates and merges

Up to 100 personal messages per merge, with one-click unsubscribe.

### Bot-aware tracking

Opt-in opens and clicks, people and machines counted apart.

Build it

## Sends you can schedule, undo and account for.

`outbox.create` seals and queues the message and answers at once; the rest arrives as events carrying your `reference`.

- **Undo and schedule.** `undoSendSeconds``undo_send_seconds` (0 to 60) holds sends until `undoUntil``undo_until`, and a `sendAt``send_at` can move before the first attempt (`send.rescheduled`).
- **Retries.** Up to 8 attempts within 24 hours of the send time.
- **Linked copies.** The Sent copy carries the `outboxId``outbox_id` and `reference`, so bounces and replies match the send.
- **Retention.** Sealed content is dropped when an entry finishes, and the entry after 30 days.
- **Priority.** `"high"` or `"low"` writes the headers Outlook, Thunderbird and Apple Mail read; indexed messages carry `importance`.

outbox.tsoutbox.py

```ts
// From a send-as identity, November 3 at 9:00 UTC
const send = await workwae.outbox.create({
  accountId,
  from: { address: "sales@example.com" },
  to: [{ name: "Priya Shah", address: "priya@example.com" }],
  subject: "Contract for review",
  html: "<p>The contract is attached.</p>",
  attachments: [
    {
      filename: "contract.pdf",
      contentType: "application/pdf",
      content: pdfBase64,
    },
  ],
  priority: "high",
  sendAt: "2026-11-03T09:00:00Z",
  reference: "deal_1042",
});

// Before the first attempt, move it earlier or later
await workwae.outbox.reschedule({
  accountId,
  outboxId: send.id,
  sendAt: "2026-11-03T14:00:00Z",
});

// Queued, sending, sent, failed or cancelled
const entry = await workwae.outbox.get({
  accountId,
  outboxId: send.id,
});
console.log(entry.status, entry.attempt, entry.lastError);
```

```python
from datetime import datetime, timezone

# From a send-as identity, November 3 at 9:00 UTC
send = workwae.outbox.create(
    account_id=account_id,
    from_={"address": "sales@example.com"},
    to=[{"name": "Priya Shah", "address": "priya@example.com"}],
    subject="Contract for review",
    html="<p>The contract is attached.</p>",
    attachments=[
        {
            "filename": "contract.pdf",
            "content_type": "application/pdf",
            "content": pdf_base64,
        },
    ],
    priority="high",
    send_at=datetime(2026, 11, 3, 9, tzinfo=timezone.utc),
    reference="deal_1042",
)

# Before the first attempt, move it earlier or later
workwae.outbox.reschedule(
    account_id=account_id,
    outbox_id=send.id,
    send_at=datetime(2026, 11, 3, 14, tzinfo=timezone.utc),
)

# Queued, sending, sent, failed or cancelled
entry = workwae.outbox.get(account_id=account_id, outbox_id=send.id)
print(entry.status, entry.attempt, entry.last_error)
```

Build it

## Templates, mail merge and lists people can leave.

Store a template once, send one message per recipient, and skip whoever left the list.

- **Templates** in Handlebars or Markdown, per tenant or account; edits never change queued mail.
- **Merges** of up to 100 entries, each with its own params, [Message-ID](https://workwae.com/glossary#message-id), send time, events, tracking and bounce matching; a bad entry fails alone.
- **One-click unsubscribe** per RFC 8058, with `{{rcpt.unsubscribeUrl}}`, over HTTPS as Gmail and Yahoo require.
- **Suppression.** List sends skip addresses on the list or `global`, checked when queued and at delivery.
- **Bounces** arrive as `message.bounced`; a gone address on a list send goes on `global`, and abuse reports can suppress it on that list.

[Read the suppression lists guide](https://docs.workwae.com/guides/suppressions)

merge.tsmerge.py

```ts
const template = await workwae.templates.create({
  name: "renewal-reminder",
  subject: "{{params.company}}: your renewal is due",
  html:
    "<p>Hi {{params.name}}, you renew on {{params.date}}.</p>" +
    '<p><a href="{{rcpt.unsubscribeUrl}}">Unsubscribe</a></p>',
});

// One message per recipient, each addressed to them alone
const { items } = await workwae.mailMerges.create({
  accountId,
  template: template.id,
  listId: "renewals",
  entries: [
    {
      to: { address: "priya@example.com" },
      params: { name: "Priya", company: "Acme", date: "Dec 1" },
    },
    {
      to: { address: "sam@example.com" },
      params: { name: "Sam", company: "Globex", date: "Dec 4" },
    },
  ],
});

for (const result of items) {
  if (!result.success) console.warn(result.to, result.reason);
}

// Your own opt-outs, on the same list
await workwae.suppressions.entries.add({
  listId: "renewals",
  addresses: ["former-customer@example.com"],
});
```

```python
template = workwae.templates.create(
    name="renewal-reminder",
    subject="{{params.company}}: your renewal is due",
    html=(
        "<p>Hi {{params.name}}, you renew on {{params.date}}.</p>"
        '<p><a href="{{rcpt.unsubscribeUrl}}">Unsubscribe</a></p>'
    ),
)

# One message per recipient, each addressed to them alone
merge = workwae.mail_merges.create(
    account_id=account_id,
    template=template.id,
    list_id="renewals",
    entries=[
        {
            "to": {"address": "priya@example.com"},
            "params": {"name": "Priya", "company": "Acme", "date": "Dec 1"},
        },
        {
            "to": {"address": "sam@example.com"},
            "params": {"name": "Sam", "company": "Globex", "date": "Dec 4"},
        },
    ],
)

for result in merge.items:
    if result.success is False:
        print(result.to, result.reason)

# Your own opt-outs, on the same list
workwae.suppressions.entries.add(
    list_id="renewals",
    addresses=["former-customer@example.com"],
)
```

Build it

## Opens and clicks, with the machines sorted out.

Opt-in per tenant, account or send; proxies, prefetching and link scanners don't count as readers.

- **Only the HTML part changes:** a 1x1 pixel and absolute http(s) links, never `mailto:`, unsubscribe or `data-workwae-notrack` links.
- **Classified hits** with an `actor` (human, proxy, prefetch, scanner or unknown) and `reasons`, counted apart.
- **Its own host** serves tracking and unsubscribe links only, so a blocklisted or crawled one never affects the API.
- **Per message:** every recipient gets the same MIME; merges track per recipient.
- **Edges.** Gmail and Microsoft 365 draft-sends are never tracked, and a sender viewing their tracked Sent copy with images on counts as an open.

tracking.tstracking.py

```ts
const send = await workwae.outbox.create({
  accountId,
  to: [{ address: "jordan@example.com" }],
  subject: "Proposal and next steps",
  html: proposalHtml,
  tracking: { opens: true, clicks: true },
  reference: "deal_4821",
});

// Later: counts split by person and machine
const entry = await workwae.outbox.get({
  accountId,
  outboxId: send.id,
});
console.log(entry.humanOpenCount, entry.machineOpenCount);

// Each hit, newest first, with why it was classified that way
const { items } = await workwae.outbox.tracking({
  accountId,
  outboxId: send.id,
});
for (const hit of items) {
  console.log(hit.kind, hit.actor, hit.isMachine, hit.reasons);
}
```

```python
send = workwae.outbox.create(
    account_id=account_id,
    to=[{"address": "jordan@example.com"}],
    subject="Proposal and next steps",
    html=proposal_html,
    tracking={"opens": True, "clicks": True},
    reference="deal_4821",
)

# Later: counts split by person and machine
entry = workwae.outbox.get(account_id=account_id, outbox_id=send.id)
print(entry.human_open_count, entry.machine_open_count)

# Each hit, newest first, with why it was classified that way
hits = workwae.outbox.tracking(account_id=account_id, outbox_id=send.id)
for hit in hits.items:
    print(hit.kind, hit.actor, hit.is_machine, hit.reasons)
```

Reference and FAQ

## The details, when you need them.

**Sync rules**

| First sync | No per-message events; ends with one `account.initialized` with counts, and only later changes emit `message.*` and `mailbox.*`. |
| --- | --- |
| Sync window | 90 days by default, set per tenant or per account, or the whole history; provider search reaches older mail. |
| Your own writes | API writes change the index in the same call, and sync announces nothing more when it sees them. |
| Push and polling | A notification only wakes the sync, so a lost one delays a change; the backstop poll runs every 10 minutes with push, every minute without. |
| Direction | Outbound when in Sent or from the account's address or an identity, so drafts and notes to self count. |
| Expired cursors | The mailbox or folder is re-read and diffed, so only real changes are announced. |

**Per-provider details**

| Aspect | Gmail and Google Workspace | Microsoft 365 | IMAP |
| --- | --- | --- | --- |
| Mailboxes | Labels; a message can carry several. Inbox tabs become `categories`; no per-label counts. | Folders; a message is in one. Immutable ids survive a move. | Folders from LIST, counts from LIST-STATUS. |
| Finding changes | `history.list`; a history id older than about a week forces a full read, diffed. | Message delta per folder plus a folder delta; an expired token re-reads the folder, diffed. | QRESYNC (VANISHED and CHANGEDSINCE) or UID and flag comparison, 1,000 messages per commit, resumable. |
| Push | `users.watch` to Cloud Pub/Sub, renewed daily, OIDC-verified; your own Google OAuth app can use its own topic. | One subscription per account, renewed at half its lifetime or on a [lifecycle notification](https://workwae.com/glossary#lifecycle-notification). | IDLE on INBOX; NOTIFY (RFC 5465) for other mailboxes where offered, else a STATUS check of Sent and Drafts every minute. |
| Backstop | The poll; a refused watch is explained in runtime detail and retried with backoff. | The poll, for notifications Graph drops. | A full read every 5 minutes on a second connection; at most two per account. |
| Provider search | Gmail syntax, at most 10 searches per account per minute. | KQL. | SEARCH TEXT. |
| Message identity | Gmail message ids; attachments by MIME part. | Immutable ids; a replaced draft keeps its id. | OBJECTID or `X-GM-MSGID` where available, else another program's move is a delete plus a create. |
| Sent copies | Filed by Gmail; consumer Gmail replaces the Message-ID, and Workwae links the copy by its own header. | Filed by Exchange in Sent Items. | Appended untracked to Sent unless the server files it. |
| Worth knowing | Workwae's Google app uses `gmail.modify`, so delete moves to Trash; permanent delete needs your own app with full scope. | At most 4 requests in flight per mailbox, honoring `Retry-After`; in GCC High and DoD permanent delete goes to Recoverable Items. | Servers autodiscovered; private addresses and plaintext logins refused. Google over IMAP needs your own Google OAuth app. |

**Body storage modes**

`bodyStorage` is a tenant default with a per-account override. Stored content goes to object storage, sealed per tenant in 64 KiB chunks and streamed back a chunk at a time.

| Mode | Stored | Reads from | Index search covers |
| --- | --- | --- | --- |
| `none` (default) | Metadata only; switching to it drops stored content. | The provider, every time. | Subject, sender and recipient names and addresses, snippet. |
| `cache` | What reads fetch, capped per workspace; dropped after 30 days unread through the API. | Stored content, storing the raw message on a miss. | Also bodies read so far. |
| `full` | Every indexed message, backfilled on switch without holding back new mail. | Stored content; drafts always from the provider. | Also every body. |

The index keeps a search vector of body text, never the text. With `source=auto` (the default), search asks the provider only when the index can't answer, such as before the window; results the index lacks have a null id and can't be opened through the API.

**Mail events**

Signed per Standard Webhooks and filterable by event type, account, mailbox, sender, subject and direction.

| Event | When |
| --- | --- |
| `account.initialized` | The first mail sync finished, with mailbox and message counts. |
| `mailbox.created`, `mailbox.updated`, `mailbox.deleted` | A folder or label appeared, changed name, place or role, or went away; counts change silently. |
| `message.created` | A message was received, sent, drafted or moved in from outside the window. |
| `message.updated` | Read, flagged, moved, reprioritized or linked to its send; `changes` names the fields. |
| `message.deleted` | A message was removed; carries it and its mailboxes as last indexed. |
| `send.sent`, `send.retrying`, `send.failed` | Accepted by the provider, waiting for `nextAttemptAt` after a failed attempt, or failed for good. |
| `send.rescheduled` | A queued send got a new `sendAt` before its first attempt. |
| `message.bounced` | A delivery status notification arrived, with each failed recipient's status and diagnostic, and the `outboxId` if it answers a send. |
| `message.opened`, `message.clicked` | A tracked send was opened or a link followed, with the actor and its reasons. |
| `suppression.created` | An unsubscribe, bounce or complaint put an address on a [suppression list](https://workwae.com/glossary#suppression-list). |
| `message.classified` | With [AI features](https://workwae.com/features/ai) on, a reply to your send was classified as a human reply, auto-reply, opt-out or bounce. |

**Can a send go out twice?**

Delivery is at least once, but a retry first looks for a copy already sent, and provider requests repeat only after a refusal. An SMTP send with an unknown outcome fails as `outcome_unknown` instead of retrying.

**Which Microsoft clouds are supported?**

Worldwide (including GCC), GCC High and DoD, each with its own app registration. In 21Vianet, Graph has no message delta yet, so mail runs over IMAP and SMTP with Microsoft sign-in.

**Why did my own open show up in tracking?**

Gmail and Microsoft 365 keep the tracked copy, pixel included, in Sent; on Gmail, viewing it arrives through the image proxy as a `proxy` hit. IMAP accounts keep an untracked copy.

Related

## Where teams use it, and what pairs with it.

### [CRM and sales](https://workwae.com/use-cases/crm)

Log every rep's email to the deal, and send from their mailbox.

### [Support desks](https://workwae.com/use-cases/support)

Shared inboxes as tickets, answered from the same address.

### [AI email agents](https://workwae.com/use-cases/ai-agents)

Read, draft and send for a person, with every change as an event.

### [Webhooks](https://workwae.com/features/webhooks)

Signed deliveries, filters, replays and an ordered change feed.

### [Contacts](https://workwae.com/features/contacts)

Google, Microsoft 365 and CardDAV address books.

### [Connect](https://workwae.com/features/connect)

Hosted or headless sign-in for every account type.

## Add every inbox to your product.

Workwae is in early access. Tell us what you are building, and read the docs in the meantime.

[Request early access](https://workwae.com/early-access/) [Mail API reference](https://docs.workwae.com/reference/mail)
