# Email log

Every email the system queued or sent, with its bodies and delivery status, for the Platform admin. See ADR 0021.

Part of the [Celerbeam API and MCP reference](https://celerbeam.com/docs/api/index.md). HTML version: https://celerbeam.com/docs/api/email-log/

## List emails

`GET /v1/emails`

Every email the system has queued or sent, newest first, without bodies. The Platform admin only. `template`, `status`, `recipient`, `user_id` and `organisation_id` narrow it, and `from` (inclusive) and `to` (exclusive) to a range of times it was queued. Emails are kept 90 days. A page can hold fewer items than `limit`, even none, and still have a `next_cursor`.

- MCP tool: `list_emails` (read-only)
- Auth: Bearer token (`bearerAuth`)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `cursor` | query | `string` | no | The `next_cursor` from the previous page. Omit it for the first page. At least 1 character. |
| `limit` | query | `integer` | no | The most items to return. 1 to 100. Default `50`. |
| `template` | query | `EmailTemplate` | no | Only emails of this template. |
| `status` | query | `EmailStatus` | no | Only emails in this status. |
| `recipient` | query | `Email` | no | Only emails to this address, in any case. |
| `user_id` | query | `UserId` | no | Only emails to this User's address. |
| `organisation_id` | query | `OrganisationId` | no | Only emails about this Organisation. |
| `from` | query | `Timestamp` | no | Only emails queued at or after this time. |
| `to` | query | `Timestamp` | no | Only emails queued before this time. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| 200 | One page of emails. | `EmailPage` (`application/json`) |
| 400 | The request is malformed or fails validation (`invalid_request`), or an ID has the wrong prefix for its field (`invalid_id`). `errors` names each invalid field. | `Problem` (`application/problem+json`) |
| 401 | No valid bearer token (`unauthenticated`). Header `WWW-Authenticate`: The bearer challenge, per RFC 6750. | `Problem` (`application/problem+json`) |
| 403 | The caller can see the resource, but their Role doesn't allow this operation (`forbidden`). The attempt is audited with `result=denied`. | `Problem` (`application/problem+json`) |

## Get an email

`GET /v1/emails/{email_id}`

One email, with its subject, HTML and text bodies as sent and its status timeline, with any error. One-time codes are masked. The Platform admin only.

- MCP tool: `get_email` (read-only)
- Auth: Bearer token (`bearerAuth`)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `email_id` | path | `EmailId` | yes | Email ID. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| 200 | The email. | `EmailDetail` (`application/json`) |
| 400 | The request is malformed or fails validation (`invalid_request`), or an ID has the wrong prefix for its field (`invalid_id`). `errors` names each invalid field. | `Problem` (`application/problem+json`) |
| 401 | No valid bearer token (`unauthenticated`). Header `WWW-Authenticate`: The bearer challenge, per RFC 6750. | `Problem` (`application/problem+json`) |
| 403 | The caller can see the resource, but their Role doesn't allow this operation (`forbidden`). The attempt is audited with `result=denied`. | `Problem` (`application/problem+json`) |
| 404 | The resource doesn't exist, or the caller can't see it (`not_found`). The two are never told apart. | `Problem` (`application/problem+json`) |

## Resend an email

`POST /v1/emails/{email_id}/resend`

Queues the same email again, to the same address, as a new email whose `resend_of` names this one. The Platform admin only. An invitation is resent with a fresh code, which replaces the old one, so the old email's code stops working; once the invitation has been accepted it can't be resent (409 `not_resendable`). A password reset or set-password email starts a fresh reset through the user pool, as the person's own "Forgot password?" does: a new code, which replaces the old one, emailed by the pool, so `email` is `null` and the new email shows in the log a moment later; 429 `rate_limited` if the pool refuses another for now. Records one `email.resent` audit event.

- MCP tool: `resend_email` (not destructive)
- Auth: Bearer token (`bearerAuth`)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `email_id` | path | `EmailId` | yes | Email ID. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| 202 | The new email, queued, or `null` when the user pool sends it. | `EmailResent` (`application/json`) |
| 400 | The request is malformed or fails validation (`invalid_request`), or an ID has the wrong prefix for its field (`invalid_id`). `errors` names each invalid field. | `Problem` (`application/problem+json`) |
| 401 | No valid bearer token (`unauthenticated`). Header `WWW-Authenticate`: The bearer challenge, per RFC 6750. | `Problem` (`application/problem+json`) |
| 403 | The caller can see the resource, but their Role doesn't allow this operation (`forbidden`). The attempt is audited with `result=denied`. | `Problem` (`application/problem+json`) |
| 404 | The resource doesn't exist, or the caller can't see it (`not_found`). The two are never told apart. | `Problem` (`application/problem+json`) |
| 409 | The change breaks a uniqueness rule or the resource's current state (`conflict`). | `Problem` (`application/problem+json`) |
| 429 | TooManyRequests | `Problem` (`application/problem+json`) |

## Schemas

### EmailTemplate

Which email it is: `added_to_organisation` tells an existing User they've been added to another Organisation; `invitation` carries a one-time code for someone with no account yet; `password_reset` and `set_password` carry the user pool's code to reset a password, or to set one for someone who only uses Google.

Type: `string`. One of `added_to_organisation`, `invitation`, `password_reset`, `set_password`.

### EmailStatus

Where the email has got to. `queued`: written with the change that caused it, not yet sent. `sent`: the mail service accepted it. `delivered`: the recipient's server accepted it. `bounced`: the recipient's server refused it. `complained`: the recipient marked it as spam. `failed`: it couldn't be sent. `suppressed`: not sent, because the address bounced or complained before.

Type: `string`. One of `queued`, `sent`, `delivered`, `bounced`, `complained`, `failed`, `suppressed`.

### Email

An email address. Compared case-insensitively, and returned in lower case.

Type: `string (email)`. At most 254 characters. Example: `jason@northgate.example`.

### UserId

User ID.

Type: `string`. Exactly 18 characters. Pattern `^USR[a-z0-9]{15}$`. Example: `USR8hfaw8hfpwhjf94`.

### OrganisationId

Organisation ID.

Type: `string`. Exactly 18 characters. Pattern `^ORG[a-z0-9]{15}$`. Example: `ORG8hfaw8hfpwhjf94`.

### Timestamp

UTC, with milliseconds and a `Z` suffix.

Type: `string (date-time)`. Pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$`. Example: `2026-11-28T14:27:03.412Z`.

### EmailPage

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | `array of EmailSummary` | yes |  |
| `next_cursor` | `string \| null` | yes | An opaque cursor for the next page, or `null` on the last page. |

### CursorPage

One page of a list. A list response combines this with its own `items` through `allOf`. Pass `next_cursor` back as `cursor` to get the next page; it is `null` on the last page.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | `array of any` | yes |  |
| `next_cursor` | `string \| null` | yes | An opaque cursor for the next page, or `null` on the last page. |

### EmailSummary

One email in the log, without its bodies.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `EmailId` | yes | Email ID. |
| `template` | `EmailTemplate` | yes | Which email it is: `added_to_organisation` tells an existing User they've been added to another Organisation; `invitation` carries a one-time code for someone with no account yet; `password_reset` and `set_password` carry the user pool's code to reset a password, or to set one for someone who only uses Google. |
| `status` | `EmailStatus` | yes | Where the email has got to. `queued`: written with the change that caused it, not yet sent. `sent`: the mail service accepted it. `delivered`: the recipient's server accepted it. `bounced`: the recipient's server refused it. `complained`: the recipient marked it as spam. `failed`: it couldn't be sent. `suppressed`: not sent, because the address bounced or complained before. |
| `to` | `Email` | yes | The recipient. |
| `user_id` | `UserId \| null` | yes | The recipient's User, or `null` when the address has none. |
| `organisation_id` | `OrganisationId \| null` | yes | The Organisation it is about, or `null` for a platform-level email. |
| `subject` | `string \| null` | yes | The subject as sent, with any `[DEV]` or `[STAGING]` prefix. `null` until sent. |
| `created_at` | `Timestamp` | yes | UTC, with milliseconds and a `Z` suffix. |
| `resend_of` | `EmailId \| null` | yes | The email this one resent, or `null`. |

### EmailId

Email ID.

Type: `string`. Exactly 18 characters. Pattern `^EML[a-z0-9]{15}$`. Example: `EML8hfaw8hfpwhjf94`.

### Problem

An RFC 9457 problem details object, sent as `application/problem+json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | `string (uri-reference)` | yes | A URI identifying the problem type. `about:blank` when `code` says enough. Example: `about:blank`. |
| `title` | `string` | yes | A short, human-readable summary of the problem type. Example: `Not found`. |
| `status` | `integer` | yes | The HTTP status code. 400 to 599. Example: `404`. |
| `code` | `string` | yes | A stable, snake_case machine code. Clients branch on this, never on `title`. Pattern `^[a-z][a-z0-9]*(_[a-z0-9]+)*$`. Examples: `not_found`, `invalid_id`. |
| `detail` | `string` | no | A human-readable explanation of this occurrence. |
| `instance` | `string (uri-reference)` | no | The request path that produced the problem. |
| `request_id` | `string` | yes | Links the problem to the request logs and any audit event. |
| `started_by` | `UplinkSessionStarter` | no | `channel_in_use` only: who started the Channel's active Uplink session. |
| `reason` | `string` | no | `session_ended` only: `idle` (unused past its window) or `signed_out` (by another session, e.g. after a password change). One of `idle`, `signed_out`. |
| `errors` | `array of ProblemFieldError` | no | One entry per invalid field, for `invalid_request` and `invalid_id`. |
| `retry_after_seconds` | `integer` | no | `rate_limited` only: how long to wait before trying again, in seconds. At least 0. |

### UplinkSessionStarter

Who pressed Start.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `user_id` | `UserId` | yes | User ID. |
| `name` | `string` | yes | How to show them. Their email, until Users have names. Example: `mike@northgate.example`. |

### ProblemFieldError

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `pointer` | `string` | no | A JSON Pointer into the request body, e.g. `/first_admin_email`. |
| `parameter` | `string` | no | The name of the path, query or header parameter, e.g. `organisation_id`. |
| `detail` | `string` | yes | What is wrong with the field. |

### EmailDetail

One email, with its bodies and status timeline.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `EmailId` | yes | Email ID. |
| `template` | `EmailTemplate` | yes | Which email it is: `added_to_organisation` tells an existing User they've been added to another Organisation; `invitation` carries a one-time code for someone with no account yet; `password_reset` and `set_password` carry the user pool's code to reset a password, or to set one for someone who only uses Google. |
| `status` | `EmailStatus` | yes | Where the email has got to. `queued`: written with the change that caused it, not yet sent. `sent`: the mail service accepted it. `delivered`: the recipient's server accepted it. `bounced`: the recipient's server refused it. `complained`: the recipient marked it as spam. `failed`: it couldn't be sent. `suppressed`: not sent, because the address bounced or complained before. |
| `to` | `Email` | yes | The recipient. |
| `user_id` | `UserId \| null` | yes | The recipient's User, or `null` when the address has none. |
| `organisation_id` | `OrganisationId \| null` | yes | The Organisation it is about, or `null` for a platform-level email. |
| `subject` | `string \| null` | yes | The subject as sent, with any `[DEV]` or `[STAGING]` prefix. `null` until sent. |
| `created_at` | `Timestamp` | yes | UTC, with milliseconds and a `Z` suffix. |
| `resend_of` | `EmailId \| null` | yes | The email this one resent, or `null`. |
| `html` | `string \| null` | yes | The HTML body as sent, with any one-time code masked. `null` until sent, or when it never was. |
| `text` | `string \| null` | yes | The plain-text body as sent, with any one-time code masked. `null` until sent, or when it never was. |
| `timeline` | `array of EmailStatusChange` | yes | Every status it has had, oldest first. |
| `stage` | `EmailStage \| null` | yes | The stage that sent it, which decides the subject prefix. `null` until sent, or when it never was. |
| `provider_message_id` | `string \| null` | yes | The mail service's ID for the message (SES, or Mailpit locally), once sent. |
| `cause_audit_event_id` | `AuditEventId` | yes | The audit event of the change that queued it. |

### EmailStatusChange

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `EmailStatus` | yes | Where the email has got to. `queued`: written with the change that caused it, not yet sent. `sent`: the mail service accepted it. `delivered`: the recipient's server accepted it. `bounced`: the recipient's server refused it. `complained`: the recipient marked it as spam. `failed`: it couldn't be sent. `suppressed`: not sent, because the address bounced or complained before. |
| `at` | `Timestamp` | yes | UTC, with milliseconds and a `Z` suffix. |
| `detail` | `string \| null` | yes | What the mail service said, e.g. why it bounced or failed. `null` when nothing. |

### EmailStage

The stage that sent it: `local` is a developer's environment. `local` and `dev` prefix the subject with `[DEV]`, `staging` with `[STAGING]`, and `prod` with nothing.

Type: `string`. One of `local`, `dev`, `staging`, `prod`.

### AuditEventId

Audit event ID.

Type: `string`. Exactly 18 characters. Pattern `^EVT[a-z0-9]{15}$`. Example: `EVT8hfaw8hfpwhjf94`.

### EmailResent

What a resend queued.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | `EmailDetail \| null` | yes | The new email, queued. `null` for a password reset or set-password code, which the user pool sends: its new email shows in the log a moment later, to the same address. |
