百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

resend-cli

> 编程语言
开源

Resend 的官方 CLI

386 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Resend 的官方 CLI

Resend CLI

The official CLI for Resend.

Built for humans, AI agents, and CI/CD pipelines.

██████╗ ███████╗███████╗███████╗███╗   ██╗██████╗
██╔══██╗██╔════╝██╔════╝██╔════╝████╗  ██║██╔══██╗
██████╔╝█████╗  ███████╗█████╗  ██╔██╗ ██║██║  ██║
██╔══██╗██╔══╝  ╚════██║██╔══╝  ██║╚██╗██║██║  ██║
██║  ██║███████╗███████║███████╗██║ ╚████║██████╔╝
╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝╚═╝  ╚═══╝╚═════╝

Install

cURL

bash
curl -fsSL https://resend.com/install.sh | bash

Node.js

bash
npm install -g resend-cli

Homebrew (macOS / Linux)

bash
brew install resend/cli/resend

PowerShell (Windows)

bash
irm https://resend.com/install.ps1 | iex

Or download the .exe directly from the GitHub releases page.

Quickstart

bash
# Authenticate
resend login

# Send an email
resend emails send \
  --from "[email protected]" \
  --to [email protected] \
  --subject "Hello from Resend CLI" \
  --text "Sent from my terminal."

# Check your environment
resend doctor

Agent skills

This CLI ships with an agent skill that teaches AI coding agents (Cursor, Claude Code, Windsurf, etc.) how to use the Resend CLI effectively, including non-interactive flags, output formats, and common pitfalls.

To install skills for Resend's full platform (API, CLI, React Email, email best practices) from the central skills repository:

bash
npx skills add resend/resend-skills

Local development

Use this when you want to change the CLI and run your build locally.

Prerequisites

  • Node.js 20+

Setup

  1. Clone the repo

    bash
    git clone https://github.com/resend/resend-cli.git
    cd resend-cli
  2. Install dependencies

    bash
    pnpm install
  3. Build locally

    bash
    pnpm build

    Output: ./dist/cli.cjs

Running the CLI locally

Use the dev script:

bash
pnpm dev --version

Or run the built JS bundle:

bash
node dist/cli.cjs --version

Making changes

After editing source files, rebuild:

bash
pnpm build

Building native binaries

To build a standalone native binary:

bash
pnpm build:bin

Output: ./dist/resend


Authentication

The CLI resolves your API key using the following priority chain:

Priority Source How to set
1 (highest) --api-key flag resend --api-key re_xxx emails send ...
2 RESEND_API_KEY env var export RESEND_API_KEY=re_xxx
3 (lowest) Config file resend login

If no key is found from any source, the CLI errors with code auth_error.


Commands

resend login

Authenticate by storing your API key locally. The key is validated against the Resend API before being saved.

bash
resend login

Interactive mode (default in terminals)

When run in a terminal, the command checks for an existing key:

  • No key found: Offers to open the Resend API keys dashboard in your browser so you can create one, then prompts for the key.
  • Existing key found: Shows the key source (env, config) and prompts for a new key to replace it.

Enter the key via a masked password input. Your key must start with re_.

Non-interactive mode (CI, pipes, scripts)

When stdin is not a TTY, the --key flag is required:

bash
resend login --key re_xxxxxxxxxxxxx

Omitting --key in non-interactive mode exits with error code missing_key.

Options

Flag Description
--key API key to store (required in non-interactive mode)

Output

On success, credentials are saved to ~/.config/resend/credentials.json with 0600 permissions (owner read/write only). The config directory is created with 0700 permissions.

bash
# JSON output
resend login --key re_xxx --json
# => {"success":true,"config_path":"/Users/you/.config/resend/credentials.json"}

Error codes

Code Cause
missing_key No --key provided in non-interactive mode
invalid_key_format Key does not start with re_
validation_failed Resend API rejected the key

Switch between teams and accounts

If you work across multiple Resend teams or accounts, the CLI handles that, too.

Switch between profiles without logging in and out:

bash
resend auth switch

You can also use the global --profile (or -p) flag on any command to run it with a specific profile.

bash
resend domains list --profile production

resend emails send

Send an email via the Resend API.

Provide all options via flags for scripting, or let the CLI prompt interactively for missing fields.

bash
resend emails send \
  --from "Name " \
  --to [email protected] \
  --subject "Subject line" \
  --text "Plain text body"

