resend-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Resend CLI

Resend CLI

Agent Protocol

Agent协议

The CLI auto-detects non-TTY environments and outputs JSON — no
--json
flag needed.
Rules for agents:
  • Supply ALL required flags. The CLI will NOT prompt when stdin is not a TTY.
  • Pass
    --quiet
    (or
    -q
    ) to suppress spinners and status messages.
  • Exit
    0
    = success,
    1
    = error.
  • Error JSON goes to stderr, success JSON goes to stdout:
    json
    {"error":{"message":"...","code":"..."}}
  • Use
    --api-key
    or
    RESEND_API_KEY
    env var. Never rely on interactive login.
  • All
    delete
    /
    rm
    commands require
    --yes
    in non-interactive mode.
CLI会自动检测非TTY环境并输出JSON——无需使用
--json
标志。
Agent规则:
  • 提供所有必填标志。当标准输入不是TTY时,CLI不会进行提示。
  • 传递
    --quiet
    (或
    -q
    )以抑制加载动画和状态消息。
  • 退出码
    0
    表示成功,
    1
    表示错误。
  • 错误JSON输出到stderr,成功JSON输出到stdout:
    json
    {"error":{"message":"...","code":"..."}}
  • 使用
    --api-key
    RESEND_API_KEY
    环境变量。切勿依赖交互式登录。
  • 所有
    delete
    /
    rm
    命令在非交互式模式下需要添加
    --yes
    标志。

Authentication

认证

Auth resolves:
--api-key
flag >
RESEND_API_KEY
env > config file (
resend login --key
). Use
--profile
or
RESEND_PROFILE
for multi-profile.
认证优先级:
--api-key
标志 >
RESEND_API_KEY
环境变量 > 配置文件(
resend login --key
)。使用
--profile
RESEND_PROFILE
进行多配置文件管理。

Global Flags

全局标志

