# Mail events

> Events for mailboxes, messages, sends, tracking and suppressions, with the message object and sample payloads.

URL: https://docs.workwae.com/guides/events/mail

These events track an account's mailboxes and messages, your sends through the outbox, open and click tracking, and suppressions. For the envelope fields see [Events](/guides/events#envelope).

## The message object

`message.created`, `message.updated`, `message.deleted` and `message.classified` carry `data.message`, the message as indexed, and `data.mailboxes`, the mailboxes it is in. It is the same message summary that [`/reference/mail`](/reference/mail) returns.

| Field | Description |
| --- | --- |
| `id` | Workwae message id. |
| `threadId` | The provider's thread id, or `null`. |
| `internetMessageId` | RFC 5322 `Message-ID`, or `null`. |
| `mailboxIds` | Ids of the mailboxes the message is in. |
| `subject`, `from`, `to`, `cc`, `snippet` | Headers and a text preview. `from` and `subject` can be `null`. |
| `receivedAt`, `sentAt` | Timestamps, or `null`. |
| `isRead`, `isFlagged`, `isDraft`, `hasAttachments` | Flags. |
| `categories` | Microsoft categories; Gmail inbox tabs (`personal`, `social`, `promotions`, `updates`, `forums`). |
| `direction` | `outbound` when the message is in a mailbox with role `sent` or its From is the account's own address or one of its identities (so drafts are outbound); else `inbound`. |
| `outboxId`, `reference` | The outbox entry this message is a copy of, and the `reference` it was queued with, when it was sent through the API (the sent copy, and the received copy of a message sent to the account itself); else `null`. Kept after outbox retention deletes the entry. |
| `importance` | `high`, `normal` or `low`. `null` for a message indexed before Workwae read priorities, until the provider reports it again. Gmail and IMAP read `normal` when no priority header is present. |
| `inReplyTo`, `references` | The Message-IDs the message answers: its In-Reply-To (the first id, or `null`) and its References, oldest first, angle brackets kept. Match a reply to one of your sends by comparing them with the `internetMessageId` of the send. Read from the index, with no provider call; `null` and `[]` where the message answers nothing, and also where the index does not know the ids yet (always for a Microsoft 365 message in `message.created`, whose sync carries no headers, until it is read in full). See [Get a message](/guides/mail#get). |

Each entry of `data.mailboxes` has the mailbox's `id`, `name` and `role`; the role tells inbound mail from sent mail and drafts.

To keep the samples short, only the first message sample shows the full object.

## Mailboxes

`data.mailbox` is the mailbox (folder or label) with its `id`, `name`, `path`, `parentId`, `role`, `kind`, `totalCount` and `unreadCount`.

**mailbox.created**

Fires when a mailbox (folder or label) appears.

```json
{
  "id": "1001",
  "type": "mailbox.created",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "mailbox": {
      "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a",
      "name": "INBOX",
      "path": "INBOX",
      "parentId": null,
      "role": "inbox",
      "kind": "folder",
      "totalCount": 1284,
      "unreadCount": 3
    }
  }
}
```

**mailbox.updated**

Fires when a mailbox is renamed, moved or given another role.

`changes` names the changed fields: `name`, `path`, `parentId`, `role` or `kind`. Counts change without an event.

```json
{
  "id": "1001",
  "type": "mailbox.updated",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "mailbox": {
      "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a",
      "name": "INBOX",
      "path": "INBOX",
      "parentId": null,
      "role": "inbox",
      "kind": "folder",
      "totalCount": 1284,
      "unreadCount": 3
    },
    "changes": ["name"]
  }
}
```

**mailbox.deleted**

Fires when a mailbox goes away. `data.mailbox` is the mailbox as last indexed.

```json
{
  "id": "1001",
  "type": "mailbox.deleted",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "mailbox": {
      "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a",
      "name": "INBOX",
      "path": "INBOX",
      "parentId": null,
      "role": "inbox",
      "kind": "folder",
      "totalCount": 1284,
      "unreadCount": 3
    }
  }
}
```

## Messages

**message.created**

Fires when a message is indexed: received, sent, drafted, or moved in from outside the sync window. Use `direction` and the mailbox `role` to tell inbound mail from your own.

```json
{
  "id": "1001",
  "type": "message.created",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "message": {
      "id": "c4e6a8b0-1d3f-4a5c-8e7b-9d1f3a5c7e9b",
      "threadId": "18f2a3b4c5d6e7f8",
      "internetMessageId": "<CAF3x9a@mail.example.org>",
      "mailboxIds": ["8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a"],
      "subject": "Quarterly report",
      "from": { "name": "Grace Hopper", "address": "grace@example.org" },
      "to": [{ "name": null, "address": "ada@example.com" }],
      "cc": [],
      "snippet": "Hi Ada, the numbers for the quarter are attached.",
      "receivedAt": "2026-05-04T09:30:00.000Z",
      "sentAt": "2026-05-04T09:30:00.000Z",
      "isRead": false,
      "isFlagged": false,
      "isDraft": false,
      "hasAttachments": true,
      "categories": [],
      "direction": "inbound",
      "outboxId": null,
      "reference": null,
      "importance": "high",
      "inReplyTo": "<20260503141500.7d9e5f@example.com>",
      "references": ["<20260503141500.7d9e5f@example.com>"]
    },
    "mailboxes": [
      { "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a", "name": "INBOX", "role": "inbox" }
    ]
  }
}
```

**message.updated**

Fires when a message changes: read, flagged, moved, or linked to the outbox entry it is a copy of.

`changes` names the changed fields: `threadId`, `internetMessageId`, `subject`, `from`, `to`, `cc`, `bcc`, `replyTo`, `snippet`, `receivedAt`, `sentAt`, `isRead`, `isFlagged`, `isDraft`, `hasAttachments`, `categories`, `mailboxIds`, `direction`, `outboxId` or `importance`. `reference` changes only with `outboxId` and is not named on its own. `inReplyTo` and `references` are never named: the index fills them in quietly, without a `message.updated`.

The sample shows the sent copy of a send being linked to its outbox entry (message trimmed).

```json
{
  "id": "1001",
  "type": "message.updated",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "message": {
      "id": "d5f7b9a1-2c4e-4b6d-9f8a-0c2e4b6d8f0a",
      "internetMessageId": "<20260504093000.1a2b3c@example.com>",
      "mailboxIds": ["1e3a5c7b-9d1f-4b3e-8a5c-7e9b1d3f5a7c"],
      "subject": "Invoice 1001",
      "direction": "outbound",
      "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
      "reference": "invoice-1001"
    },
    "mailboxes": [
      { "id": "1e3a5c7b-9d1f-4b3e-8a5c-7e9b1d3f5a7c", "name": "Sent", "role": "sent" }
    ],
    "changes": ["outboxId"]
  }
}
```

**message.deleted**

Fires when a message is removed. It carries the message and its mailboxes as last indexed, plus `messageId` and the provider's `providerMessageId` (message trimmed).

```json
{
  "id": "1001",
  "type": "message.deleted",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "messageId": "c4e6a8b0-1d3f-4a5c-8e7b-9d1f3a5c7e9b",
    "providerMessageId": "18f2a3b4c5d6e7f8",
    "message": {
      "id": "c4e6a8b0-1d3f-4a5c-8e7b-9d1f3a5c7e9b",
      "subject": "Quarterly report",
      "direction": "inbound"
    },
    "mailboxes": [
      { "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a", "name": "INBOX", "role": "inbox" }
    ]
  }
}
```

**message.bounced**

Fires when a delivery status notification reporting failed recipients reaches the account.

| Field | Description |
| --- | --- |
| `messageId` | The notice itself, as indexed. |
| `outboxId`, `reference` | The send the notice answers, when it answers one of your sends; else `null`. The notice is matched by the `X-Workwae-Outbox` header or the `Message-ID` of the original it returns. Some servers return nothing of the original (for example only their own trace headers, for a message sent from a consumer Gmail account); such a notice is then matched by its failed recipients to the one send of the account that went out to all of them in the 72 hours before Workwae received it, but only when a mailer-daemon sent it and the account's mail server authenticated it (DMARC or DKIM pass in its `Authentication-Results` header) for the sender's domain and the recipients' domain, so that a notice anyone could have written does not link. If no send or several did, the notice names a `Message-ID` that is not yours, or it is not authenticated, both are `null`. |
| `originalMessageId` | The `Message-ID` of the bounced message, when the notice names it. |
| `recipients[]` | `address`; `status`, the RFC 3463 enhanced status code (for example `5.1.1`) or `null`; `diagnostic`, what the rejecting server said, or `null`. |

```json
{
  "id": "1001",
  "type": "message.bounced",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "messageId": "c4e6a8b0-1d3f-4a5c-8e7b-9d1f3a5c7e9b",
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "originalMessageId": "<20260504093000.1a2b3c@example.com>",
    "recipients": [
      {
        "address": "grace@example.org",
        "status": "5.1.1",
        "diagnostic": "smtp; 550 5.1.1 <grace@example.org>: Recipient address rejected"
      }
    ]
  }
}
```

**message.classified**

Fires when AI classifies a reply to one of your sends. Requires the tenant setting `aiReplyClassification`; see [AI](/guides/ai).

It carries the message, its mailboxes and `classification` (message trimmed):

| Field | Description |
| --- | --- |
| `kind` | `opt_out`, `auto_reply`, `bounce` or `human_reply`. |
| `probabilities` | Each kind's probability, 0 to 1. |
| `optOutProbability` | Probability the message asks to stop receiving email. At 0.9 or more the sender's address is handled per the tenant's opt-out setting. |
| `autoReplyCategory` | `out_of_office`, `left_company`, `address_changed`, `ticket_acknowledgment`, `challenge_response` or `other`; `null` unless `kind` is `auto_reply`. |
| `returnDate` | An `out_of_office` reply's stated return date, or `null`. |
| `alternateContacts` | Addresses a `left_company` or `address_changed` reply names in its text (at most 5); else empty. |
| `outboxId` | The send the message answers. |
| `model`, `classifiedAt` | The classifying model and when it ran. |

```json
{
  "id": "1001",
  "type": "message.classified",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "message": {
      "id": "c4e6a8b0-1d3f-4a5c-8e7b-9d1f3a5c7e9b",
      "subject": "Automatic reply: Invoice 1001",
      "from": { "name": "Grace Hopper", "address": "grace@example.org" },
      "snippet": "I'm out of the office until Monday, May 11, with limited access to email.",
      "direction": "inbound"
    },
    "mailboxes": [
      { "id": "8a3f5c7e-2d4b-4c6e-9f1a-3b5d7f9e1c2a", "name": "INBOX", "role": "inbox" }
    ],
    "classification": {
      "kind": "auto_reply",
      "probabilities": {
        "auto_reply": 0.97,
        "human_reply": 0.02,
        "opt_out": 0.01,
        "bounce": 0
      },
      "optOutProbability": 0.01,
      "autoReplyCategory": "out_of_office",
      "returnDate": "2026-05-11",
      "alternateContacts": [],
      "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
      "model": "workwae-classifier",
      "classifiedAt": "2026-05-04T09:30:00.000Z"
    }
  }
}
```

## Opens and clicks

`message.opened` and `message.clicked` carry the same fields. They fire only for sends with tracking on; see [Tracking](/guides/tracking).

| Field | Description |
| --- | --- |
| `outboxId`, `reference` | The tracked send. |
| `messageId` | The account's sent copy, once its sync has indexed and linked it; `null` until then. |
| `url` | Clicks: where the link led. `null` for opens and for the honeypot link. |
| `actor` | `human`, `proxy`, `prefetch`, `scanner` or `unknown`. |
| `reasons` | Stable codes for what decided the actor, such as `ua_google_image_proxy`, `cidr_apple_mpp`, `honeypot`, `sec_fetch_user`. |
| `isMachine` | `true` when `actor` is `proxy`, `prefetch` or `scanner`. |
| `sequence`, `secondsAfterSend`, `secondsSincePrevious` | The hit's number among the send's opens and clicks (from 1) and its timing. |
| `client`, `device`, `os`, `browser`, location fields | Signals derived from the request. |

The raw request headers are only on the tracking list API, not in the event.

**message.opened**

Fires when a recipient's client, or a proxy fetching for it, loads the open-tracking pixel of a send.

```json
{
  "id": "1001",
  "type": "message.opened",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "messageId": "d5f7b9a1-2c4e-4b6d-9f8a-0c2e4b6d8f0a",
    "url": null,
    "userAgent": "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)",
    "actor": "proxy",
    "reasons": ["ua_google_image_proxy"],
    "isMachine": true,
    "occurredAt": "2026-05-04T10:12:41.000Z",
    "method": "GET",
    "refererHost": null,
    "originHost": null,
    "client": "gmail_proxy",
    "device": "unknown",
    "os": null,
    "browser": null,
    "country": "US",
    "region": "California",
    "city": "Mountain View",
    "timezone": "America/Los_Angeles",
    "latitude": 37.4056,
    "longitude": -122.0775,
    "secondsAfterSend": 2561,
    "secondsSincePrevious": null,
    "sequence": 1,
    "isConditional": false,
    "isRange": false,
    "isPrefetch": false,
    "secFetch": { "dest": null, "mode": null, "site": null, "user": null }
  }
}
```

**message.clicked**

Fires when a tracked link of a send is followed.

```json
{
  "id": "1001",
  "type": "message.clicked",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "messageId": "d5f7b9a1-2c4e-4b6d-9f8a-0c2e4b6d8f0a",
    "url": "https://billing.example.com/invoices/1001",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
    "actor": "human",
    "reasons": ["sec_fetch_user", "referer_webmail"],
    "isMachine": false,
    "occurredAt": "2026-05-04T10:13:05.000Z",
    "method": "GET",
    "refererHost": "mail.google.com",
    "originHost": null,
    "client": "gmail_web",
    "device": "desktop",
    "os": "windows",
    "browser": "chrome",
    "country": "GB",
    "region": "England",
    "city": "London",
    "timezone": "Europe/London",
    "latitude": 51.5072,
    "longitude": -0.1276,
    "secondsAfterSend": 2585,
    "secondsSincePrevious": 24,
    "sequence": 2,
    "isConditional": false,
    "isRange": false,
    "isPrefetch": false,
    "secFetch": { "dest": "document", "mode": "navigate", "site": "cross-site", "user": true }
  }
}
```

## Sends

Every send event carries `outboxId`, the outbox entry, and the `reference` it was queued with. See [Sending](/guides/sending).

**send.sent**

Fires when the provider accepts a queued send.

- `attempt`: the attempt that succeeded.
- `providerMessageId`: the provider's id for the sent message; `null` where the provider gives none.
- `internetMessageId`, `sentAt`: the sent message's `Message-ID` and send time.
- `rejectedRecipients`: recipients an SMTP server refused while taking the message for the others (IMAP accounts), each `{ address, status, diagnostic }` with the refusal's enhanced status code and reply; empty when none. A refusal saying the address is gone suppresses it, as a [bounce](/guides/suppressions#lists) does.

```json
{
  "id": "1001",
  "type": "send.sent",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "attempt": 1,
    "providerMessageId": "18f2a3b4c5d6e7f9",
    "internetMessageId": "<20260504093000.1a2b3c@example.com>",
    "sentAt": "2026-05-04T09:30:00.000Z",
    "rejectedRecipients": []
  }
}
```

**send.retrying**

Fires when an attempt fails and the send is queued again for `nextAttemptAt`. `error` has a `code` and a `message`.

```json
{
  "id": "1001",
  "type": "send.retrying",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "attempt": 1,
    "nextAttemptAt": "2026-05-04T09:31:00.000Z",
    "error": {
      "code": "throttled",
      "message": "The provider asked us to slow down"
    }
  }
}
```

**send.failed**

Fires when the send fails for good: refused, or out of attempts. `attempt` is the last attempt; `error` has a `code` and a `message`.

`rejectedRecipients` lists the recipients the SMTP server refused one by one (IMAP accounts), each `{ address, status, diagnostic }` as in `send.sent`. A refusal arrives as `error.code` `invalid_request`, and a non-empty list tells you which addresses were refused for good; the address is not worth retrying unless you change it. It is empty when the failure names no recipient: every other error code, and a refusal that did not say which recipient it was about. Gmail and Microsoft 365 do not name refused recipients when they take a send; a bounce for one arrives later as `message.bounced`.

```json
{
  "id": "1001",
  "type": "send.failed",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "attempt": 5,
    "error": {
      "code": "invalid_request",
      "message": "smtp.example.com rejected the message: Recipient address rejected"
    },
    "rejectedRecipients": [
      {
        "address": "ada@example.com",
        "status": "5.1.1",
        "diagnostic": "550 5.1.1 <ada@example.com> User unknown"
      }
    ]
  }
}
```

**send.rescheduled**

Fires when a queued send gets a new `sendAt` before its first attempt. `previousSendAt` is the old time.

```json
{
  "id": "1001",
  "type": "send.rescheduled",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "sendAt": "2026-05-04T14:00:00.000Z",
    "previousSendAt": "2026-05-04T09:30:30.000Z"
  }
}
```

**send.cancelled**

Fires when a queued entry is cancelled: `DELETE .../outbox/{outboxId}`, the MCP `cancel_send` tool, or its [mail merge](/guides/mail-merge#cancel) being cancelled (one event per entry). `mailMergeId` is the merge the entry belonged to, `null` for a single send.

```json
{
  "id": "1001",
  "type": "send.cancelled",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f",
    "reference": "invoice-1001",
    "mailMergeId": null
  }
}
```

## Suppressions

**suppression.created**

Fires when an address goes onto a suppression list because of a send. The envelope's account is the one whose send it concerns.

| `source` | Cause | `listId` |
| --- | --- | --- |
| `unsubscribe` | The recipient unsubscribed. | The send's list |
| `bounce` | A permanent bounce said the address is gone. | `global` |
| `reply`, `complaint` | A detected opt-out was suppressed, at once or on approval. | The send's list or `global` |
| `inactive` | An auto-reply said the person left or moved, suppressed on approval only. | `global` |

Only a change is announced. Addresses added through the API are recorded in the [audit log](/guides/audit-log) instead. See [Suppressions](/guides/suppressions).

```json
{
  "id": "1001",
  "type": "suppression.created",
  "accountId": "6f1c2a4e-8b3d-4e5f-9a7b-1c2d3e4f5a6b",
  "createdAt": "2026-05-04T09:30:00.000Z",
  "data": {
    "listId": "weekly-news",
    "address": "ada@example.org",
    "source": "unsubscribe"
  }
}
```
