# Resend API

Every handle of the Resend fake: the `resend` fixture, the people and objects a test creates on it, and what they read and wait for. How to test a Resend app or agent, step by step, is in the [Resend guide](https://channelstack.dev/docs/platforms/resend).

Each call is shown in every SDK's language, with its required options (the table under it lists them all). Arguments go first; options are TypeScript's trailing object, Python's keyword arguments and Rust's builder setters. The variable names are the ones the calls return elsewhere on these pages, so `user` is a `ResendUser` handle.

Besides the errors listed with each method, most methods can fail with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires), [`cross_workspace_credential`](https://channelstack.dev/docs/reference/api/errors#cross-workspace-credential), [`fake_actor_in_live_world`](https://channelstack.dev/docs/reference/api/errors#fake-actor-in-live-world), [`internal`](https://channelstack.dev/docs/reference/api/errors#internal), [`invalid_argument`](https://channelstack.dev/docs/reference/api/errors#invalid-argument), [`live_misconfigured`](https://channelstack.dev/docs/reference/api/errors#live-misconfigured), [`live_not_allowlisted`](https://channelstack.dev/docs/reference/api/errors#live-not-allowlisted), [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), [`session_not_found`](https://channelstack.dev/docs/reference/api/errors#session-not-found), [`unauthorized`](https://channelstack.dev/docs/reference/api/errors#unauthorized), [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): a bad request, a closed session, or live mode refusing or misconfigured.

## ResendFixture

Returned by [`Session.resend()`](https://channelstack.dev/docs/reference/api/client#resend).

| Field    | Python / Rust | Type        |
| -------- | ------------- | ----------- |
| `app`    | `app`         | `ResendApp` |
| `apiUrl` | `api_url`     | `string`    |

### createApp()

Make another app: a team of its own, with its own address and credentials (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_RESEND_APP\_\<NAME>\_WEBHOOK_URL.

```ts title="TypeScript"
const app = await resend.createApp({ name: "…" });
```

```python title="Python"
app = await resend.create_app(name="…")
```

```rust title="Rust"
let app = resend.create_app().name("…").await?;
```

| Parameter | Type     | Required |        |
| --------- | -------- | -------- | ------ |
| `name`    | `string` | yes      | option |
| `domain`  | `string` | no       | option |

**Returns** [`ResendApp`](https://channelstack.dev/docs/reference/api/resend#resendapp).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).

### apps()

The teams this session used: the agent's first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here.

```ts title="TypeScript"
const apps = await resend.apps();
```

```python title="Python"
apps = await resend.apps()
```

```rust title="Rust"
let apps = resend.apps().await?;
```

**Returns** [`ResendApps`](https://channelstack.dev/docs/reference/api/resend#resendapps).

### createUser()

Create a person: a mailbox, at `<name>@example.com` unless a test gives the address.

```ts title="TypeScript"
const user = await resend.createUser({ name: "…" });
```

```python title="Python"
user = await resend.create_user(name="…")
```

```rust title="Rust"
let user = resend.create_user().name("…").await?;
```

| Parameter | Type     | Required |                                                                         |
| --------- | -------- | -------- | ----------------------------------------------------------------------- |
| `name`    | `string` | yes      | option                                                                  |
| `address` | `string` | no       | option                                                                  |
| `token`   | `string` | no       | option; read from `CHANNELSTACK_RESEND_USER_{name}_TOKEN` when left out |

**Returns** [`ResendUser`](https://channelstack.dev/docs/reference/api/resend#resenduser).

### users()

The people this session created.

```ts title="TypeScript"
const users = await resend.users();
```

```python title="Python"
users = await resend.users()
```

```rust title="Rust"
let users = resend.users().await?;
```

**Returns** [`ResendUsers`](https://channelstack.dev/docs/reference/api/resend#resendusers).

### threads()

The threads this session's people started, oldest first.

```ts title="TypeScript"
const threads = await resend.threads();
```

```python title="Python"
threads = await resend.threads()
```

```rust title="Rust"
let threads = resend.threads().await?;
```

**Returns** [`ResendThreads`](https://channelstack.dev/docs/reference/api/resend#resendthreads).

### deliveries()

Every webhook channelstack sent the agent for this session, with every attempt.

```ts title="TypeScript"
const deliveries = await resend.deliveries({ type: "…" });
```

```python title="Python"
deliveries = await resend.deliveries(type="…")
```

```rust title="Rust"
let deliveries = resend.deliveries().r#type("…").await?;
```

| Parameter  | Python / Rust     | Type           | Required |        |
| ---------- | ----------------- | -------------- | -------- | ------ |
| `type`     | `type` · `r#type` | `string`       | no       | option |
| `resource` | `resource`        | `ResendThread` | no       | option |
| `app`      | `app`             | `ResendApp`    | no       | option |

**Returns** [`ResendDeliveries`](https://channelstack.dev/docs/reference/api/resend#resenddeliveries).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### calls()

The REST calls the agent made about this session's emails, by the SDK's method name (`emails.send`).

```ts title="TypeScript"
const apiCalls = await resend.calls({ operation: "…" });
```

```python title="Python"
api_calls = await resend.calls(operation="…")
```

```rust title="Rust"
let api_calls = resend.calls().operation("…").await?;
```

| Parameter   | Type             | Required |        |
| ----------- | ---------------- | -------- | ------ |
| `operation` | `string`         | no       | option |
| `error`     | `true \| string` | no       | option |

**Returns** [`ResendApiCalls`](https://channelstack.dev/docs/reference/api/resend#resendapicalls).

**Live:** needs proxy mode: Resend doesn't report the team's calls; proxy mode sees them. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### waitForCall()

Waits for the next API call from the agent after the last one this handle returned: it polls `calls()` and never sleeps longer than it must.

```ts title="TypeScript"
const apiCall = await resend.waitForCall({ operation: "…" });
```

```python title="Python"
api_call = await resend.wait_for_call(operation="…")
```

```rust title="Rust"
let api_call = resend.wait_for_call().operation("…").await?;
```

| Parameter   | Type             | Required |             |
| ----------- | ---------------- | -------- | ----------- |
| `operation` | `string`         | no       | filter      |
| `error`     | `true \| string` | no       | filter      |
| `timeout`   | `Duration`       | no       | default 10s |

**Returns** [`ResendApiCall`](https://channelstack.dev/docs/reference/api/resend#resendapicall). When the time is up, it fails with what it was waiting for.

## ResendApp

Returned by [`ResendFixture.createApp()`](https://channelstack.dev/docs/reference/api/resend#createapp).

| Field           | Python / Rust    | Type       |
| --------------- | ---------------- | ---------- |
| `id`            | `id`             | `string`   |
| `channel`       | `channel`        | `"resend"` |
| `kind`          | `kind`           | `"app"`    |
| `name`          | `name`           | `string`   |
| `botUserId`     | `bot_user_id`    | `string`   |
| `address`       | `address`        | `string`   |
| `domain`        | `domain`         | `string`   |
| `apiKey`        | `api_key`        | `string`   |
| `webhookSecret` | `webhook_secret` | `string`   |

### send()

An app a test made sends an email, through its own team's API, as its own call would.

```ts title="TypeScript"
const email = await app.send({ to, subject: "…" });
```

```python title="Python"
email = await app.send(to=to, subject="…")
```

```rust title="Rust"
let email = app.send().to(to).subject("…").await?;
```

| Parameter | Type                             | Required |        |
| --------- | -------------------------------- | -------- | ------ |
| `to`      | `Array<ResendUser \| ResendApp>` | yes      | option |
| `cc`      | `Array<ResendUser \| ResendApp>` | no       | option |
| `subject` | `string`                         | yes      | option |
| `text`    | `string`                         | no       | option |
| `html`    | `string`                         | no       | option |
| `headers` | `Record<string, string>`         | no       | option |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).

### reply()

An app a test made replies to an email, in its thread, as its own call would.

```ts title="TypeScript"
const result = await app.reply(email, { text: "…" });
```

```python title="Python"
result = await app.reply(email, text="…")
```

```rust title="Rust"
let result = app.reply(&email).text("…").await?;
```

| Parameter | Type                     | Required |            |
| --------- | ------------------------ | -------- | ---------- |
| `email`   | `ResendEmail`            | yes      | positional |
| `text`    | `string`                 | no       | option     |
| `html`    | `string`                 | no       | option     |
| `all`     | `boolean`                | no       | option     |
| `headers` | `Record<string, string>` | no       | option     |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).

## ResendEmail

Returned by [`ResendApp.send()`](https://channelstack.dev/docs/reference/api/resend#send), [`ResendApp.reply()`](https://channelstack.dev/docs/reference/api/resend#reply), [`ResendEmail.refresh()`](https://channelstack.dev/docs/reference/api/resend#refresh), [`ResendUser.send()`](https://channelstack.dev/docs/reference/api/resend#send-1).

| Field       | Python / Rust    | Type                          |
| ----------- | ---------------- | ----------------------------- |
| `id`        | `id`             | `string`                      |
| `channel`   | `channel`        | `"resend"`                    |
| `thread`    | `thread`         | `ResendThread`                |
| `author`    | `author`         | `ResendPrincipal`             |
| `from`      | `from_` · `from` | `string`                      |
| `to`        | `to`             | `string[]`                    |
| `cc`        | `cc`             | `string[]`                    |
| `subject`   | `subject`        | `string`                      |
| `text`      | `text`           | `string`                      |
| `at`        | `at`             | `string`                      |
| `messageId` | `message_id`     | `string`                      |
| `headers`   | `headers`        | `Record<string, string>`      |
| `delivery`  | `delivery`       | `ResendDelivery \| undefined` |

### refresh()

Re-read an email.

```ts title="TypeScript"
const updated = await email.refresh();
```

```python title="Python"
updated = await email.refresh()
```

```rust title="Rust"
let updated = email.refresh().await?;
```

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail).

### deliveryFor()

The delivery that told this app of the email (decision 0027), or nothing when it wasn't told.

```ts title="TypeScript"
const delivery = await email.deliveryFor(app);
```

```python title="Python"
delivery = await email.delivery_for(app)
```

```rust title="Rust"
let delivery = email.delivery_for(&app).await?;
```

| Parameter | Type        | Required |            |
| --------- | ----------- | -------- | ---------- |
| `app`     | `ResendApp` | yes      | positional |

**Returns** [`ResendDelivery | undefined`](https://channelstack.dev/docs/reference/api/resend#resenddelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

## ResendThread

| Field     | Type       |
| --------- | ---------- |
| `id`      | `string`   |
| `channel` | `"resend"` |
| `subject` | `string`   |

### messages()

Every email in the thread, oldest first.

```ts title="TypeScript"
const messages = await thread.messages();
```

```python title="Python"
messages = await thread.messages()
```

```rust title="Rust"
let messages = thread.messages().await?;
```

**Returns** [`ResendMessages`](https://channelstack.dev/docs/reference/api/resend#resendmessages).

### replies()

The thread's answers: every email after the first, oldest first.

```ts title="TypeScript"
const replies = await thread.replies();
```

```python title="Python"
replies = await thread.replies()
```

```rust title="Rust"
let replies = thread.replies().await?;
```

**Returns** [`ResendReplies`](https://channelstack.dev/docs/reference/api/resend#resendreplies).

### transcript()

The thread as a person reads it: each email's own words, without the quoted history.

```ts title="TypeScript"
const transcript = await thread.transcript();
```

```python title="Python"
transcript = await thread.transcript()
```

```rust title="Rust"
let transcript = thread.transcript().await?;
```

**Returns** [`ResendTranscript`](https://channelstack.dev/docs/reference/api/resend#resendtranscript).

### waitForReply()

Waits for the next reply after the last one this handle returned: it polls `replies()` and never sleeps longer than it must.

```ts title="TypeScript"
const email = await thread.waitForReply({ from: "my-agent" });
```

```python title="Python"
email = await thread.wait_for_reply(from_="my-agent")
```

```rust title="Rust"
let email = thread.wait_for_reply().from("my-agent").await?;
```

| Parameter | Python / Rust    | Type                        | Required |                     |
| --------- | ---------------- | --------------------------- | -------- | ------------------- |
| `from`    | `from_` · `from` | `ResendPrincipal \| string` | no       | a handle, or a name |
| `timeout` | `timeout`        | `Duration`                  | no       | default 10s         |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail). When the time is up, it fails with what it was waiting for.

### latestReply()

The latest reply, once the app is quiet. Waits for at least one: it polls `replies()` and never sleeps longer than it must.

```ts title="TypeScript"
const email = await thread.latestReply({ from: "my-agent" });
```

```python title="Python"
email = await thread.latest_reply(from_="my-agent")
```

```rust title="Rust"
let email = thread.latest_reply().from("my-agent").await?;
```

| Parameter  | Python / Rust    | Type                        | Required |                     |
| ---------- | ---------------- | --------------------------- | -------- | ------------------- |
| `from`     | `from_` · `from` | `ResendPrincipal \| string` | no       | a handle, or a name |
| `timeout`  | `timeout`        | `Duration`                  | no       | default 10s         |
| `quietFor` | `quiet_for`      | `Duration`                  | no       | default 750ms       |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail). When the time is up, it fails with what it was waiting for.

## ResendDelivery

Returned by [`ResendEmail.deliveryFor()`](https://channelstack.dev/docs/reference/api/resend#deliveryfor), [`ResendDelivery.refresh()`](https://channelstack.dev/docs/reference/api/resend#refresh-1).

| Field      | Python / Rust     | Type                                                                      |
| ---------- | ----------------- | ------------------------------------------------------------------------- |
| `id`       | `id`              | `string`                                                                  |
| `channel`  | `channel`         | `"resend"`                                                                |
| `app`      | `app`             | `string`                                                                  |
| `type`     | `type` · `r#type` | `string`                                                                  |
| `email`    | `email`           | `string`                                                                  |
| `payload`  | `payload`         | `unknown \| undefined`                                                    |
| `attempts` | `attempts`        | `DeliveryAttempt[]`                                                       |
| `status`   | `status`          | `"pending" \| "acknowledged" \| "failed" \| "timed_out" \| "unreachable"` |

### refresh()

Re-read a delivery: its attempts and status.

```ts title="TypeScript"
const updated = await delivery.refresh();
```

```python title="Python"
updated = await delivery.refresh()
```

```rust title="Rust"
let updated = delivery.refresh().await?;
```

**Returns** [`ResendDelivery`](https://channelstack.dev/docs/reference/api/resend#resenddelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### redeliver()

Send the same webhook again, as Resend retries: the same `svix-id`, signed again.

```ts title="TypeScript"
const deliveryAttempt = await delivery.redeliver();
```

```python title="Python"
delivery_attempt = await delivery.redeliver()
```

```rust title="Rust"
let delivery_attempt = delivery.redeliver().await?;
```

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Resend has no API to redeliver a webhook.

### resend()

Send the webhook again, forged: signed with a secret that isn't the webhook's, or with a timestamp past the five minutes receivers accept.

```ts title="TypeScript"
const deliveryAttempt = await delivery.resend({ badSignature });
```

```python title="Python"
delivery_attempt = await delivery.resend(bad_signature=bad_signature)
```

```rust title="Rust"
let delivery_attempt = delivery.resend().bad_signature(bad_signature).await?;
```

| Parameter      | Python / Rust   | Type      | Required |        |
| -------------- | --------------- | --------- | -------- | ------ |
| `badSignature` | `bad_signature` | `boolean` | no       | option |
| `stale`        | `stale`         | `boolean` | no       | option |

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### settled()

Waits for the delivery to settle: it polls `refresh()` and never sleeps longer than it must.

```ts title="TypeScript"
const updated = await delivery.settled();
```

```python title="Python"
updated = await delivery.settled()
```

```rust title="Rust"
let updated = delivery.settled().await?;
```

| Parameter | Type       | Required |             |
| --------- | ---------- | -------- | ----------- |
| `timeout` | `Duration` | no       | default 10s |

**Returns** [`ResendDelivery`](https://channelstack.dev/docs/reference/api/resend#resenddelivery). When the time is up, it fails with what it was waiting for.

## ResendUser

Returned by [`ResendFixture.createUser()`](https://channelstack.dev/docs/reference/api/resend#createuser).

| Field     | Type       |
| --------- | ---------- |
| `id`      | `string`   |
| `channel` | `"resend"` |
| `kind`    | `"user"`   |
| `name`    | `string`   |
| `address` | `string`   |

### send()

The person emails someone: the agent (`resend.app`), another app, or another person.

```ts title="TypeScript"
const email = await user.send({ to, subject: "…" });
```

```python title="Python"
email = await user.send(to=to, subject="…")
```

```rust title="Rust"
let email = user.send().to(to).subject("…").await?;
```

| Parameter | Type                             | Required |        |
| --------- | -------------------------------- | -------- | ------ |
| `to`      | `Array<ResendUser \| ResendApp>` | yes      | option |
| `cc`      | `Array<ResendUser \| ResendApp>` | no       | option |
| `subject` | `string`                         | yes      | option |
| `text`    | `string`                         | no       | option |
| `html`    | `string`                         | no       | option |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail).

### reply()

The person replies to an email, in its thread: `Re:` its subject, with `In-Reply-To` and `References`.

```ts title="TypeScript"
const result = await user.reply(email, { text: "…" });
```

```python title="Python"
result = await user.reply(email, text="…")
```

```rust title="Rust"
let result = user.reply(&email).text("…").await?;
```

| Parameter | Type          | Required |            |
| --------- | ------------- | -------- | ---------- |
| `email`   | `ResendEmail` | yes      | positional |
| `text`    | `string`      | no       | option     |
| `html`    | `string`      | no       | option     |
| `all`     | `boolean`     | no       | option     |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail).

### inbox()

What reached the person's mailbox, oldest first.

```ts title="TypeScript"
const inbox = await user.inbox();
```

```python title="Python"
inbox = await user.inbox()
```

```rust title="Rust"
let inbox = user.inbox().await?;
```

**Returns** [`ResendInbox`](https://channelstack.dev/docs/reference/api/resend#resendinbox).

### waitForEmail()

Waits for the next email after the last one this handle returned: it polls `inbox()` and never sleeps longer than it must.

```ts title="TypeScript"
const email = await user.waitForEmail({ from: "my-agent" });
```

```python title="Python"
email = await user.wait_for_email(from_="my-agent")
```

```rust title="Rust"
let email = user.wait_for_email().from("my-agent").await?;
```

| Parameter | Python / Rust    | Type                        | Required |                     |
| --------- | ---------------- | --------------------------- | -------- | ------------------- |
| `from`    | `from_` · `from` | `ResendPrincipal \| string` | no       | a handle, or a name |
| `timeout` | `timeout`        | `Duration`                  | no       | default 10s         |

**Returns** [`ResendEmail`](https://channelstack.dev/docs/reference/api/resend#resendemail). When the time is up, it fails with what it was waiting for.

## Types

Plain values the handles return and take.

### ResendApps

```ts
type ResendApps = ResendApp[];
```

### ResendPrincipal

| Field  | Type              |
| ------ | ----------------- |
| `id`   | `string`          |
| `name` | `string`          |
| `kind` | `"user" \| "app"` |

### ResendUsers

```ts
type ResendUsers = ResendUser[];
```

### ResendThreads

```ts
type ResendThreads = ResendThread[];
```

### ResendInbox

```ts
type ResendInbox = ResendEmail[];
```

### ResendMessages

```ts
type ResendMessages = ResendEmail[];
```

### ResendReplies

```ts
type ResendReplies = ResendEmail[];
```

### ResendTranscript

| Field     | Type                      |
| --------- | ------------------------- |
| `entries` | `ResendTranscriptEntry[]` |
| `text`    | `string`                  |

### ResendTranscriptEntry

| Field      | Type              |
| ---------- | ----------------- |
| `id`       | `string`          |
| `author`   | `ResendPrincipal` |
| `at`       | `string`          |
| `text`     | `string`          |
| `controls` | `string[]`        |
| `edited`   | `boolean`         |
| `depth`    | `number`          |

### ResendDeliveries

```ts
type ResendDeliveries = ResendDelivery[];
```

### ResendApiCalls

```ts
type ResendApiCalls = ResendApiCall[];
```

### ResendApiCall

| Field            | Python / Rust     | Type                   |
| ---------------- | ----------------- | ---------------------- |
| `id`             | `id`              | `string`               |
| `channel`        | `channel`         | `"resend"`             |
| `operation`      | `operation`       | `string`               |
| `method`         | `method`          | `string`               |
| `path`           | `path`            | `string`               |
| `at`             | `at`              | `string`               |
| `durationMs`     | `duration_ms`     | `number`               |
| `request`        | `request`         | `unknown \| undefined` |
| `responseStatus` | `response_status` | `number`               |
| `response`       | `response`        | `unknown \| undefined` |
| `error`          | `error`           | `string \| undefined`  |
