---
title: "client.Emails"
description: "Every method in this namespace: its signature, its parameters, what it returns and an example."
url: "https://openemail.uk/docs/go/reference/emails"
area: "Go"
category: "Reference"
---

# client.Emails

Every method in this namespace: its signature, its parameters, what it returns and an example.

## Methods

Send mail now or later, in batches or translated, and follow what happened to it.

### `Emails.Send`

Send, schedule or translate and send one email

```go
Send(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Sends one message now, or holds it for later with `scheduledAt` or an undo window with `cancellableForSeconds`. The body comes from exactly one source: `html` and or `text`, a stored `template`, or an existing `draftId`. Naming none is a 422, and `template` alongside `html`, `text` or `draftId` is refused. An immediate send is dispatched inside the request, so the call usually returns a `sent`, `partial` or `failed` message. A held send settles as `queued` or `scheduled`, so read `status` rather than treating a returned message as delivered mail.

Every call carries an `Idempotency-Key`. The SDK generates one per call and reuses it on that call's retries, and the API claims it against the key's own unique index before anything is dispatched, so a retried network failure replays the original message instead of sending a second one. Pass `nextmail.WithIdempotencyKey` to extend that across processes and restarts, deriving it from what made the send necessary rather than from a clock. A replay returns `replayed: true` and the stored message in its current state. The same key with a different body is a 422 `idempotency_key_reuse`.

Add `translate` to deliver the message in the recipient's language. The translation runs when the request is accepted, before any record exists, so a scheduled send carries the approved wording and a translation that cannot be produced refuses the whole send: nothing is ever delivered untranslated as a fallback. By default the subject is translated too and your original text is placed below the translation, captioned in the target language. It works with `template`, translating what the template rendered, and is refused alongside `draftId` because a draft goes as it was written.

Scopes: `emails:send`.

**Parameters**

- `from` (`any`, required): Sender as `billing@acme.com`, `Acme Billing <billing@acme.com>` or a map with `email` and `name`. It must be an address the key may send as, otherwise 403 `from_address_forbidden`.
- `to` (`any`, required): One recipient or a list. `to`, `cc` and `bcc` together hold at most 50 addresses, and more is a 422 `too_many_recipients`.
- `cc` (`any`): Copy recipients, counted toward the 50 recipient ceiling.
- `bcc` (`any`): Blind copy recipients, counted toward the 50 recipient ceiling.
- `replyTo` (`any`): Written into the `Reply-To` header.
- `subject` (`string`): At most 998 characters. Falls back to the template or draft subject when empty.
- `html` (`string`): HTML body, at most 1,000,000 characters.
- `text` (`string`): Plain text body, at most 1,000,000 characters.
- `template` (`nextmail.Body`): A stored template by id or slug. Omitting `version` resolves whatever is published at that moment, so pin it when somebody else owns the copy.
- `draftId` (`string`): Sends an existing draft as written. Cannot be combined with `template` or `translate`.
- `threadId` (`string`): Files the sent message into an existing thread.
- `headers` (`nextmail.Body`): Custom headers limited to `X-*`, `List-*`, `Reply-To`, `Precedence`, `Auto-Submitted`, `Importance`, `Priority` and `Feedback-ID`. Anything the server sets itself is a 422 `reserved_header`.
- `attachments` (`[]nextmail.Body`): At most 20 files. Each entry is either an inline file, with `filename` and `content` as bytes or a base64 string (bytes are encoded for you, and inline files are capped at 10 MB in total once decoded), or a stored file as a map with `fileId` naming a file already uploaded to the workspace, which is how a file larger than the inline cap is sent. A file at an https address is a map with `url` and optionally `filename` and `contentType`, fetched once when the message is accepted. Inline and `url` files come to at most 25 MB together.
- `attachmentDelivery` (`string`): How the files in `attachments` travel. `mime` carries them inside the message, so files that come to more than 25 MB together are refused. `link` uploads each file and puts a download link in the body in its place, so the message itself stays small. `auto` links when the files together come to more than 25 MB, or to more than 2 MB when the `from` domain has an active files domain, and attaches them otherwise. Left out, the sender's mailbox setting applies, and that defaults to `auto`.
- `scheduledAt` (`time.Time | string`): A `time.Time`, an ISO 8601 instant or a duration such as `PT1H` or `P2D`. At least one second and at most 365 days out.
- `followUpAt` (`time.Time | string`): Asks to be reminded if nobody replies: a `time.Time`, an ISO 8601 instant or a duration from now such as `P3D`, later than the time the message goes out and at most 365 days out. If no real reply has arrived by then, the thread returns to the top of the inbox, unread, with a push. `FollowUps.List` lists the reminders and `FollowUps.Cancel` cancels one.
- `cancellableForSeconds` (`int`): An undo window from 0 to 900 seconds on an immediate send. Refused alongside `scheduledAt`, which is already cancellable until it goes.
- `tracking` (`nextmail.Body`): Overrides the tracking setting for this send. A field left out takes the setting of the address it is sent from: its own, else its domain catch-all's when the catch-all caught that address, else off.
- `signature` (`bool`): An `html` body goes out exactly as written, so it carries a signature only when this is `true`, while a `text`-only body carries one unless this is `false`. When it is added it is the default signature of the address it is sent from: the one it keeps for replies when the message answers a thread (`threadId` or an `In-Reply-To` header), and the one for new mail otherwise. An address with no signature of its own takes its domain catch-all's when the catch-all caught that address, else the Nextmail footer unless that address turned the footer off. `signatureId` picks another signature of the address. Template sends and encrypted sends never carry one.
- `signatureId` (`string`): Adds one particular signature of the `from` address in place of its default, by the id `Signatures.List` returns. It signs an `html` body too, so `signature: true` is not needed with it, and it cannot be combined with `signature: false`. An id that is not a signature of the `from` address is a 422 `invalid_parameter`. When the signature is deleted before a scheduled message goes out, the message carries the default of the address instead.
- `tags` (`nextmail.Body`): Up to 10 tags, keys of 1 to 64 letters, digits, `_` or `-`, values up to 256 characters. Echoed back on every read.
- `stream` (`string`): The lane the message travels in: `transactional`, the default, for mail one person is waiting for, or `broadcast` for newsletters and other mail to many people. Each lane has its own queue and its own reputation.
- `translate` (`nextmail.Body`): a map with `to` and optionally `from`, `includeOriginal` and `subject`. `to` takes a code, an English name or an endonym. `includeOriginal` and `subject` both default to true.
- `nextmail.WithIdempotencyKey` (`string`): Your own key, 1 to 255 characters of letters, digits, `_`, `.`, `:` or `-`. Anything else is a 400 `invalid_idempotency_key`.
- `nextmail.WithAPIKey` (`string`): Sends with this key instead of the client's, for a process sending on behalf of several workspaces.

**Returns**

An `nextmail.Object`, an email object plus `replayed`. Notable fields are `id` (`msg_` plus 24 hex), `status`, `mode`, `from`, `subject`, `scheduledAt`, `cancellableUntil`, `sentAt`, `lastError`, `tags`, `stream` and, on a translated send, `translation`.

**Example**

```go
invoice, err := os.ReadFile("invoice.pdf")
if err != nil {
	return err
}

sent, err := client.Emails.Send(ctx, nextmail.Body{
	"from":    "Acme Billing <billing@acme.com>",
	"to":      "ada@example.de",
	"subject": "Your September invoice",
	"html":    "<p>The invoice is attached. Tell me if anything on it looks wrong.</p>",
	"attachments": []nextmail.Body{
		{"filename": "invoice.pdf", "content": invoice, "contentType": "application/pdf"},
	},
	"translate": nextmail.Body{"to": "de"},
	"tags":      nextmail.Body{"invoice": "inv_2026_09_4192"},
}, nextmail.WithIdempotencyKey("invoice:inv_2026_09_4192"))
if err != nil {
	return err
}

