> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ancha.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli version 0.1.4, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli@0.1.4` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Resend

> A stateful replica of Resend's REST API: transactional emails and batches, broadcasts, domains, contacts and segments, where mail is recorded rather than delivered.

The Resend replica implements 40 endpoints of Resend's REST API. Mail is recorded, not delivered: each email gets the outcome its recipient implies, two simulated seconds after sending. Its key is `resend`. It was tested with the `resend` SDK.

## Connect

| Variable | Value |
| - | - |
| `RESEND_BASE_URL` | Base URL. The SDK reads it by itself. |
| `RESEND_API_KEY` | Fake API key with full access. Send `Authorization: Bearer <key>`. |

```js Node theme={null}
import { Resend } from 'resend';
// The SDK also reads RESEND_BASE_URL by itself.
const resend = new Resend(process.env.RESEND_API_KEY, { baseUrl: process.env.RESEND_BASE_URL });
const { data, error } = await resend.emails.list();
```

This is what `ancha connect resend --lang ts` prints.

## Endpoints

| Method | Path | Support |
| - | - | - |
| `POST` | `/emails` | partial: from a verified domain or `resend.dev`; `bounced@resend.dev` and `complained@resend.dev` give those outcomes; templates, topics and URL attachments are gaps |
| `POST` | `/emails/batch` | partial: up to 100 emails, all or none; permissive mode is a gap |
| `GET` | `/emails`, `/emails/:id` | supported |
| `PATCH` | `/emails/:id` | supported: reschedules a scheduled email |
| `POST` | `/emails/:id/cancel` | supported |
| `POST` | `/domains` | partial: custom return paths, click and open tracking and TLS settings are gaps |
| `GET` | `/domains`, `/domains/:id` | supported |
| `POST` | `/domains/:id/verify` | partial: verification completes two simulated minutes after it is asked for |
| `DELETE` | `/domains/:id` | supported |
| `POST` | `/contacts` | partial: contact properties and topics are gaps |
| `GET` | `/contacts` | supported |
| `GET`, `PATCH`, `DELETE` | `/contacts/:id` | supported, by ID or email |
| `GET` | `/contacts/:id/segments` | supported |
| `POST`, `DELETE` | `/contacts/:id/segments/:segment_id` | supported |
| `POST`, `GET` | `/segments` | supported |
| `GET`, `PATCH`, `DELETE` | `/segments/:id` | supported |
| `GET` | `/segments/:id/contacts` | supported |
| `POST` | `/broadcasts` | partial: a draft, or sent now or at `scheduled_at` to the segment's subscribed contacts as they are when the send is asked for; topics are a gap |
| `GET` | `/broadcasts`, `/broadcasts/:id` | supported |
| `PATCH` | `/broadcasts/:id` | partial: drafts only |
| `POST` | `/broadcasts/:id/send` | supported: now or at `scheduled_at` |
| `POST` | `/broadcasts/:id/cancel` | supported: a scheduled broadcast goes back to draft |
| `DELETE` | `/broadcasts/:id` | supported: drafts and scheduled broadcasts |
| `POST`, `GET` | `/audiences` | supported: deprecated aliases of `/segments` |
| `GET`, `DELETE` | `/audiences/:id` | supported: deprecated aliases |
| `POST`, `GET` | `/audiences/:id/contacts` | supported: deprecated, the segment's contacts |
| `GET`, `PATCH` | `/audiences/:id/contacts/:contact` | supported: deprecated, by ID or email |

Anything else returns HTTP 501 with Resend's error shape and `x-ancha-gap: 1`.

## Starter data

The `resend-starter` dataset is Acme's account with an API key named "Support agent".

| Record | Detail |
| - | - |
| Domains | `acme.example`, verified. `mail.acme.example`, added three hours ago and unverified. |
| Segments | "Customers" and "Product updates". |
| Contacts | Erin Walsh, Nora Bell, Grace Lin, Carla Diaz, Megan Shaw and Lucy Grant (unsubscribed), each in one or both segments. |
| Emails | Five sent: an overdue-invoice reminder to Helix Manufacturing that bounced, a welcome to Nora Bell (opened), "Your CSV export is ready" to Erin Walsh (clicked), a training recording to Megan Shaw (delivered), and a scheduled reports beta invite to three customers (delivered). |
| Broadcasts | "October product update", sent to Product updates ten days ago, and "November product update", a draft about the scheduled reports beta. |

## Checks

Resend has no state checks. Use trace checks, for example `{ called: "POST /emails" }` or `{ not_called: "POST /broadcasts/*/send" }`.

## Limits

* Mail is recorded, not delivered: `bounced@` and `complained@resend.dev` give those outcomes, other recipients are delivered two simulated seconds after sending.
* Broadcasts go to the segment's subscribed contacts as they are when the send is requested.
* Domain verification completes two simulated minutes after it is requested; templates, webhooks, topics and contact properties are gaps.


## Related topics

- [Tools](https://docs.ancha.io/tools/overview.md)
- [Test file (scene.yaml)](https://docs.ancha.io/reference/test-file.md)
- [ancha connect](https://docs.ancha.io/cli/connect.md)
- [Introduction](https://docs.ancha.io/index.md)
- [Environment variables](https://docs.ancha.io/reference/environment-variables.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.