---
title: "CLI"
description: "The `nextmail` command: your mailbox and every API operation, from a terminal or a script."
url: "https://nextmail.sh/docs/cli"
area: "CLI"
category: "Getting started"
---

# CLI

The `nextmail` command: your mailbox and every API operation, from a terminal or a script.

## What it is

One command for everything Nextmail does outside the browser. It reads, searches, sends and files mail, runs every operation of the REST API, translates, writes and summarises mail with AI, and connects MCP clients such as Claude and Cursor to your mailbox. It is a single file with no dependencies, and runs on Node.js 20.12 or later on macOS, Linux and Windows.

**Install**

_npm_

```text
npm install -g @nextmail/cli
```

_pnpm_

```text
pnpm add -g @nextmail/cli
```

_bun_

```text
bun add -g @nextmail/cli
```

_yarn_

```text
yarn global add @nextmail/cli
```

Or run it without installing anything: `npx @nextmail/cli <command>`.

## A 60-second tour

**Terminal**

```
nextmail login
nextmail status
nextmail inbox --unread
nextmail read CAHk7pQ2x9LmZ4
nextmail reply CAHk7pQ2x9LmZ4 --text "Thursday works for me."
nextmail send --to ada@example.com --subject "Lunch?" --text "Thursday at noon?"
nextmail search invoice from:ada has:pdf
nextmail domains list
nextmail mcp config --client claude-code
```

1. `login` opens your browser, where you choose the workspace and what the CLI may do, and saves the sign-in.
2. `status` shows who you are, the addresses you can send from and the state of each domain.
3. `inbox`, `read`, `reply`, `send` and `search` work the mailbox the way the app does.
4. `domains list` is a resource command. Every method of the SDK has one, so anything the API can do, the CLI can do.
5. `mcp config` prints what to add to an AI client so it can use your mailbox.

## Two ways to sign in

| Command | What it saves | Verification codes |
| --- | --- | --- |
| nextmail login | A browser sign-in, for a person at a terminal. It acts as you, limited to what you approve, and can use the AI tools and the MCP server. | Asked before a few sensitive changes, as in the web app |
| nextmail login --with-token | An API key, for scripts, CI and servers. It acts with the scopes of the key. | Never asked |

## In the web app

Billing, creating and switching workspaces, account security, data export, writing calendar events, forwarding and linking a DNS provider happen in the web app. `nextmail open` takes you to the right page, signed in as whoever is signed in to that browser. `open forwarding` takes the address whose forwarding you want to change, and `open providers`, or `open dns`, opens DNS provider linking.

**Terminal**

```
nextmail open billing
nextmail open security --print
nextmail open forwarding you@acme.com
nextmail open providers
```

## Where to go

- [Install](https://nextmail.sh/docs/cli/install.md): Every package manager, npx, updates and shell completion.
- [Authentication](https://nextmail.sh/docs/cli/authentication.md): Browser sign-in, API keys, profiles and verification codes.
- [Commands](https://nextmail.sh/docs/cli/commands.md): The grammar, the global flags and every command.
- [Mail](https://nextmail.sh/docs/cli/mail.md): Send, read, search, reply and file threads.
- [AI and MCP](https://nextmail.sh/docs/cli/ai-and-mcp.md): Translate and write with AI, and connect AI clients.
- [Scripting](https://nextmail.sh/docs/cli/scripting.md): JSON, streams, exit codes and CI.
- [For AI agents](https://nextmail.sh/docs/cli/agents.md): Unattended sign-in, help as data, dry runs and missing scopes.
- [Every command](https://nextmail.sh/docs/cli/reference/commands.md): All of them on one page, with the endpoint and scope of each.
- [Changelog](https://nextmail.sh/docs/cli/changelog.md): Every release, newest first.
