Resend CLI
The Resend CLI is the official command-line interface for interacting with the Resend email API. It allows developers, AI agents, and CI/CD pipelines to manage and send emails directly from the terminal. The current stable version is 2.2.1, with frequent minor and patch releases, indicating active development and continuous feature additions. Key differentiators include its multi-platform installation methods (npm, cURL, Homebrew, PowerShell), built-in 'agent skill' support for AI coding agents, and robust authentication mechanisms. It provides commands for common tasks such as sending emails, managing domains, and checking the environment, aiming to streamline email operations programmatically and interactively.
Common errors
-
Error: auth_error
cause The Resend API key was not found through any of the configured sources (flag, environment variable, or config file).fixRun `resend login` to store your API key, or export `RESEND_API_KEY=re_xxx` in your environment, or pass it via `--api-key re_xxx` flag. -
Error: missing_key
cause Attempted to run `resend login` in a non-interactive environment (e.g., CI/CD) without providing the `--key` flag.fixUse `resend login --key re_xxxxxxxxxxxxx` to provide the API key when not in an interactive terminal.
Warnings
- breaking Version 2.0.0 removed 'backwards compatibility shims', which might break existing scripts or integrations relying on older CLI behaviors or flags.
- gotcha The Resend CLI resolves API keys using a strict priority: `--api-key` flag (highest), `RESEND_API_KEY` environment variable, then the locally stored config file (lowest). Misunderstanding this order can lead to unexpected authentication issues.
- gotcha When running `resend login` in a non-interactive environment (e.g., CI/CD pipelines, scripts), the `--key` flag is mandatory. Omitting it will result in an error.
- breaking The CLI requires Node.js version 20 or higher. Running with older Node.js versions may lead to errors or unexpected behavior.
- security Version 1.10.0 included a fix to sanitize untrusted terminal output, preventing potential escape sequence injection vulnerabilities. Older versions might be susceptible to malicious input displaying unexpected terminal behaviors or executing arbitrary commands in certain contexts.
Install
-
npm install resend-cli -
yarn add resend-cli -
pnpm add resend-cli
Imports
- resend
import { resend } from 'resend-cli'npm install -g resend-cli
- resend login
node resend login
resend login
- resend emails send
resend send email
resend emails send --from 'you@example.com' --to 'recipient@example.com' --subject 'Hello' --text 'Body'
Quickstart
resend login resend emails send \ --from "you@example.com" \ --to delivered@resend.dev \ --subject "Hello from Resend CLI" \ --text "Sent from my terminal." resend doctor