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.
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, cross_workspace_credential, fake_actor_in_live_world, internal, invalid_argument, live_misconfigured, live_not_allowlisted, not_found, session_not_found, unauthorized, unsupported_in_live: a bad request, a closed session, or live mode refusing or misconfigured.
ResendFixture#
Returned by Session.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.
const app = await resend.createApp({ name: "…" });app = await resend.create_app(name="…")let app = resend.create_app().name("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
name | string | yes | option |
domain | string | no | option |
Returns ResendApp.
Live: refused with 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.
const apps = await resend.apps();apps = await resend.apps()let apps = resend.apps().await?;Returns ResendApps.
createUser()#
Create a person: a mailbox, at <name>@example.com unless a test gives the address.
const user = await resend.createUser({ name: "…" });user = await resend.create_user(name="…")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.
users()#
The people this session created.
const users = await resend.users();users = await resend.users()let users = resend.users().await?;Returns ResendUsers.
threads()#
The threads this session's people started, oldest first.
const threads = await resend.threads();threads = await resend.threads()let threads = resend.threads().await?;Returns ResendThreads.
deliveries()#
Every webhook channelstack sent the agent for this session, with every attempt.
const deliveries = await resend.deliveries({ type: "…" });deliveries = await resend.deliveries(type="…")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.
Live: refused with 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).
const apiCalls = await resend.calls({ operation: "…" });api_calls = await resend.calls(operation="…")let api_calls = resend.calls().operation("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
operation | string | no | option |
error | true | string | no | option |
Returns 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), so for now the call is refused with 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.
const apiCall = await resend.waitForCall({ operation: "…" });api_call = await resend.wait_for_call(operation="…")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. When the time is up, it fails with what it was waiting for.
ResendApp#
Returned by ResendFixture.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.
const email = await app.send({ to, subject: "…" });email = await app.send(to=to, subject="…")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.
Live: refused with 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.
const result = await app.reply(email, { text: "…" });result = await app.reply(email, text="…")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.
Live: refused with 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(), ResendApp.reply(), ResendEmail.refresh(), ResendUser.send().
| 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.
const updated = await email.refresh();updated = await email.refresh()let updated = email.refresh().await?;Returns ResendEmail.
deliveryFor()#
The delivery that told this app of the email (decision 0027), or nothing when it wasn't told.
const delivery = await email.deliveryFor(app);delivery = await email.delivery_for(app)let delivery = email.delivery_for(&app).await?;| Parameter | Type | Required | |
|---|---|---|---|
app | ResendApp | yes | positional |
Returns ResendDelivery | undefined.
Live: refused with 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.
const messages = await thread.messages();messages = await thread.messages()let messages = thread.messages().await?;Returns ResendMessages.
replies()#
The thread's answers: every email after the first, oldest first.
const replies = await thread.replies();replies = await thread.replies()let replies = thread.replies().await?;Returns ResendReplies.
transcript()#
The thread as a person reads it: each email's own words, without the quoted history.
const transcript = await thread.transcript();transcript = await thread.transcript()let transcript = thread.transcript().await?;Returns ResendTranscript.
waitForReply()#
Waits for the next reply after the last one this handle returned: it polls replies() and never sleeps longer than it must.
const email = await thread.waitForReply({ from: "my-agent" });email = await thread.wait_for_reply(from_="my-agent")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. 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.
const email = await thread.latestReply({ from: "my-agent" });email = await thread.latest_reply(from_="my-agent")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. When the time is up, it fails with what it was waiting for.
ResendDelivery#
Returned by ResendEmail.deliveryFor(), ResendDelivery.refresh().
| 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.
const updated = await delivery.refresh();updated = await delivery.refresh()let updated = delivery.refresh().await?;Returns ResendDelivery.
Live: refused with 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.
const deliveryAttempt = await delivery.redeliver();delivery_attempt = await delivery.redeliver()let delivery_attempt = delivery.redeliver().await?;Returns DeliveryAttempt.
Live: refused with 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.
const deliveryAttempt = await delivery.resend({ badSignature });delivery_attempt = await delivery.resend(bad_signature=bad_signature)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.
Live: refused with 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.
const updated = await delivery.settled();updated = await delivery.settled()let updated = delivery.settled().await?;| Parameter | Type | Required | |
|---|---|---|---|
timeout | Duration | no | default 10s |
Returns ResendDelivery. When the time is up, it fails with what it was waiting for.
ResendUser#
Returned by ResendFixture.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.
const email = await user.send({ to, subject: "…" });email = await user.send(to=to, subject="…")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.
reply()#
The person replies to an email, in its thread: Re: its subject, with In-Reply-To and References.
const result = await user.reply(email, { text: "…" });result = await user.reply(email, text="…")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.
inbox()#
What reached the person's mailbox, oldest first.
const inbox = await user.inbox();inbox = await user.inbox()let inbox = user.inbox().await?;Returns ResendInbox.
waitForEmail()#
Waits for the next email after the last one this handle returned: it polls inbox() and never sleeps longer than it must.
const email = await user.waitForEmail({ from: "my-agent" });email = await user.wait_for_email(from_="my-agent")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. When the time is up, it fails with what it was waiting for.
Types#
Plain values the handles return and take.
ResendApps#
type ResendApps = ResendApp[];
ResendPrincipal#
| Field | Type |
|---|---|
id | string |
name | string |
kind | "user" | "app" |
ResendUsers#
type ResendUsers = ResendUser[];
ResendThreads#
type ResendThreads = ResendThread[];
ResendInbox#
type ResendInbox = ResendEmail[];
ResendMessages#
type ResendMessages = ResendEmail[];
ResendReplies#
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#
type ResendDeliveries = ResendDelivery[];
ResendApiCalls#
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 |