Options

Flag Required Description
--from Yes Sender email address (must be from a verified domain)
--to Yes One or more recipient email addresses (space-separated)
--subject Yes Email subject line
--text One of text/html/html-file Plain text body
--html One of text/html/html-file HTML body as a string
--html-file One of text/html/html-file Path to an HTML file to use as body
--cc No CC recipients (space-separated)
--bcc No BCC recipients (space-separated)
--reply-to No Reply-to email address

Interactive mode

When run in a terminal without all required flags, the CLI prompts for missing fields:

bash
# prompts for from, to, subject, and body
resend emails send

# prompts only for missing fields
resend emails send --from "[email protected]"

Non-interactive mode

When piped or run in CI, all required flags must be provided. Missing flags cause an error listing what's needed:

bash
echo "" | resend emails send --from "[email protected]"
# Error: Missing required flags: --to, --subject

A body (--text, --html, or --html-file) is also required — omitting all three exits with code missing_body.

Examples

Multiple recipients:

bash
resend emails send \
  --from "[email protected]" \
  --to [email protected] [email protected] \
  --subject "Team update" \
  --text "Hello everyone"

HTML from a file:

bash
resend emails send \
  --from "[email protected]" \
  --to [email protected] \
  --subject "Newsletter" \
  --html-file ./newsletter.html

With CC, BCC, and reply-to:

bash
resend emails send \
  --from "[email protected]" \
  --to [email protected] \
  --subject "Meeting notes" \
  --text "See attached." \
  --cc [email protected] \
  --bcc [email protected] \
  --reply-to [email protected]

Overriding the API key for one send:

bash
resend --api-key re_other_key emails send \
  --from "[email protected]" \
  --to [email protected] \
  --subject "Test" \
  --text "Using a different key"

Output

Returns the email ID on success:

json
{ "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" }

Error codes

Code Cause
auth_error No API key found or client creation failed
missing_body No --text, --html, or --html-file provided
file_read_error Could not read the file passed to --html-file
send_error Resend API returned an error

resend doctor

Run environment diagnostics. Verifies your CLI version, API key, domains, and detects AI agent integrations.

bash
resend doctor

Checks performed

Check Pass Warn Fail
CLI Version Running latest Update available or registry unreachable —
API Key Key found (shows masked key and source) — No key found
Domains Verified domains exist No domains or all pending verification API key invalid
AI Agents Lists detected agents (or none) — —

The API key is always masked in output (e.g. re_...xxxx).

Interactive mode

In a terminal, shows animated spinners for each check with colored status icons:

  Resend Doctor

  ✔ CLI Version: v0.1.0 (latest)
  ✔ API Key: re_...xxxx (source: env)
  ✔ Domains: 2 verified, 0 pending
  ✔ AI Agents: Detected: Cursor, Claude Desktop

JSON mode

bash
resend doctor --json
json
{
  "ok": true,
  "checks": [
    { "name": "CLI Version", "status": "pass", "message": "v0.1.0 (latest)" },
    {
      "name": "API Key",
      "status": "pass",
      "message": "re_...xxxx (source: env)"
    },
    { "name": "Domains", "status": "pass", "message": "2 verified, 0 pending" },
    { "name": "AI Agents", "status": "pass", "message": "Detected: Cursor" }
  ]
}

Each check has a status of pass, warn, or fail. The top-level ok is false if any check is fail.

Detected AI agents

Agent Detection method
OpenClaw ~/clawd/skills directory exists
Cursor ~/.cursor directory exists
Claude Desktop Platform-specific config file exists
VS Code .vscode/mcp.json in current directory

Exit code

Exits 0 when all checks pass or warn. Exits 1 if any check fails.


Webhooks

With the Resend CLI, you can manage webhook endpoints so your app receives real-time event notifications.

Payloads are signed with Svix headers (svix-id, svix-timestamp, svix-signature). Verify them in your app with the Resend SDK.

For example: resend.webhooks.verify({ payload, headers, webhookSecret })

There are many events that you can listen for in your application.

For example, you can:

  • Set up a POST endpoint to unsubscribe users when an email bounces or they mark your email as spam.
  • Notify yourself when you get a new subscriber using the contact.created event.
  • Use an email.received webhook to set up an inbox for your agent and notify it when a new email is received.

Event types

| Category | Events | |

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言