fmt.Println(sent.ID(), "is", sent.String("status"), sent.Bool("replayed"))
fmt.Println("Sent in", sent.Object("translation").String("language"))
```

**Notes**

- A message sent with `stream` set to `broadcast` while that lane is paused for too many bounces or complaints is refused with 409 `stream_paused`. `Sending.ListStreams` shows why, and app mail on the `transactional` lane still goes.
- On the `broadcast` lane, a message to one recipient whose `headers` hold no `List-Unsubscribe` gets `List-Unsubscribe` and `List-Unsubscribe-Post` for one-click unsubscribe. Whoever uses them joins the unsubscribe list that `Suppressions.ListUnsubscribes` reads, and broadcast lane mail is not sent to anybody on that list: the recipient is `suppressed` and `email.suppressed` says why. Transactional mail still reaches them.
- A `from` on a domain that is known to the workspace but cannot sign mail yet is refused up front with 409 `domain_not_sendable` and `param` set to `from`, so nothing is accepted that would only fail at dispatch. `Addresses.List` shows the same verdict as `canSend` before you send.
- A test key (`oe_test_`) never delivers. The message is marked `sent` with `transport` set to `test` and every recipient `delivered`, so assert on the response and not on an inbox.
- The idempotency fingerprint covers the template version the send resolved to. Retrying an unpinned template send after somebody publishes a new version is a 422 `idempotency_key_reuse`, not a replay. `scheduledAt` is left out of the fingerprint.
- A spent send allowance is a 429 `send_quota_exceeded` with no `Retry-After`, and it resets on the first of the month. The SDK does not retry a 429 that carries no `Retry-After`, so the call fails straight away.
- Translation failures refuse the send: 409 `translation_not_configured` when the workspace has no AI, 422 `translation_too_long` past 30,000 characters, 429 `ai_quota_exceeded` when the workspace has used today's AI actions, and 503 `translation_failed` when the provider did not answer.
- A translated send spends one AI action. `nextmail.ErrRetryable` is true for every 429, but `ai_quota_exceeded` fails the same way until the allowance resets at midnight UTC, so show it to a person or send without `translate`.
- A `followUpAt` that is not later than the time the message goes out, or is more than 365 days out, refuses the send with a 422 whose `param` is `followUpAt`, coded `invalid_follow_up` or `invalid_parameter`, and nothing is sent. A `time.Time` is sent as an ISO 8601 instant, as it does for `scheduledAt`.

Also available in: API [`POST /emails`](https://openemail.uk/docs/api/reference/emails#post-emails); TypeScript [`nextmail.emails.send()`](https://openemail.uk/docs/sdk/reference/emails#send); Python [`emails.send()`](https://openemail.uk/docs/python/reference/emails#send); Ruby [`emails.send`](https://openemail.uk/docs/ruby/reference/emails#send); PHP [`emails->send`](https://openemail.uk/docs/php/reference/emails#send); Java [`emails().send`](https://openemail.uk/docs/java/reference/emails#send); C# [`Emails.SendAsync`](https://openemail.uk/docs/csharp/reference/emails#send); CLI [`openemail emails send`](https://openemail.uk/docs/cli/reference/emails#emails-send).

### `Emails.SendBatch`

Send up to 100 independent emails in one request

```go
SendBatch(ctx context.Context, emails []nextmail.Body, opts ...nextmail.RequestOption) (*nextmail.BatchResult, error)
```

Sends each message in order, as if `Emails.Send` had been called for it, and reports per item. It is never all or nothing: a bad address on item 7 fails item 7 and the rest still go, because a batch that rolled back would turn your retry into a guess about which messages had already been delivered. The call returns whenever the batch was processed, so check `Failed` and each item's `status` rather than relying on an error.

The batch shares one `Idempotency-Key`, generated once per call or supplied as `nextmail.WithIdempotencyKey`, and the server derives a separate key per item from it and the item's position. Retrying the same list replays the items that already went and sends only the ones that did not. Reordering the list between attempts changes which body each position's key is bound to, so an item that moved comes back as an `idempotency_key_reuse` error.

Apart from a key or scope failure or a server fault, only problems with the batch as a whole fail the call with a 422: an empty list, more than 100 messages, or more than 10 messages carrying `translate`. Translation costs several model calls per message and they run one after another, so a larger translated batch would time out partway. Split it, or schedule the messages instead.

Scopes: `emails:send`.

**Parameters**

- `emails` (`[]nextmail.Body`, required): Between 1 and 100 messages, each shaped exactly like the body of `Emails.Send`, `followUpAt` included, and validated on its own.
- `nextmail.WithIdempotencyKey` (`string`): Your own batch key, 1 to 255 characters of letters, digits, `_`, `.`, `:` or `-`.
- `nextmail.WithAPIKey` (`string`): Sends the batch with this key instead of the client's.

**Returns**

An `*nextmail.BatchResult` with `Sent`, `Failed` and `Items`. Each item has its `index` and either `status` set to `ok` with the `email`, shaped like what `Send` returns, or `status` set to `error` with an `error` carrying `type`, `code`, `message` and, when a field is to blame, `param`.

**Example**

```go
result, err := client.Emails.SendBatch(ctx, []nextmail.Body{
	{
		"from":    "dispatch@acme.com",
		"to":      "ada@example.com",
		"subject": "Order AC-4192 has shipped",
		"text":    "It is on its way.",
	},
	{
		"from":    "dispatch@acme.com",
		"to":      "grace@example.com",
		"subject": "Order AC-4193 has shipped",
		"text":    "It is on its way.",
	},
}, nextmail.WithIdempotencyKey("shipments:2026-09-15"))
if err != nil {
	return err
}

fmt.Println(result.Sent, "sent,", result.Failed, "failed")

