# Resend CLI The Resend CLI (`resend`) is the [[Command Line Interface (CLI)|command-line tool]] for [[Resend]]. It covers sending email, domains, API keys, contacts, webhooks, automations and broadcasts, and it was designed with two kinds of users in mind: you at a terminal, and an AI agent running shell commands. ## Install and authenticate You can install it with a cURL install script, npm (`npm install -g resend-cli`), [[Homebrew]] or PowerShell. The binary is `resend`. The API key is resolved in this order: 1. The `--api-key` flag 2. The `RESEND_API_KEY` environment variable 3. Credentials saved by `resend login` If you work with several Resend teams or accounts, save one profile per account and switch with `resend auth switch`. ## Key commands ```bash resend emails send ... # send one email resend emails batch < emails.json # up to 100 emails, JSON on stdin resend emails receiving listen --json # stream inbound emails resend emails metrics # deliverability and engagement metrics resend emails share <id> --expires-in "2 hours" # expiring read-only link to an email resend domains ... # manage sending domains resend api-keys ... # manage API keys resend contacts ... # contacts, segments, CSV import resend suppressions ... # suppressed addresses resend automations create ... # create an automation resend events send ... # send a custom event (drives automations) resend webhooks listen # receive webhook events locally resend webhooks events list <id> # past events of a webhook resend broadcasts cancel <id> # cancel a broadcast ``` Several of these (metrics, webhook events, share, broadcast cancel) arrived with the [[Resend Headless Dashboard Initiative]]. ## Why it works well with agents The CLI behaves predictably when there's no human on the other side: - Output switches to JSON automatically when stdout isn't a terminal. In Resend's words: "Pipe to another command and JSON output activates." An agent doesn't have to remember a `--json` flag - Exit codes are `0` for success and `1` for failure, with structured error messages, so a script or an agent can branch on the result - Content can come from stdin (`--text-file -`), so you can pipe a generated report straight into an email - `--idempotency-key` makes retries safe: if the agent runs the same command twice, only one email goes out (see [[Idempotency]]) - `--scheduled-at` schedules the email instead of sending it now Resend also ships a skill that teaches agents how to use the CLI: ```bash npx skills add resend/resend-cli ``` `npx skills` is the installer from [[Skills.sh]]. For the broader set of Resend skills, see [[Resend Agent Skills]]. ## CLI or MCP? Both reach the same API. The CLI fits agents that already live in a shell ([[Claude Code]], CI jobs, cron scripts) and costs nothing in context until a command runs. The [[Resend MCP Server]] fits clients without a shell, or when you prefer OAuth over handling API keys. ## References - Resend CLI documentation: https://resend.com/docs/cli - Resend CLI quickstart: https://resend.com/docs/cli-quickstart - Using the Resend CLI with AI agents: https://resend.com/docs/cli-agents ## Related - [[Resend]] - [[Resend API]] - [[Resend MCP Server]] - [[Resend Agent Skills]] - [[Resend Headless Dashboard Initiative]] - [[Command Line Interface (CLI)]] - [[Cloudflare CLI]]