@emulators/resend

中文文档
0.13.1发布于 2026/11/09Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 7.1万

Resend email API emulation with email sending, domain management, API keys, audiences, contacts, and a local inbox for captured messages.

原始使用文档
文档目录11 节
  1. Install
  2. Endpoints
  3. Emails
  4. Idempotency
  5. Recipient restrictions and send attempts
  6. Domains
  7. API Keys
  8. Audiences & Contacts
  9. Inbox
  10. Seed Configuration
  11. Links

@emulators/resend

Resend email API emulation with email sending, domain management, API keys, audiences, contacts, and a local inbox for captured messages.

Part of emulate — local drop-in replacement services for CI and no-network sandboxes.

Install

npm install @emulators/resend

Endpoints

Emails

  • POST /emails — send single email
  • POST /emails/batch — send up to 100 emails
  • GET /emails — list sent emails
  • GET /emails/:id — get email
  • POST /emails/:id/cancel — cancel scheduled email

Idempotency

POST /emails and POST /emails/batch accept the case-insensitive Idempotency-Key header. Keys must be 1 to 256 characters and are retained for 24 hours. Repeating a request with the same key and validated payload returns the original response without creating another email or dispatching duplicate webhooks. Reusing a key with a different payload or endpoint returns 409 invalid_idempotent_request. Invalid key lengths return 400 invalid_idempotency_key. Requests without the header keep the normal non-idempotent behavior.

Recipient restrictions and send attempts

Set resend.allowlist in seed config to test recipient rejection:

resend:
  allowlist:
    - [email protected]
    - [email protected]

Omitting allowlist accepts every recipient; allowlist: [] rejects every recipient. Every address in to, cc, and bcc must be listed. Matching ignores surrounding whitespace and letter case; entries are individual addresses, with no wildcard or domain matching. This is a local testing control, independent of Resend's domain verification and account restrictions.

A rejected send returns 403 validation_error naming the rejected addresses and configured allowlist. No email ID, email record, idempotency record, or webhook is created. A batch is rejected as a whole if any recipient is disallowed. Retrying a rejected request, even with the same idempotency key, creates a new attempt. Replaying an accepted idempotent request returns its original response even if the allowlist has since changed.

Validated sends append one record per email to the resend.send_attempts store collection, including emails in a rejected batch. Each record contains from, to, cc, bcc, subject, idempotency_key (or null), and the store's id, created_at, and updated_at. Message bodies are not copied into attempts. Malformed requests, invalid or conflicting idempotency keys, and idempotency replays do not append attempts.

Read attempts with getResendStore(store).sendAttempts.all() from @emulators/resend, or inspect the persisted state. Shared adapter snapshots use the key resend:resend.send_attempts. Attempts and recipient restrictions survive saved-state restoration, including rejected sends. There is no additional Resend API endpoint for attempts. A rejected send has an attempt without an email; a send that never happened has neither.

Domains

  • POST /domains — create domain
  • GET /domains — list domains
  • GET /domains/:id — get domain
  • DELETE /domains/:id — remove domain
  • POST /domains/:id/verify — trigger domain verification

API Keys

  • POST /api-keys — create API key
  • GET /api-keys — list API keys
  • DELETE /api-keys/:id — delete API key

Audiences & Contacts

  • POST /audiences — create audience
  • GET /audiences — list audiences
  • DELETE /audiences/:id — delete audience
  • POST /audiences/:audience_id/contacts — add contact
  • GET /audiences/:audience_id/contacts — list contacts
  • DELETE /audiences/:audience_id/contacts/:id — delete contact

Inbox

  • GET /inbox — list captured emails
  • GET /inbox/:id — view captured email

Seed Configuration

resend:
  domains:
    - name: example.com
  api_keys:
    - name: default

版本与发布记录

@emulators/resend 共发布 18 个版本,首次发布于 2026/04/03;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.1latest2026/11/094 天前
0.13.02026/10/2915 天前
0.12.32026/10/2321 天前
0.12.22026/10/1430 天前
0.12.12026/10/021 个月前
0.12.02026/09/241 个月前

关于 @emulators/resend 的常见问题

@emulators/resend 是什么?

Resend email API emulation with email sending, domain management, API keys, audiences, contacts, and a local inbox for captured messages.

如何安装 @emulators/resend?

在项目目录运行 npm install @emulators/resend,或使用 pnpm add / yarn add / bun add。

@emulators/resend 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@emulators/resend 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@emulators/resend 可以商用吗?

@emulators/resend 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@emulators/resend 的下载量有多少?

根据 npm 官方下载统计,@emulators/resend 在 2026/10/14 – 2026/11/12 这 30 天内被下载 70,880 次,日均约 2,363 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@emulators/resend 还在维护吗?

最新版本 0.13.1 发布于 2026/11/09(4 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/04/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。