Resend CLI
The official CLI for Resend.
Built for humans, AI agents, and CI/CD pipelines.
██████╗ ███████╗███████╗███████╗███╗ ██╗██████╗
██╔══██╗██╔════╝██╔════╝██╔════╝████╗ ██║██╔══██╗
██████╔╝█████╗ ███████╗█████╗ ██╔██╗ ██║██║ ██║
██╔══██╗██╔══╝ ╚════██║██╔══╝ ██║╚██╗██║██║ ██║
██║ ██║███████╗███████║███████╗██║ ╚████║██████╔╝
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═══╝╚═════╝
Install
cURL
curl -fsSL https://resend.com/install.sh | bash
Node.js
npm install -g resend-cli
Homebrew (macOS / Linux)
brew install resend/cli/resend
PowerShell (Windows)
irm https://resend.com/install.ps1 | iex
Or download the .exe directly from the GitHub releases page.
Quickstart
# Authenticate
resend login
# Send an email
resend emails send \
--from "you@example.com" \
--to delivered@resend.dev \
--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:
npx skills add resend/resend-skills
Local development
Use this when you want to change the CLI and run your build locally.
Prerequisites
Setup
-
Clone the repo
git clone https://github.com/resend/resend-cli.git
cd resend-cli
-
Install dependencies
pnpm install
-
Build locally
pnpm build
Output: ./dist/cli.cjs
Running the CLI locally
Use the dev script:
pnpm dev --version
Or run the built JS bundle:
node dist/cli.cjs --version
Making changes
After editing source files, rebuild:
pnpm build
Building native binaries
To build a standalone native binary:
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.
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)
The CLI is non-interactive when stdin or stdout is not a TTY, when CI or GITHUB_ACTIONS is set, or when TERM=dumb. In that mode, pass --web or --key.
--web logs in through the browser with no prompts in any mode, so AI agents can run it. The command tries to open the browser, then prints the authorize URL and the target profile to stderr. It waits up to 5 minutes for you to approve the login, then stores an OAuth grant:
resend login --web
- The browser must run on the same machine as the CLI, because Resend redirects to a local callback on
127.0.0.1.
- Without
--profile, the login goes to the default profile and replaces its saved credentials.
- The status text on stderr comes before any JSON error.
--key stores an API key:
resend login --key re_xxxxxxxxxxxxx
Omitting both flags in non-interactive mode exits with error code missing_key.
Options
| Flag | Description |
|---|
--web | Log in through the browser with no prompts |
--key <key> | API key to store (required in non-interactive mode, unless --web) |
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.
With --json, or when stdout is not a TTY, the result is JSON on stdout:
resend login --key re_xxx --json
# => {"success":true,"config_path":"...","profile":"default","storage":"...","permission":"full_access"}
resend login --web --json
# => {"success":true,"config_path":"...","profile":"default","storage":"...","scope":"full_access"}
Error codes
| Code | Cause |
|---|
missing_key | No --key or --web in non-interactive mode |
conflicting_flags | --web and --key are both set |
invalid_key_format | Key does not start with re_ |
validation_failed | Resend API rejected the key |
invalid_profile_name | The --profile name is not valid |
write_failed | The credentials could not be saved |
oauth_error | Browser login failed: the local callback did not start, access was denied, it timed out, or the token exchange failed |
oauth_state_mismatch | The browser callback did not match this login request |
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:
resend auth switch
You can also use the global --profile (or -p) flag on any command to run it with a specific profile.
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.
resend emails send \
--from "Name <sender@example.com>" \
--to delivered@resend.dev \
--subject "Subject line" \
--text "Plain text body"
Options
| Flag | Required | Description |
|---|
--from <address> | Yes | Sender email address (must be from a verified domain) |
--to <addresses...> | Yes | One or more recipient email addresses (space-separated) |
--subject <subject> | Yes | Email subject line |
--text <text> | One of text/html/html-file | Plain text body |
--html <html> | One of text/html/html-file | HTML body as a string |
--html-file <path> | One of text/html/html-file | Path to an HTML file to use as body |
--cc <addresses...> | No | CC recipients (space-separated) |
--bcc <addresses...> | No | BCC recipients (space-separated) |
--reply-to <address> | No | Reply-to email address |
Interactive mode
When run in a terminal without all required flags, the CLI prompts for missing fields:
# prompts for from, to, subject, and body
resend emails send
# prompts only for missing fields
resend emails send --from "you@example.com"
Non-interactive mode
When piped or run in CI, all required flags must be provided. Missing flags cause an error listing what's needed:
echo "" | resend emails send --from "you@example.com"
# 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:
resend emails send \
--from "you@example.com" \
--to delivered@resend.dev bounced@resend.dev \
--subject "Team update" \
--text "Hello everyone"
HTML from a file:
resend emails send \
--from "you@example.com" \
--to delivered@resend.dev \
--subject "Newsletter" \
--html-file ./newsletter.html
With CC, BCC, and reply-to:
resend emails send \
--from "you@example.com" \
--to delivered@resend.dev \
--subject "Meeting notes" \
--text "See attached." \
--cc manager@example.com \
--bcc delivered+1@resend.dev \
--reply-to support@example.com
Overriding the API key for one send:
resend --api-key re_other_key emails send \
--from "you@example.com" \
--to delivered@resend.dev \
--subject "Test" \
--text "Using a different key"
Output
Returns the email ID on success:
{ "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.
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