resend / resend-cli
The official CLI for Resend
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing resend/resend-cli in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewResend CLI The official CLI for Resend. Built for humans, AI agents, and CI/CD pipelines. Install cURL Node.js Homebrew (macOS / Linux) PowerShell (Windows) Or download the directly from the GitHub releases page. Local development Use this when you want to change the CLI and run your build locally. Prerequisites • Node.js 20+ Setup • **Clone the repo** • **Install dependencies** • **Build locally** Output: Running the CLI locally Use the dev script: Or run the built JS bundle: Making changes After editing source files, rebuild: Building native binaries To build a standalone native binary: Output: Quick start --- Authentication The CLI resolves your API key using the following priority chain: | Priority | Source | How to set | |----------|--------|------------| | 1 (highest) | flag | | | 2 | env var | | | 3 (lowest) | Config file | | If no key is found from any source, the CLI errors with code . --- Commands Authenticate by storing your API key locally. The key is validated against the Resend API before being saved. 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 ( , ) and prompts for a new key to replace it. The key is entered via a masked password input and must start with . Non-interactive mode (CI, pipes, scripts) When stdin is not a TTY, the flag is required: Omitting in non-interactive mode exits with error code . Options | Flag | Description | |------|-------------| | | API key to store (required in non-interactive mode) | Output On success, credentials are saved to with permissions (owner read/write only). The config directory is created with permissions. Error codes | Code | Cause | |------|-------| | | No provided in non-interactive mode | | | Key does not start with | | | 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: You can also use the global (or ) flag on any command to run it with a specific profile. --- Send an email via the Resend API. Provide all options via flags for scripting, or let the CLI prompt interactively for missing fields. Options | Flag | Required | Description | |------|----------|-------------| | | Yes | Sender email address (must be from a verified domain) | | | Yes | One or more recipient email addresses (space-separated) | | | Yes | Email subject line | | | One of text/html/html-file | Plain text body | | | One of text/html/html-file | HTML body as a string | | | One of text/html/html-file | Path to an HTML file to use as body | | | No | CC recipients (space-separated) | | | No | BCC recipients (space-separated) | | | No | Reply-to email address | Interactive mode When run in a terminal without all required flags, the CLI prompts for missing fields: Non-interactive mode When piped or run in CI, all required flags must be provided. Missing flags cause an error listing what's needed: A body ( , , or ) is also required — omitting all three exits with code . Examples **Multiple recipients:** **HTML from a file:** **With CC, BCC, and reply-to:** **Overriding the API key for one send:** Output Returns the email ID on success: Error codes | Code | Cause | |------|-------| | | No API key found or client creation failed | | | No , , or provided | | | Could not read the file passed to | | | Resend API returned an error | --- Run environment diagnostics. Verifies your CLI version, API key, domains, and detects AI agent integrations. Checks performed | Check | Pass | Warn | Fail | |-------|------|------|------| | **CLI Version** | Running latest | Update available or registry unreachable | — | | **API Key** | Key found (shows masked key + 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. ). Interactive mode In a terminal, shows animated spinners for each check with colored status icons: JSON mode Each check has a of , , or . The top-level is if any check is . Detected AI agents | Agent | Detection method | |-------|-----------------| | OpenClaw | directory exists | | Cursor | directory exists | | Claude Desktop | Platform-specific config file exists | | VS Code | in current directory | Exit code Exits when all checks pass or warn. Exits if any check fails. --- Global options These flags work on every command and are passed before the subcommand: | Flag | Description | |------|-------------| | | Override API key for this invocation (takes highest priority) | | | Profile to use (overrides env var) | | | Force JSON output even in interactive terminals | | | Suppress spinners and status output (implies ) | | | Print version and exit | | | Show help text | --- Output behavior The CLI has two output modes: | Mode | When | Stdout | Stderr | |------|------|--------|--------| | **Interactive** | Terminal (TTY) | Formatted text | Spinners, prompts | | **Machine** | Piped, CI, or | JSON | Nothing | Switching is automatic — pipe to another command and JSON output activates: Error output Errors always exit with code and output structured JSON to stdout: --- Agent & CI/CD usage CI/CD Set as an environment variable — no needed: AI agents Agents calling the CLI as a subprocess automatically get JSON output (non-TTY detection). The contract: • **Input:** All required flags must be provided (no interactive prompts) • **Output:** JSON to stdout, nothing to stderr • **Exit code:** success, error • **Errors:** Always include and fields --- Configuration | Item | Path | Notes | |------|------|-------| | Config directory | | Respects…