FlagDescription
--api-key <key>
Override API key for this invocation
-p, --profile <name>
Select stored profile
--json
Force JSON output (auto in non-TTY)
-q, --quiet
Suppress spinners/status (implies
--json
)
标志描述
--api-key <key>
覆盖本次调用使用的API密钥
-p, --profile <name>
选择已存储的配置文件
--json
强制输出JSON(非TTY环境下自动启用)
-q, --quiet
抑制加载动画/状态消息(隐含
--json

Available Commands

可用命令

Command GroupWhat it does
emails
send, get, list, batch, cancel, update
emails receiving
list, get, attachments, forward, listen
domains
create, verify, update, delete, list
api-keys
create, list, delete
broadcasts
create, send, update, delete, list
contacts
create, update, delete, segments, topics
contact-properties
create, update, delete, list
segments
create, get, list, delete
templates
create, publish, duplicate, delete, list
topics
create, update, delete, list
webhooks
create, update, listen, delete, list
auth
login, logout, switch, rename, remove
whoami
/
doctor
/
update
/
open
Utility commands
Read the matching reference file for detailed flags and output shapes.
命令组功能
emails
发送、获取、列出、批量发送、取消、更新
emails receiving
列出、获取、查看附件、转发、监听
domains
创建、验证、更新、删除、列出
api-keys
创建、列出、删除
broadcasts
创建、发送、更新、删除、列出
contacts
创建、更新、删除、管理分段、管理主题
contact-properties
创建、更新、删除、列出
segments
创建、获取、列出、删除
templates
创建、发布、复制、删除、列出
topics
创建、更新、删除、列出
webhooks
创建、更新、监听、删除、列出
auth
登录、登出、切换、重命名、移除配置文件
whoami
/
doctor
/
update
/
open
实用工具命令
查看对应的参考文件以获取详细的标志说明和输出格式。

Common Mistakes

常见错误

#MistakeFix
1Forgetting
--yes
on delete commands
All
delete
/
rm
subcommands require
--yes
in non-interactive mode — otherwise the CLI exits with an error
2Not saving webhook
signing_secret
webhooks create
shows the secret once only — it cannot be retrieved later. Capture it from command output immediately
3Omitting
--quiet
in CI
Without
-q
, spinners and status text leak into stdout. Use
-q
to get clean JSON only
4Using
--scheduled-at
with batch
Batch sending does not support
scheduled_at
— use single
emails send
instead
5Expecting
domains list
to include DNS records
List returns summaries only — use
domains get <id>
for the full
records[]
array
6Sending a dashboard-created broadcast via CLIOnly API-created broadcasts can be sent with
broadcasts send
— dashboard broadcasts must be sent from the dashboard
7Passing
--events
to
webhooks update
expecting additive behavior
--events
replaces the entire subscription list — always pass the complete set
序号错误操作修复方法
1删除命令忘记添加
--yes
标志
在非交互式模式下,所有
delete
/
rm
子命令都需要
--yes
标志——否则CLI会报错退出
2未保存webhook的
signing_secret
webhooks create
只会显示一次密钥——之后无法找回。请立即从命令输出中记录该密钥
3在CI环境中未使用
--quiet
标志
如果不添加
-q
,加载动画和状态文本会混入标准输出。使用
-q
以仅获取纯净的JSON输出
4批量发送时使用
--scheduled-at
标志
批量发送不支持
scheduled_at
——请使用单个
emails send
命令替代
5期望
domains list
返回DNS记录
列表命令仅返回摘要信息——如需完整的
records[]
数组,请使用
domains get <id>
命令
6通过CLI发送在控制台创建的广播只有通过API创建的广播才能使用
broadcasts send
发送——控制台创建的广播必须从控制台发送
7
webhooks update
中传递
--events
期望追加行为
--events
会替换整个订阅列表——请始终传递完整的事件集合

Common Patterns

常见使用示例

Send an email:
bash
resend emails send --from "you@domain.com" --to user@example.com --subject "Hello" --text "Body"
Domain setup flow:
bash
resend domains create --name example.com --region us-east-1
发送邮件:
bash
resend emails send --from "you@domain.com" --to user@example.com --subject "Hello" --text "Body"
域名配置流程:
bash
resend domains create --name example.com --region us-east-1

Configure DNS records from output, then:

根据输出配置DNS记录,然后执行:

resend domains verify <domain-id> resend domains get <domain-id> # check status

**Create and send a broadcast:**
```bash
resend broadcasts create --from "news@domain.com" --subject "Update" --segment-id <id> --html "<h1>Hi</h1>" --send
CI/CD (no login needed):
bash
RESEND_API_KEY=re_xxx resend emails send --from ... --to ... --subject ... --text ...
Check environment health:
bash
resend doctor -q
resend domains verify <domain-id> resend domains get <domain-id> # 检查状态

**创建并发送广播:**
```bash
resend broadcasts create --from "news@domain.com" --subject "Update" --segment-id <id> --html "<h1>Hi</h1>" --send
CI/CD环境使用(无需登录):
bash
RESEND_API_KEY=re_xxx resend emails send --from ... --to ... --subject ... --text ...
检查环境健康状态:
bash
resend doctor -q

When to Load References

何时查看参考文档

  • Sending or reading emailsreferences/emails.md
  • Setting up or verifying a domainreferences/domains.md
  • Managing API keysreferences/api-keys.md
  • Creating or sending broadcastsreferences/broadcasts.md
  • Managing contacts, segments, or topicsreferences/contacts.md, references/segments.md, references/topics.md
  • Defining contact propertiesreferences/contact-properties.md
  • Working with templatesreferences/templates.md
  • Setting up webhooks or listening for eventsreferences/webhooks.md
  • Auth, profiles, or health checksreferences/auth.md
  • Multi-step recipes (setup, CI/CD, broadcast workflow) → references/workflows.md
  • Command failed with an errorreferences/error-codes.md
  • Resend SDK integration (Node.js, Python, Go, etc.) → Install the
    resend
    skill
  • AI agent email inbox → Install the
    agent-email-inbox
    skill
  • 发送或查看邮件references/emails.md
  • 配置或验证域名references/domains.md
  • 管理API密钥references/api-keys.md
  • 创建或发送广播references/broadcasts.md
  • 管理联系人、分段或主题references/contacts.md, references/segments.md, references/topics.md
  • 定义联系人属性references/contact-properties.md
  • 使用模板references/templates.md
  • 配置webhook或监听事件references/webhooks.md
  • 认证、配置文件或健康检查references/auth.md
  • 多步骤流程(配置、CI/CD、广播工作流) → references/workflows.md
  • 命令执行报错references/error-codes.md
  • Resend SDK集成(Node.js、Python、Go等) → 安装
    resend
    技能
  • AI Agent邮箱收件箱 → 安装
    agent-email-inbox
    技能