for _, item := range result.Items {
	if item.String("status") == "error" {
		failure := item.Object("error")

		fmt.Println("Item", item.Int("index"), failure.String("code"), failure.String("message"))
	}
}
```

**Notes**

- Each entry is authorised on its own, so a `from` on a domain that cannot sign yet fails that entry with `domain_not_sendable` while the rest go.
- Once the send allowance of the workspace runs out partway, every remaining item fails with `send_quota_exceeded` while the earlier ones stay sent. It is counted for that workspace alone, so sends from other workspaces never spend it. A workspace on a paid plan with pay as you go turned on keeps sending past it instead.
- Each item with `translate` spends one AI action. Once that account has used today's AI actions, every remaining item with `translate` fails with `ai_quota_exceeded` while items without it still go. Retrying those items fails the same way until the allowance resets at midnight UTC, unless the account has pay as you go turned on.
- An unexpected server fault aborts the batch with a 500 after the earlier items have gone. The SDK retries it with the same key, which replays those items instead of sending them twice.
- Items are processed one after another inside a single request, so a large batch of immediate sends takes noticeably longer than one `Send`. Keep the client timeout generous.

Also available in: API [`POST /emails/batch`](https://openemail.uk/docs/api/reference/emails#post-emails-batch); TypeScript [`nextmail.emails.sendBatch()`](https://openemail.uk/docs/sdk/reference/emails#sendBatch); Python [`emails.send_batch()`](https://openemail.uk/docs/python/reference/emails#sendBatch); Ruby [`emails.send_batch`](https://openemail.uk/docs/ruby/reference/emails#sendBatch); PHP [`emails->sendBatch`](https://openemail.uk/docs/php/reference/emails#sendBatch); Java [`emails().sendBatch`](https://openemail.uk/docs/java/reference/emails#sendBatch); C# [`Emails.SendBatchAsync`](https://openemail.uk/docs/csharp/reference/emails#sendBatch); CLI [`openemail emails send-batch`](https://openemail.uk/docs/cli/reference/emails#emails-send-batch).

### `Emails.Translate`

Preview a translation without sending anything

```go
Translate(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Runs the same translation `translate` performs on a send and stops one step early. The same function produces both, so what comes back is what would go out. Nothing is stored and nothing is sent. Use it when somebody should read the translated wording before it reaches a recipient.

Send the approved result as an ordinary `subject` and `html` on `Emails.Send` with no `translate` option. Passing `translate` again translates a second time, moving the wording off the version that was signed off and discarding any edits. When `includeOriginal` is on, `html` already contains your original text below the translation, so do not append your own copy.

At least one of `html`, `text` or `subject` is required. `to` accepts a BCP-47 code, an English name or the language's own name, and the response reports the code it settled on in `language.code`, which is the form worth storing. State `from` to skip language detection. Otherwise it is detected from the body, and a detector that cannot tell returns null in `detectedSourceLanguage` rather than guessing.

Scopes: `emails:send`.

**Parameters**

- `to` (`string`, required): Target language as a code (`de`), English name (`German`) or endonym (`Deutsch`). An unrecognised value is a 422 `invalid_parameter` on `to`.
- `from` (`string`): The language you wrote in. Stating it skips the detection call.
- `includeOriginal` (`bool`): Defaults to true, placing your original text below the translation under a caption in the target language.
- `subject` (`string`): Subject line to translate, at most 998 characters.
- `html` (`string`): HTML body to translate. Only the content inside `<body>` is sent to the model when the markup is a full document.
- `text` (`string`): Plain text body to translate. Translated separately when given alongside `html`.
- `nextmail.WithAPIKey` (`string`): Runs the preview with this key instead of the client's.

**Returns**

An `nextmail.Object` with `object` set to `translation`, `language` and `detectedSourceLanguage` as full language object rows, `subject`, `html` and `text` (each null when that input was not given) and `includeOriginal`.

**Example**

```go
preview, err := client.Emails.Translate(ctx, nextmail.Body{
	"to":      "ja",
	"subject": "Your September invoice",
	"html":    "<p>The invoice is attached.</p>",
})
if err != nil {
	return err
}

fmt.Println(preview.Object("language").String("native"), preview.Object("detectedSourceLanguage").String("code"), preview.String("subject"), preview.String("html"))
```

**Notes**

- The SDK never retries this call. Each attempt spends one AI action, as a translated send does. Handle a 503 `translation_failed` yourself, and treat a 429 `ai_quota_exceeded` as final until the allowance resets at midnight UTC.
- Anything over 30,000 characters is refused with 422 `translation_too_long` rather than truncated, since half a translation has no seam to show where it stopped.
- A right-to-left target comes back with `html` wrapped in `dir="rtl"`.
- A workspace with no AI configured gets 409 `translation_not_configured`, and retrying will fail the same way.

Also available in: API [`POST /emails/translate`](https://openemail.uk/docs/api/reference/emails#post-emails-translate); TypeScript [`nextmail.emails.translate()`](https://openemail.uk/docs/sdk/reference/emails#translate); Python [`emails.translate()`](https://openemail.uk/docs/python/reference/emails#translate); Ruby [`emails.translate`](https://openemail.uk/docs/ruby/reference/emails#translate); PHP [`emails->translate`](https://openemail.uk/docs/php/reference/emails#translate); Java [`emails().translate`](https://openemail.uk/docs/java/reference/emails#translate); C# [`Emails.TranslateAsync`](https://openemail.uk/docs/csharp/reference/emails#translate); CLI [`openemail emails translate`](https://openemail.uk/docs/cli/reference/emails#emails-translate).

### `Emails.Check`

Check how a message would be rated, without sending it

```go
Check(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Scores a message the way a receiving mailbox would, before it goes out: a spam score, a phishing score and an AI-writing score, each 0 to 100, with the signals behind each one. Nothing is stored and nothing is sent.

The same checks score every message that arrives in a mailbox on Nextmail, so what comes back is what a recipient on Nextmail sees in Details. It cannot know a recipient's own filter, sender history or reputation, so a low score is a good sign and not a delivery guarantee.

Run it before an automated send, or as someone writes, and fix what `signals` names. Sender authentication is taken as passing, since the message will be signed for your domain.

Scopes: `emails:send`.

**Parameters**

- `subject` (`string`): Subject line, at most 998 characters.
- `html` (`string`): HTML body. Links and images are read from it.
- `text` (`string`): Plain text body. Taken from `html` when left out.
- `from` (`string`): The address it will be sent from.
- `fromName` (`string`): The display name it will carry. A name that claims another address or a known brand raises the phishing score.
- `replyTo` (`string`): A Reply-To on a different domain raises the phishing score.
- `replying` (`bool`): True when it answers an existing thread. A `Re:` subject on a message that answers nothing raises the spam score.
- `attachmentNames` (`[]string`): File names, so an attachment that can run code is caught.
- `nextmail.WithAPIKey` (`string`): Runs the check with this key instead of the client's.

**Returns**

An `nextmail.Object` with `object` set to `email_check` and three scores. `spam` carries `score`, `level` (`low`, `medium` from 35, `high` from 60) and `signals`. `phishing` carries `score`, `level` (`clear`, `caution` from 30, `danger` from 60), `signals` and `reasons`. `ai` carries `score` (null when not judged), `level`, `signals`, `reasons`, `words` and `skipped` (`too-short` under 40 words).

**Example**

```go
check, err := client.Emails.Check(ctx, nextmail.Body{
	"from":    "billing@acme.com",
	"subject": "Your September invoice",
	"html":    "<p>The invoice is attached.</p>",
})
if err != nil {
	return err
}

fmt.Println(check.Object("spam").String("level"), check.Object("spam").Int("score"), check.Object("phishing").Int("score"), check.Object("ai").Int("score"))
```

**Notes**

- It spends no AI action and never calls a model, so it is safe to run on every revision.
- A score is not a probability. Each one adds up weighted signals, heaviest first in `signals`.

Also available in: API [`POST /emails/check`](https://openemail.uk/docs/api/reference/emails#post-emails-check); TypeScript [`nextmail.emails.check()`](https://openemail.uk/docs/sdk/reference/emails#check); Python [`emails.check()`](https://openemail.uk/docs/python/reference/emails#check); Ruby [`emails.check`](https://openemail.uk/docs/ruby/reference/emails#check); PHP [`emails->check`](https://openemail.uk/docs/php/reference/emails#check); Java [`emails().check`](https://openemail.uk/docs/java/reference/emails#check); C# [`Emails.CheckAsync`](https://openemail.uk/docs/csharp/reference/emails#check); CLI [`openemail emails check`](https://openemail.uk/docs/cli/reference/emails#emails-check).

### `Emails.List`

List one page of sent emails, newest first

```go
List(ctx context.Context, opts ...nextmail.RequestOption) (*nextmail.Page, error)
```

Returns one page of the workspace's send records, ordered newest first. Paging is keyset rather than offset: `NextCursor` is the id of the last message on the page, and passing it back as `cursor` continues strictly after it, so messages sent while you page never shift or repeat rows. `HasMore` is false on the last page and `NextCursor` is then null.

Filter with `status`, one value or an array that the SDK joins with commas, with `from`, which matches the sending address exactly and ignores case, with `broadcastId`, which keeps the copies of one broadcast, and with `scheduledFrom` and `scheduledTo`, which keep the messages scheduled inside a window. An unrecognised status is a 422 `invalid_parameter` naming the offending values, and a cursor that names no message in the workspace is a 400 `invalid_cursor`.

Rows are the summary form. They never carry `recipients` or `translation`, whose absence on a row says nothing either way, and a tracked message carries only the counts half of `tracking`: `opens`, `clicks`, `opened`, `clicked`, `openCount`, `clickCount` and `firstOpenAt`. Call `Get` for per-recipient delivery state and `GetTracking` for the full engagement report.

Scopes: `emails:read`.

**Parameters**

- `nextmail.WithStatus` (`...string`): One or more of `queued`, `scheduled`, `sending`, `sent`, `partial`, `bounced`, `cancelled` and `failed`.
- `nextmail.WithFromAddress` (`string`): A bare sending address such as `billing@acme.com`, matched exactly and case insensitively. A display name form does not match.
- `nextmail.WithBroadcastID` (`string`): Only the copies of one broadcast, a `brd_` id from `Broadcasts.Send`. Each person a broadcast reaches gets a message of their own, so this lists who it went to and what happened to each copy. An id that names no broadcast answers an empty page.
- `nextmail.WithScheduledFrom` (`time.Time`): Only messages scheduled for this instant or later. With `scheduledTo` and `status: ['scheduled', 'queued']` it lists what is waiting to go out in a window, as the calendar of the app does. A message with no `scheduledAt` is left out.
- `nextmail.WithScheduledTo` (`time.Time`): Only messages scheduled for this instant or earlier. `scheduledFrom` after `scheduledTo` is a 422 `invalid_parameter`.
- `nextmail.WithSince` (`time.Time`): Only messages made at this instant or later.
- `nextmail.WithUntil` (`time.Time`): Only messages made before this instant. `since` after `until` is a 422 `invalid_parameter`.
- `nextmail.WithRecipient` (`string`): Only messages that went to this address as a to, cc or bcc recipient, matched exactly.
- `nextmail.WithTag` (`string`): Only messages sent with this tag: `name` for any value, or `name:value` for one value. Tags are stored encrypted, so the match is exact and case-sensitive.
- `nextmail.WithLimit` (`int`): Rows per page, a whole number from 1 to 100, defaulting to 25. Outside that range is a 422.
- `nextmail.WithCursor` (`string`): The `NextCursor` from the previous page, which is a message id.
- `nextmail.WithAPIKey` (`string`): Lists with this key instead of the client's.

**Returns**

A `*nextmail.Page` with `Items`, `HasMore` and `NextCursor`. Each item has `id`, `status`, `mode`, `from`, `subject`, `transport`, `attempts`, `lastError`, `scheduledAt`, `cancellableUntil`, `sentAt`, `tags`, `broadcastId`, `source`, `createdAt` and, when tracked, the trimmed `tracking` counts.

**Example**

```go
page, err := client.Emails.List(
	ctx,
	nextmail.WithStatus("failed", "partial"),
	nextmail.WithFromAddress("billing@acme.com"),
	nextmail.WithLimit(50),
)
if err != nil {
	return err
}

for _, email := range page.Items {
	fmt.Println(email.String("id"), email.String("status"), email.String("lastError"))
}

fmt.Println(page.HasMore, page.NextCursor)
```

**Notes**

- With a narrowed key only messages sent from addresses it covers are read, and the page is cut after that filter, so every page but the last holds `limit` items. A key that holds a whole domain covers every address on it.
- A `from` the key does not cover returns an empty last page rather than a 403.
- `tracking` is absent, not zeroed, on a message that carried no pixel or rewritten link.

Also available in: API [`GET /emails`](https://openemail.uk/docs/api/reference/emails#get-emails); TypeScript [`nextmail.emails.list()`](https://openemail.uk/docs/sdk/reference/emails#list); Python [`emails.list()`](https://openemail.uk/docs/python/reference/emails#list); Ruby [`emails.list`](https://openemail.uk/docs/ruby/reference/emails#list); PHP [`emails->list`](https://openemail.uk/docs/php/reference/emails#list); Java [`emails().list`](https://openemail.uk/docs/java/reference/emails#list); C# [`Emails.ListAsync`](https://openemail.uk/docs/csharp/reference/emails#list); CLI [`openemail emails list`](https://openemail.uk/docs/cli/reference/emails#emails-list).

### `Emails.ListAll`

Collect every matching sent email into one slice

```go
ListAll(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)
```

Follows `NextCursor` from page to page and returns once the last page has been read, with every matching send record in one slice, newest first. It accepts the same filters as `List` and returns the same summary rows, so there are no `recipients` or `translation` on them and `tracking` is the trimmed counts form.

Everything is held in memory before the call returns, and a workspace's send history grows without bound. Narrow it with `status` or `from`, or switch to `Iterate` when you want to stop early or process rows as they arrive. `limit` sets the page size of each underlying request, not the total, so a larger value means fewer round trips.

Scopes: `emails:read`.

**Parameters**

- `nextmail.WithStatus` (`...string`): One or more statuses to keep, joined with commas on the wire.
- `nextmail.WithFromAddress` (`string`): A bare sending address, matched exactly and case insensitively.
- `nextmail.WithBroadcastID` (`string`): Only the copies of one broadcast, a `brd_` id.
- `nextmail.WithScheduledFrom` (`time.Time`): Only messages scheduled for this instant or later.
- `nextmail.WithScheduledTo` (`time.Time`): Only messages scheduled for this instant or earlier.
- `nextmail.WithSince` (`time.Time`): Only messages made at this instant or later.
- `nextmail.WithUntil` (`time.Time`): Only messages made before this instant.
- `nextmail.WithRecipient` (`string`): Only messages that went to this address as a to, cc or bcc recipient.
- `nextmail.WithTag` (`string`): Only messages sent with this tag: `name` for any value, or `name:value` for one value.
- `nextmail.WithLimit` (`int`): Page size per request, from 1 to 100, defaulting to 25 on the server.
- `nextmail.WithCursor` (`string`): A message id to start after, skipping everything newer.
- `nextmail.WithAPIKey` (`string`): Lists with this key instead of the client's.

**Returns**

A `[]nextmail.Object` holding every row across all pages.

**Example**

```go
scheduled, err := client.Emails.ListAll(ctx, nextmail.WithStatus("scheduled"), nextmail.WithLimit(100))
if err != nil {
	return err
}

for _, email := range scheduled {
	fmt.Println(email.String("scheduledAt"), email.String("id"))
}
```

**Notes**

- A failure on any page fails the whole call, and the rows already fetched are discarded.
- With a narrowed key only messages sent from addresses it covers are collected, and every page but the last is full.

Also available in: API [`GET /emails`](https://openemail.uk/docs/api/reference/emails#get-emails); TypeScript [`nextmail.emails.listAll()`](https://openemail.uk/docs/sdk/reference/emails#listAll); Python [`emails.list_all()`](https://openemail.uk/docs/python/reference/emails#listAll); Ruby [`emails.list_all`](https://openemail.uk/docs/ruby/reference/emails#listAll); PHP [`emails->listAll`](https://openemail.uk/docs/php/reference/emails#listAll); Java [`emails().listAll`](https://openemail.uk/docs/java/reference/emails#listAll); C# [`Emails.ListAllAsync`](https://openemail.uk/docs/csharp/reference/emails#listAll).

### `Emails.Iterate`

Stream sent emails one at a time across pages

```go
Iterate(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.Iterator
```

Returns an iterator that yields send records individually, newest first, and requests the next page only once the current one is drained. Nothing is fetched until you start consuming it, and breaking out of the loop stops the requests, so this is the cheapest way to find the most recent message matching a condition the filters cannot express.

The walk is keyset based, following `NextCursor` from page to page. Mail sent while you iterate lands ahead of where you started and is never yielded, and nothing already yielded comes round again. Rows are the same summary form `List` returns.

Scopes: `emails:read`.

**Parameters**

- `nextmail.WithStatus` (`...string`): One or more statuses to keep, joined with commas on the wire.
- `nextmail.WithFromAddress` (`string`): A bare sending address, matched exactly and case insensitively.
- `nextmail.WithBroadcastID` (`string`): Only the copies of one broadcast, a `brd_` id.
- `nextmail.WithScheduledFrom` (`time.Time`): Only messages scheduled for this instant or later.
- `nextmail.WithScheduledTo` (`time.Time`): Only messages scheduled for this instant or earlier.
- `nextmail.WithSince` (`time.Time`): Only messages made at this instant or later.
- `nextmail.WithUntil` (`time.Time`): Only messages made before this instant.
- `nextmail.WithRecipient` (`string`): Only messages that went to this address as a to, cc or bcc recipient.
- `nextmail.WithTag` (`string`): Only messages sent with this tag: `name` for any value, or `name:value` for one value.
- `nextmail.WithLimit` (`int`): Page size per request, from 1 to 100, defaulting to 25 on the server.
- `nextmail.WithCursor` (`string`): A message id to start after.
- `nextmail.WithAPIKey` (`string`): Lists with this key instead of the client's.

**Returns**

An `*nextmail.Iterator` yielding one send record per step.

**Example**

```go
for email, err := range client.Emails.Iterate(ctx, nextmail.WithStatus("failed"), nextmail.WithLimit(100)).All() {
	if err != nil {
		return err
	}

	fmt.Println(email.String("id"), email.String("lastError"))
}
```

**Notes**

- The iterator is lazy, so an abandoned loop costs only the pages you consumed.
- With a narrowed key only messages sent from addresses it covers are yielded, and every page but the last is full.

Also available in: API [`GET /emails`](https://openemail.uk/docs/api/reference/emails#get-emails); TypeScript [`nextmail.emails.iterate()`](https://openemail.uk/docs/sdk/reference/emails#iterate); Python [`emails.iterate()`](https://openemail.uk/docs/python/reference/emails#iterate); Ruby [`emails.iterate`](https://openemail.uk/docs/ruby/reference/emails#iterate); PHP [`emails->iterate`](https://openemail.uk/docs/php/reference/emails#iterate); Java [`emails().iterate`](https://openemail.uk/docs/java/reference/emails#iterate); C# [`Emails.IterateAsync`](https://openemail.uk/docs/csharp/reference/emails#iterate).

### `Emails.Get`

Read one sent email with per-recipient state

```go
Get(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Returns the full send record for one message: its lifecycle `status`, delivery `attempts` and `lastError`, the schedule fields, and the two parts a list row leaves out. `recipients` has one entry per address with its own `status`, `error` and `deliveredAt`, and `translation` records what was done to a translated send.

A message that went out as a single call can still land differently per recipient. `status` on the message says how the send went as a whole, while each recipient moves on as delivery reports, bounces and complaints arrive. `uncertain` is a real recipient state: a transport that failed partway cannot say which recipients it reached. `suppressed` marks an address that previously bounced or complained in this workspace and was held back.

When the message was tracked, `tracking` carries the full engagement report with per-recipient and per-link detail. When it was not tracked, the field is absent rather than zeroed, because a message with no pixel has no evidence about whether anybody read it.

Scopes: `emails:read`.

**Parameters**

- `id` (`string`, required): The send id, `msg_` followed by 24 hex characters, as returned by `Send`.
- `nextmail.WithAPIKey` (`string`): Reads with this key instead of the client's.

**Returns**

An `nextmail.Object` with `id`, `status`, `mode`, `from`, `subject`, `threadId`, `transport`, `attempts`, `lastError`, `scheduledAt`, `cancellableUntil`, `sentAt`, `tags`, `broadcastId`, `source`, `createdAt`, `recipients` and, when present, `translation` and the full `tracking` report.

**Example**

```go
email, err := client.Emails.Get(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20")
if err != nil {
	return err
}

fmt.Println(email.String("status"))
```

**Notes**

- Do not correlate on `messageId`. The header is rewritten on the way out, so that value appears in no bounce or delivery report. Webhook events name the send by this `id`, as `emailId`.
- A 404 never distinguishes a missing id from one in another workspace, and a narrowed key gets the same 404 for a message sent from an address it does not cover.
- `transport` stays null until dispatch, and reads `test` on every message sent with a test key.

Also available in: API [`GET /emails/{id}`](https://openemail.uk/docs/api/reference/emails#get-emails-id); TypeScript [`nextmail.emails.get()`](https://openemail.uk/docs/sdk/reference/emails#get); Python [`emails.get()`](https://openemail.uk/docs/python/reference/emails#get); Ruby [`emails.get`](https://openemail.uk/docs/ruby/reference/emails#get); PHP [`emails->get`](https://openemail.uk/docs/php/reference/emails#get); Java [`emails().get`](https://openemail.uk/docs/java/reference/emails#get); C# [`Emails.GetAsync`](https://openemail.uk/docs/csharp/reference/emails#get); CLI [`openemail emails get`](https://openemail.uk/docs/cli/reference/emails#emails-get).

### `Emails.ListEvents`

Read one page of the event trail of one sent email

```go
ListEvents(ctx context.Context, id string, opts ...nextmail.RequestOption) (*nextmail.Page, error)
```

Returns one page of everything recorded against one send, oldest first. Nothing is dropped from the trail, so following `NextCursor` while `HasMore` is true reaches its newest event, and `ListAllEvents` and `IterateEvents` do that walk for you. It is the audit behind the current `status`: when the message was accepted or held, when it was rescheduled or cancelled, when it went out or failed, and every delivery report, bounce, complaint, open, click and file download attributed to it afterwards.

Each event has a dotted `type` and a `data` object whose shape depends on it. `email.accepted`, `email.queued` and `email.scheduled` open the trail with the source and recipient count. `email.sent` names the `transport` and `messageId`. `email.failed` carries the `error`. `email.bounced` and `email.complained` list the affected `recipients` and whether they were suppressed. `email.delivered`, `email.rescheduled`, `email.cancelled`, `email.opened`, `email.clicked` and `email.downloaded` follow as they happen. `email.downloaded` counts a person fetching a file that went out as a download link, never a scanner, and carries no `recipient`: the link is the same for everyone the message went to, so a download cannot be attributed. `data` is an empty object when an event carries nothing.

Webhooks deliver a subset of these same events as they occur, so this is where to look when a webhook was missed or never subscribed.

Scopes: `emails:read`.

**Parameters**

- `id` (`string`, required): The `msg_` send id whose trail to read.
- `nextmail.WithLimit` (`int`): Events per page, a whole number from 1 to 100, defaulting to 25.
- `nextmail.WithCursor` (`string`): The `NextCursor` from the previous page, which is an event id. One that names no event of this send is a 400 `invalid_cursor`.
- `nextmail.WithAPIKey` (`string`): Reads with this key instead of the client's.

**Returns**

A `*nextmail.Page` with `Items`, `HasMore` and `NextCursor`. Each item has `object` set to `event`, `id`, `type`, `data` and `createdAt`.

**Example**

```go
page, err := client.Emails.ListEvents(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20", nextmail.WithLimit(100))
if err != nil {
	return err
}

for _, event := range page.Items {
	fmt.Println(event.String("type"))
}

fmt.Println(page.HasMore, page.NextCursor)
```

**Notes**

- `email.delivered` is recorded in this trail but is never sent as a webhook, so a delivery report surfaces only here and in `recipients` on `Get`.
- A send made with a test key records `email.sent` with `transport: 'test'` and `simulated: true` in `data`.
- An unknown id is a 404, never an empty page.
- A tracked message opened or clicked many times records one event per counted hit, so its trail can run to many pages.

Also available in: API [`GET /emails/{id}/events`](https://openemail.uk/docs/api/reference/emails#get-emails-id-events); TypeScript [`nextmail.emails.listEvents()`](https://openemail.uk/docs/sdk/reference/emails#listEvents); Python [`emails.list_events()`](https://openemail.uk/docs/python/reference/emails#listEvents); Ruby [`emails.list_events`](https://openemail.uk/docs/ruby/reference/emails#listEvents); PHP [`emails->listEvents`](https://openemail.uk/docs/php/reference/emails#listEvents); Java [`emails().listEvents`](https://openemail.uk/docs/java/reference/emails#listEvents); C# [`Emails.ListEventsAsync`](https://openemail.uk/docs/csharp/reference/emails#listEvents); CLI [`openemail emails list-events`](https://openemail.uk/docs/cli/reference/emails#emails-list-events).

### `Emails.ListAllEvents`

Collect the whole event trail of one sent email into one slice

```go
ListAllEvents(ctx context.Context, id string, opts ...nextmail.RequestOption) ([]nextmail.Object, error)
```

Walks every page of one send's event trail and returns with all of it, oldest first: acceptance, scheduling, sending, every delivery report, bounce and complaint, and every counted open, click and download afterwards.

A widely read message can hold a great many events, all in memory before the call returns. Prefer `IterateEvents` when you can stop early. `limit` sets the page size of each request, not the total.

Scopes: `emails:read`.

**Parameters**

- `id` (`string`, required): The `msg_` send id whose trail to read.
- `nextmail.WithLimit` (`int`): Page size per request, from 1 to 100, defaulting to 25 on the server.
- `nextmail.WithCursor` (`string`): An event id to start after, skipping every older event.
- `nextmail.WithAPIKey` (`string`): Reads with this key instead of the client's.

**Returns**

A `[]nextmail.Object` holding every event across all pages, oldest first.

**Example**

```go
events, err := client.Emails.ListAllEvents(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20", nextmail.WithLimit(100))
if err != nil {
	return err
}

for _, event := range events {
	fmt.Println(event.String("type"))
}
```

**Notes**

- A failure on any page fails the whole call, and the events already fetched are discarded.
- An unknown id is a 404 on the first page.

Also available in: API [`GET /emails/{id}/events`](https://openemail.uk/docs/api/reference/emails#get-emails-id-events); TypeScript [`nextmail.emails.listAllEvents()`](https://openemail.uk/docs/sdk/reference/emails#listAllEvents); Python [`emails.list_all_events()`](https://openemail.uk/docs/python/reference/emails#listAllEvents); Ruby [`emails.list_all_events`](https://openemail.uk/docs/ruby/reference/emails#listAllEvents); PHP [`emails->listAllEvents`](https://openemail.uk/docs/php/reference/emails#listAllEvents); Java [`emails().listAllEvents`](https://openemail.uk/docs/java/reference/emails#listAllEvents); C# [`Emails.ListAllEventsAsync`](https://openemail.uk/docs/csharp/reference/emails#listAllEvents).

### `Emails.IterateEvents`

Stream the event trail of one sent email one event at a time

```go
IterateEvents(ctx context.Context, id string, opts ...nextmail.RequestOption) *nextmail.Iterator
```

Returns an iterator over one send's event trail that yields events individually, oldest first, and fetches the next page only when the current one is drained. Nothing is requested until you consume it, and breaking out of the loop stops further requests.

The walk moves forward in time, so events recorded while you iterate are yielded when the walk reaches them, and it ends when `HasMore` is false.

Scopes: `emails:read`.

**Parameters**

- `id` (`string`, required): The `msg_` send id whose trail to read.
- `nextmail.WithLimit` (`int`): Page size per request, from 1 to 100, defaulting to 25 on the server.
- `nextmail.WithCursor` (`string`): An event id to start after, skipping every older event.
- `nextmail.WithAPIKey` (`string`): Reads with this key instead of the client's.

**Returns**

An `*nextmail.Iterator` yielding one event per step.

**Example**

```go
for event, err := range client.Emails.IterateEvents(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20").All() {
	if err != nil {
		return err
	}

	fmt.Println(event.String("type"), event.String("createdAt"))
}
```

**Notes**

- The iterator is lazy, so an abandoned loop costs only the pages you consumed.

Also available in: API [`GET /emails/{id}/events`](https://openemail.uk/docs/api/reference/emails#get-emails-id-events); TypeScript [`nextmail.emails.iterateEvents()`](https://openemail.uk/docs/sdk/reference/emails#iterateEvents); Python [`emails.iterate_events()`](https://openemail.uk/docs/python/reference/emails#iterateEvents); Ruby [`emails.iterate_events`](https://openemail.uk/docs/ruby/reference/emails#iterateEvents); PHP [`emails->iterateEvents`](https://openemail.uk/docs/php/reference/emails#iterateEvents); Java [`emails().iterateEvents`](https://openemail.uk/docs/java/reference/emails#iterateEvents); C# [`Emails.IterateEventsAsync`](https://openemail.uk/docs/csharp/reference/emails#iterateEvents).

### `Emails.GetTracking`

Read the engagement report for a sent email

```go
GetTracking(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Returns the same document `Tracking.Get` serves, reached from the `msg_` id a sender already holds. It has the message totals, one entry per tracked copy under `recipients`, and every rewritten link with its clicks under `links`.

A message that was never tracked is a 404 here rather than an empty report. "We were not recording" and "nobody opened it" are different answers, and a client that renders them the same way makes a claim about a reader on no evidence. Tracking applies per send: `opens` and `clicks` record what was applied when the message went out, resolved from the setting of the address it was sent from (its own, else its domain catch-all's when the catch-all caught that address, else off) and any `tracking` override on the send, not what is switched on now.

Read every count as a floor. An open is inferred from a mail client fetching an image, so a reader whose client blocks images is never counted, and Gmail fetches the image once through its proxy and serves later views from cache. A click is stronger evidence than an open.

Scopes: `emails:read`.

**Parameters**

- `id` (`string`, required): The `msg_` send id returned by `Send`.
- `nextmail.WithAPIKey` (`string`): Reads with this key instead of the client's.

**Returns**

An `nextmail.Object` with `object` set to `tracking`, `id` (the `tmsg_` tracking id), `sendId`, `opens`, `clicks`, `opened`, `clicked`, `attributable`, `openCount`, `clickCount`, `openCountRaw`, `clickCountRaw`, the first and last open and click times, `recipients` and `links`.

**Example**

```go
report, err := client.Emails.GetTracking(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20")
if err != nil {
	return err
}

fmt.Println(report.Bool("attributable"), report.Int("openCount"))
```

**Notes**

- Only claim a named recipient has not opened when `attributable` is true. Mail that went to the whole list as one body has a shared copy whose `email` is null, and its opens cannot be pinned to anybody.
- A message sent with a test key is never tracked, so this is always a 404 for one.
- `openCountRaw - openCount` includes machine fetches such as Apple Mail Privacy Protection and repeats within thirty seconds, so do not read the difference as a pure machine count.

Also available in: API [`GET /emails/{id}/tracking`](https://openemail.uk/docs/api/reference/tracking#get-emails-id-tracking); TypeScript [`nextmail.emails.getTracking()`](https://openemail.uk/docs/sdk/reference/emails#getTracking); Python [`emails.get_tracking()`](https://openemail.uk/docs/python/reference/emails#getTracking); Ruby [`emails.get_tracking`](https://openemail.uk/docs/ruby/reference/emails#getTracking); PHP [`emails->getTracking`](https://openemail.uk/docs/php/reference/emails#getTracking); Java [`emails().getTracking`](https://openemail.uk/docs/java/reference/emails#getTracking); C# [`Emails.GetTrackingAsync`](https://openemail.uk/docs/csharp/reference/emails#getTracking); CLI [`openemail emails get-tracking`](https://openemail.uk/docs/cli/reference/emails#emails-get-tracking).

### `Emails.Cancel`

Stop a queued or scheduled email before it goes

```go
Cancel(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Cancels a message that has not been dispatched yet: a send held by `scheduledAt`, or an immediate send still inside its `cancellableForSeconds` undo window. The message moves to `cancelled`, nothing is delivered, and an `email.cancelled` event is recorded and sent to subscribed webhooks.

Only `queued` and `scheduled` messages can be cancelled. Once a message is `sending`, `sent`, `partial`, `bounced` or `failed` the call is a 409 `email_not_cancellable`, since there is no pending dispatch left to stop and mail that has gone cannot be recalled. An immediate send with no undo window is dispatched inside the `Send` request, so by the time you hold its id it is usually past this point.

Cancelling is idempotent. Cancelling an already cancelled message returns the same cancelled message rather than an error, and the SDK retries the call after a network failure or a retryable status.

Scopes: `emails:send`.

**Parameters**

- `id` (`string`, required): The `msg_` send id to cancel.
- `nextmail.WithAPIKey` (`string`): Cancels with this key instead of the client's.

**Returns**

An `nextmail.Object` in its new state, with `status` set to `cancelled` and `scheduledAt` and `cancellableUntil` still showing when it would have gone.

**Example**

```go
cancelled, err := client.Emails.Cancel(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20")
if err != nil {
	return err
}

fmt.Println(cancelled.String("status"))
```

**Notes**

- `cancellableUntil` on the message is the moment it stops being cancellable. Past it, expect the 409.
- A cancelled message stays cancelled. There is no way to resume it, so send again if you change your mind.
- A narrowed key gets a 404 for a message sent from an address it does not cover.

Also available in: API [`POST /emails/{id}/cancel`](https://openemail.uk/docs/api/reference/emails#post-emails-id-cancel); TypeScript [`nextmail.emails.cancel()`](https://openemail.uk/docs/sdk/reference/emails#cancel); Python [`emails.cancel()`](https://openemail.uk/docs/python/reference/emails#cancel); Ruby [`emails.cancel`](https://openemail.uk/docs/ruby/reference/emails#cancel); PHP [`emails->cancel`](https://openemail.uk/docs/php/reference/emails#cancel); Java [`emails().cancel`](https://openemail.uk/docs/java/reference/emails#cancel); C# [`Emails.CancelAsync`](https://openemail.uk/docs/csharp/reference/emails#cancel); CLI [`openemail emails cancel`](https://openemail.uk/docs/cli/reference/emails#emails-cancel).

### `Emails.Reschedule`

Move a queued or scheduled email to a new send time

```go
Reschedule(ctx context.Context, id string, scheduledAt time.Time, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Changes when a message that has not gone yet will be dispatched. `scheduledAt` is the only thing this call can change, and the SDK sends nothing else: the body, recipients and any translation stay exactly as they were accepted.

The new time takes a `time.Time`, an ISO 8601 instant or a duration such as `PT30M` or `P2D`, measured from when the server receives the request. It must be at least one second in the future and at most 365 days out, otherwise the call is a 422 on `scheduledAt`, usually `invalid_parameter`. Earlier and later times are both allowed.

Only `queued` and `scheduled` messages can be moved. Anything already `sending`, `sent`, `partial`, `bounced`, `cancelled` or `failed` is a 409 `email_not_cancellable`. A queued message inside its undo window can be rescheduled too, which turns it into a `scheduled` send that stays cancellable until the new time.

Scopes: `emails:send`.

**Parameters**

- `id` (`string`, required): The `msg_` send id to move.
- `scheduledAt` (`time.Time`, required): The new send time. It is sent as an ISO 8601 instant.
- `nextmail.WithAPIKey` (`string`): Reschedules with this key instead of the client's.

**Returns**

An `nextmail.Object` with `status` set to `scheduled` and `scheduledAt` and `cancellableUntil` both set to the new time.

**Example**

```go
moved, err := client.Emails.Reschedule(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20", time.Now().Add(24*time.Hour))
if err != nil {
	return err
}

fmt.Println(moved.String("status"), moved.String("scheduledAt"))
```

**Notes**

- The SDK retries this call after a network failure. A duration is resolved again on each attempt, so a retried `PT1H` lands an hour after the last attempt the server received.
- An `email.rescheduled` event with the new `scheduledAt` is added to the trail on every successful move.
- A translated scheduled message keeps its approved wording. To change the text itself, cancel it and send again.

Also available in: API [`PATCH /emails/{id}`](https://openemail.uk/docs/api/reference/emails#patch-emails-id); TypeScript [`nextmail.emails.reschedule()`](https://openemail.uk/docs/sdk/reference/emails#reschedule); Python [`emails.reschedule()`](https://openemail.uk/docs/python/reference/emails#reschedule); Ruby [`emails.reschedule`](https://openemail.uk/docs/ruby/reference/emails#reschedule); PHP [`emails->reschedule`](https://openemail.uk/docs/php/reference/emails#reschedule); Java [`emails().reschedule`](https://openemail.uk/docs/java/reference/emails#reschedule); C# [`Emails.RescheduleAsync`](https://openemail.uk/docs/csharp/reference/emails#reschedule); CLI [`openemail emails reschedule`](https://openemail.uk/docs/cli/reference/emails#emails-reschedule).

### `Emails.Update`

Change an email that has not gone yet

```go
Update(ctx context.Context, id string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Changes a `queued` or `scheduled` message before it is dispatched: when it goes with `scheduledAt`, what it says with `subject`, `html` and `text`, the address it goes out as with `from`, and who it goes to with `to`, `cc` and `bcc`. Send any of them together, and a field you leave out keeps its value. This is what editing a scheduled message in the calendar of the app does.

A recipient list replaces the stored one whole, and takes a string such as `Ada <ada@example.com>`, an object with `email` and `name`, or an array of either. `from` is checked as it is on a send, so it has to be an address the key may send as, or the call is a 403 `from_address_forbidden`.

Only messages that have not gone can change. Anything already `sending`, `sent`, `partial`, `bounced`, `cancelled` or `failed` is a 409 `email_not_cancellable`. A message translated when it was accepted keeps its approved wording, so a new `subject`, `html` or `text` on it is a 409 `translation_locked`, and one that was encrypted before it was scheduled keeps its wording and its recipients. Cancel those and send again instead.

Scopes: `emails:send`.

**Parameters**

- `id` (`string`, required): The `msg_` send id to change.
- `scheduledAt` (`time.Time | string`): A new send time: a `time.Time`, an ISO 8601 instant or a duration such as `PT2H`, in the future and at most 365 days out.
- `subject` (`string`): The new subject, up to 998 characters.
- `html` (`string`): The new HTML body.
- `text` (`string`): The new plain text body.
- `from` (`string`): The address it goes out as instead, one the key may send as.
- `to` (`any`): Replaces the recipients, at least one and at most 50 across the three lists.
- `cc` (`any`): Replaces the copied recipients.
- `bcc` (`any`): Replaces the blind copied recipients.
- `nextmail.WithAPIKey` (`string`): Changes it with this key instead of the client's.

**Returns**

An `nextmail.Object`, the message as it is now. Its `subject`, `from` and `scheduledAt` show the change.

**Example**

```go
updated, err := client.Emails.Update(ctx, "msg_3f9a1c07d2b84e6a9c5b1f20", nextmail.Body{
	"subject":     "Your September invoice, corrected",
	"to":          []string{"ada@example.com", "grace@example.com"},
	"scheduledAt": time.Date(2026, time.October, 5, 8, 0, 0, 0, time.UTC),
})
if err != nil {
	return err
}

fmt.Println(updated.String("status"), updated.String("subject"), updated.String("scheduledAt"))
```

**Notes**

- The SDK retries this call after a network failure, which is safe because a repeat writes the same values.
- An `email.updated` event naming the changed fields is added to the trail, and a move adds `email.rescheduled` as well.
- `Reschedule` is the same call with only `scheduledAt`.

Also available in: API [`PATCH /emails/{id}`](https://openemail.uk/docs/api/reference/emails#patch-emails-id); TypeScript [`nextmail.emails.update()`](https://openemail.uk/docs/sdk/reference/emails#update); Python [`emails.update()`](https://openemail.uk/docs/python/reference/emails#update); Ruby [`emails.update`](https://openemail.uk/docs/ruby/reference/emails#update); PHP [`emails->update`](https://openemail.uk/docs/php/reference/emails#update); Java [`emails().update`](https://openemail.uk/docs/java/reference/emails#update); C# [`Emails.UpdateAsync`](https://openemail.uk/docs/csharp/reference/emails#update); CLI [`openemail emails update`](https://openemail.uk/docs/cli/reference/emails#emails-update).

### `Emails.Compose`

Write an email with AI

```go
Compose(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Writes the body of an email from `prompt`, an instruction, a rough draft or a few notes, in the style of the mail this workspace has sent before, as the composer of the app does. `subject`, `to` and `cc` help the greeting and the tone fit, and `from`, the address it goes out as, has it written as that address.

Give `threadId` to write a reply: the messages of that thread are read as context, which also needs `threads:read`, and a key limited to particular addresses can only use a thread that arrived at them.

Give `draft`, the body written so far, and `prompt` says what to change in it, as the describe bar of the composer does. `withSubject: true` adds `subject` to the answer. Give `Send`, the send options as they stand, even an empty map, and `prompt` may change the recipients, the send time, tracking, the signature and the language: the answer's `Send` holds only what changed, in the shape `Emails.Send` takes, and `null` takes an option away. Add `send.fromOptions`, the addresses it may go out as, and `prompt` may move it to one of them, which the answer names in `send.from`. Add `send.encrypt`, whether it is encrypted end to end as it stands, only when every recipient can receive encrypted mail, and `prompt` may turn encryption on or off. Times such as "tomorrow at 9" are read in `timeZone`, or the time zone of the account.

Give `templates: true` and `prompt` may switch the email to one of the workspace's published templates, which the answer names in `template`: pass `template: { id: template.id }` to `Emails.Send` in place of `body`, because the template's body replaces it. Give `template`, the id of the template the email uses now, and `prompt` leaves the body alone. Give `files: true` and `prompt` may attach files the workspace holds, found by their name: the answer lists them in `attach`, each ready to pass to `Emails.Send` as a map with `fileId` set to `id` in `attachments`, and names in `attachMissing` what matched no file. `templates` needs `templates:read` and `files` needs `files:read`, and each is ignored without its scope. A key limited to particular addresses only finds the files at those addresses.

Nothing is saved or sent. Pass `body` to `Emails.Send` or `Drafts.Create` when it reads right. Each call spends one of the workspace's AI actions, and a workspace that has used them all for the day is refused with a 429 `ai_quota_exceeded`.

Scopes: `emails:send`.

**Parameters**

- `prompt` (`string`, required): What to write, up to 20,000 characters. With `draft`, what to change in it, and it may be empty to have the draft finished as it is.
- `subject` (`string`): The subject so far, if there is one.
- `from` (`string`): The address it goes out as, so it is written as that address.
- `template` (`string`): The id of the template the email uses now, up to 128 characters. Its body is then the template, so `prompt` leaves the body alone.
- `templates` (`bool`): Let `prompt` switch the email to one of the workspace's published templates, which the answer names in `template`. Needs `templates:read`, and without it this is ignored.
- `files` (`bool`): Let `prompt` attach files the workspace holds, found by their name. The answer lists them in `attach`, each ready to send as a map with `fileId` set to `id`, and what matched no file in `attachMissing`. Needs `files:read`, and without it this is ignored.
- `withSubject` (`bool`): Also write a subject. The answer then carries `subject`.
- `draft` (`string`): The body written so far, as text or Markdown, up to 20,000 characters. `prompt` then says what to change in it.
- `to` (`[]string`): Who it goes to.
- `cc` (`[]string`): Who is copied.
- `bcc` (`[]string`): Who is blind copied.
- `send` (`nextmail.Body`): a map with optionally `scheduledAt`, `tracking`, `signature`, `translate`, `fromOptions` and `encrypt`, the send options as they stand. Give it, even an empty map, to let `prompt` change them. `fromOptions` lists up to 100 addresses it may go out as, so `prompt` can move it to one of them, and `encrypt` says whether it is encrypted end to end: give it only when every recipient can receive encrypted mail, so `prompt` can turn encryption on or off.
- `timeZone` (`string`): The IANA time zone to read times in, such as `Europe/Berlin`. Without it, the time zone of the account.
- `threadId` (`string`): A thread to reply in, read as context.
- `nextmail.WithAPIKey` (`string`): Overrides the client's API key for this call only.

**Returns**

An `nextmail.Object` with `object` set to `composition` and `body` and optionally `subject`, `send`, `template`, `attach`, `attachMissing`, `note` and `sources`. Its `Send` can name `from`, the address to send it from instead, one of `send.fromOptions`, and `encrypt`, whether to encrypt it end to end, when you gave `send.encrypt`. `template`, a map with `id` and `name`, is the template to send it with instead, when you gave `templates: true` and `prompt` asked for one, and its body replaces `body`. `attach` lists the files to attach, each a map with `id`, `filename`, `contentType` and `size` with `size` in bytes, when you gave `files: true` and `prompt` asked for them, and `attachMissing` what `prompt` asked to attach that matched no file, as `prompt` named it. `note` is a short sentence when part of `prompt` cannot be done this way, such as adding somebody whose address it was not given. `sources` lists the knowledge base items the draft drew on, when it used any, each a map with `id`, `title`, `kind`, `scope` and `url`.

**Example**

```go
composition, err := client.Emails.Compose(ctx, nextmail.Body{
	"prompt":      "Send Ada the signed contract and ask for the invoice by Friday.",
	"from":        "billing@acme.com",
	"to":          []string{"ada@example.com"},
	"withSubject": true,
	"files":       true,
})
if err != nil {
	return err
}

fmt.Println(composition.String("body"), composition.String("subject"))
```

**Notes**

- The SDK does not retry it, because a second call writes something different and spends a second AI action.
- A server with no AI configured answers 409 `ai_not_configured`.

Also available in: API [`POST /emails/compose`](https://openemail.uk/docs/api/reference/emails#post-emails-compose); TypeScript [`nextmail.emails.compose()`](https://openemail.uk/docs/sdk/reference/emails#compose); Python [`emails.compose()`](https://openemail.uk/docs/python/reference/emails#compose); Ruby [`emails.compose`](https://openemail.uk/docs/ruby/reference/emails#compose); PHP [`emails->compose`](https://openemail.uk/docs/php/reference/emails#compose); Java [`emails().compose`](https://openemail.uk/docs/java/reference/emails#compose); C# [`Emails.ComposeAsync`](https://openemail.uk/docs/csharp/reference/emails#compose); CLI [`openemail emails compose`](https://openemail.uk/docs/cli/reference/emails#emails-compose).

### `Emails.Rewrite`

Rewrite part of an email with AI

```go
Rewrite(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Rewrites a subject or a body and returns different versions of it, as the rewrite menu of the composer does. `action` is `shorten`, `lengthen`, `rephrase`, `formal`, `casual` or `custom`, and `custom` needs `instruction` to say what to change, or the call is a 422 `invalid_parameter` on `instruction`. `target` is `body`, the default, or `subject`, and `count` asks for 1 to 5 versions, 3 by default.

Give `threadId` when the text is a reply, so the rewrite fits the conversation. That also needs `threads:read`. The versions never repeat the original and never add facts that are not in it.

Nothing is saved. Each call spends one of the workspace's AI actions.

Scopes: `emails:send`.

**Parameters**

- `text` (`string`, required): The subject or body to rewrite.
- `action` (`string`, required): What to do: `shorten`, `lengthen`, `rephrase`, `formal`, `casual` or `custom`.
- `target` (`string`): `body` or `subject`. Defaults to `body`.
- `instruction` (`string`): What to change, up to 500 characters. Required with `custom`.
- `count` (`int`): How many versions, 1 to 5. Defaults to 3.
- `threadId` (`string`): The thread the text replies in, read as context.
- `nextmail.WithAPIKey` (`string`): Overrides the client's API key for this call only.

**Returns**

An `nextmail.Object` with `object` set to `rewrite`, `target` and `variations`.

**Example**

```go
rewrite, err := client.Emails.Rewrite(ctx, nextmail.Body{
	"text":   "Hey, just checking whether you had a chance to look at the contract?",
	"action": "formal",
})
if err != nil {
	return err
}

fmt.Println(rewrite.String("object"))
```

**Notes**

- The SDK does not retry it, because a second call spends a second AI action.
- Fewer versions than `count` can come back when two of them turned out the same.

Also available in: API [`POST /emails/rewrite`](https://openemail.uk/docs/api/reference/emails#post-emails-rewrite); TypeScript [`nextmail.emails.rewrite()`](https://openemail.uk/docs/sdk/reference/emails#rewrite); Python [`emails.rewrite()`](https://openemail.uk/docs/python/reference/emails#rewrite); Ruby [`emails.rewrite`](https://openemail.uk/docs/ruby/reference/emails#rewrite); PHP [`emails->rewrite`](https://openemail.uk/docs/php/reference/emails#rewrite); Java [`emails().rewrite`](https://openemail.uk/docs/java/reference/emails#rewrite); C# [`Emails.RewriteAsync`](https://openemail.uk/docs/csharp/reference/emails#rewrite); CLI [`openemail emails rewrite`](https://openemail.uk/docs/cli/reference/emails#emails-rewrite).

### `Emails.SuggestSubject`

Suggest a subject line

```go
SuggestSubject(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)
```

Reads the body of an email and returns a short subject for it, under 100 characters, in the style of the mail this workspace has sent, as the subject button of the composer does.

Nothing is saved. Each call spends one of the workspace's AI actions.

Scopes: `emails:send`.

**Parameters**

- `message` (`string`, required): The body of the email, as text or HTML.
- `nextmail.WithAPIKey` (`string`): Overrides the client's API key for this call only.

**Returns**

An `nextmail.Object` with `object` set to `subject_suggestion` and `subject`.

**Example**

```go
suggestion, err := client.Emails.SuggestSubject(ctx, nextmail.Body{
	"message": "Thanks for the signed contract. Could you send the invoice by Friday?",
})
if err != nil {
	return err
}

fmt.Println(suggestion.String("subject"))
```

**Notes**

- The SDK does not retry it, because a second call spends a second AI action.

Also available in: API [`POST /emails/subject`](https://openemail.uk/docs/api/reference/emails#post-emails-subject); TypeScript [`nextmail.emails.suggestSubject()`](https://openemail.uk/docs/sdk/reference/emails#suggestSubject); Python [`emails.suggest_subject()`](https://openemail.uk/docs/python/reference/emails#suggestSubject); Ruby [`emails.suggest_subject`](https://openemail.uk/docs/ruby/reference/emails#suggestSubject); PHP [`emails->suggestSubject`](https://openemail.uk/docs/php/reference/emails#suggestSubject); Java [`emails().suggestSubject`](https://openemail.uk/docs/java/reference/emails#suggestSubject); C# [`Emails.SuggestSubjectAsync`](https://openemail.uk/docs/csharp/reference/emails#suggestSubject); CLI [`openemail emails suggest-subject`](https://openemail.uk/docs/cli/reference/emails#emails-suggest-subject).
