Commands
How a command reads, the global flags, every hand-written command and every resource namespace.
How a command reads
nextmail <command> [subcommand] [arguments] [flags]- Flags go anywhere after the command, before or after the arguments. Global flags such as
--profileand--jsonmay also come before it, and any other flag placed there stops with a hint to move it after the command name. - A value follows its flag after a space or an equals sign, so
--limit 50and--limit=50are the same. Short flags take values too, as in-n 50. - A value that starts with a dash needs the equals sign, as in
--subject=-draft-, because after a space it reads as the next flag and the first one is reported as missing its value. Negative numbers work either way. An empty value is a usage error rather than a quiet default. - A switch is on with
--flagand off with--no-flag, and--flag=trueand--flag=falsework too. - A list is comma separated or repeated:
--to ada@example.com,bob@example.com, or--totwice. - Everything after
--is an argument and never a flag, which is how a search for-from:adagets through. - An unknown command or flag stops with exit code
2and suggests the closest match.
Global flags
| Flag | What it does |
|---|---|
| -h, --help | Help for the command or group. With --json, the same help as one JSON document |
| -v, --version | Print the CLI version |
| --json | Only JSON on stdout, errors as JSON on stderr, and never a prompt |
| -y, --yes | Confirm destructive actions without asking. Never skips a verification code |
| --dry-run | Run the reads, then print the first request that would change something instead of sending it, and exit with code 0. Skips confirmations, since nothing is sent |
| --profile <name> | Use this saved profile, like NEXTMAIL_PROFILE, even when NEXTMAIL_API_KEY is set |
| --api-key <key> | Use this API key for this command only, ignoring profiles |
| --base-url <url> | The API origin for an API key or a command that sends no credential, like NEXTMAIL_BASE_URL. A saved sign-in refuses any other origin with exit code 2, so sign in to it as its own profile |
| --no-input | Never prompt. A missing value stops with exit code 2 |
| --no-color | No colour, like NO_COLOR and FORCE_COLOR=0 |
| --debug | Print request ids, the failed request and stack traces |
Hand-written commands
These are written for people: they ask for what is missing, format what they print, and combine several API calls where that helps.
| Command | What it does |
|---|---|
| login | Sign in with your browser, or save an API key |
| whoami | Who you are signed in as, with the workspace, scopes and expiry |
| status | What whoami shows, plus your sender addresses and the state of each domain |
| verify | Enter a verification code now, so sensitive commands run for 60 minutes |
| logout | Sign out and forget a profile |
| profile list, use, current, remove | List, switch and remove saved sign-ins |
| send | Send, schedule, or translate and send an email |
| inbox [folder] | List the threads in a folder |
| search <query> | Search mail with the syntax the app uses |
| read <thread-id> | Read a thread, message by message |
| reply <thread-id> | Reply to the last message on a thread |
| archive, unarchive, trash, star, unstar | File one or more threads |
| mark read, mark unread | Mark threads read or unread |
| snooze, unsnooze | Hide threads until later, or bring them back now |
| label add, label remove | Put labels on threads, or take them off |
| temp new, list, read, watch, delete | Disposable inboxes, with no sign-in |
| ai translate, languages, compose, summarize | Translate, write and summarise mail with AI |
| mcp config, tools, call, serve | Connect AI clients, or call MCP tools yourself |
| docs ask, open, read | Ask, open and read this documentation |
| agents | A guide for AI agents and scripts that drive the CLI, in Markdown or as JSON |
| open [page] | Open a page of the web app |
| api <method> <path> | Call any REST endpoint with your sign-in |
| update | Check npm for a newer release |
| completion <shell> | Print a completion script for bash, zsh or fish |
| version | Print the CLI, SDK and runtime versions |
| help [command] | Show the help of any command |
Resource commands
Every method of the SDK is also a command, nextmail <namespace> <verb>. The namespace is the SDK namespace in kebab case, and the verb is the method name in kebab case, so keys.listRequests is nextmail keys list-requests. Together they cover the whole REST API.
nextmail domains listnextmail domains create --domain acme.comnextmail rules create --data @rule.jsonnextmail keys list-requests 9f2c1a4b7e05d3862c1f0a44 --failed-only --allnextmail files download file_6bb640f5b99e47deb758f1f5 --out report.pdf- An id the method takes is an argument, as in
nextmail domains get <id>. Each field of the request body is a flag named after it in kebab case:replyTois--reply-to, andcolor.backgroundColoris--color-background-color. - Three fields whose flag would clash with a global flag are renamed:
--template-version,--label-colorand--provider-key. The provider key, in--provider-keyand inprovider-imports inspect, also takes-for stdin or@pathfor a file, which keeps it out of your shell history. --datatakes the whole body as JSON, inline, from a file with@path, or from stdin with-, and any flag you pass as well overrides its key. A flag that takes an object reads JSON the same way.- Numbers and switches are read as such, and lists are comma separated or repeated.
- A missing required value is asked for in a terminal, and is a usage error (exit code
2) anywhere else. - A list verb reads one page.
--limitsets its size and--cursorcarries on from the cursor it printed.--allreads every page and streams the items,--max <n>stops after that many, and--ndjsonprints one JSON object per line. With--jsonit prints one{ items, hasMore, nextCursor }document,--allincluded. - Anything destructive, such as deleting, revoking, rotating, cancelling or emptying, asks you to confirm, unless you pass
--yes. - A download is written to the file in
--out, and to stdout only when stdout is not a terminal. - A table fits the terminal. When even the narrowest columns do not fit, the last ones are left out, and a note names them.
nextmail <namespace> <verb> --help shows each argument and flag with its type, the scopes the call needs, its method and path, what it returns, and the notes from the API reference.
Every namespace
Also lists the other names a namespace answers to.
| Namespace | Also | Verbs |
|---|---|---|
| me | get, ping, rotate, list-requests, list-activity, stats | |
| keys | key | list, get, create, update, delete, rotate, revoke, list-requests, list-activity, list-workspace-requests, list-workspace-activity, stats |
| addresses | address | list |
| languages | language | list |
| emails | email | send, send-batch, translate, check, list, get, list-events, get-tracking, cancel, reschedule, update, compose, rewrite, suggest-subject |
| templates | template | list, get, create, update, duplicate, replace-content, delete, list-versions, get-version, publish, restore-version, delete-version, list-starters, get-starter, list-fonts, render, preview, get-analytics, list-sends, send |
| tracking | list, get-stats, get, list-opens, list-clicks | |
| threads | thread | list, get, update, trash, snooze, unsnooze, list-attachments, list-notes, create-note, update-note, delete-note, reorder-notes, counts, summary, restore, delete, unsubscribe, get-event, reply-suggestions, mute, unmute, list-sender-categories, set-sender-category, clear-sender-category |
| drafts | draft | list, get, create, update, delete |
| labels | list, list-colors, get, create, update, delete, test | |
| contacts | contact | list, get, create, update, delete, set-audiences, list-people, save, delete-many, set-photo, remove-photo, block, unblock, list-threads, activity |
| audiences | audience | list, growth, get, create, update, delete, empty, list-contacts, add-contact, remove-contact, add-contacts, remove-contacts, import-contacts |
| forms | form | list, create, list-starters, get-starter, get, update, delete, publish, pause, resume, duplicate, analytics, list-submissions, get-submission, delete-submission, delete-submissions, approve-submission, resend-confirmation, subscribe, design, redesign |
| broadcasts | broadcast | preview, send, list, get, stats, list-recipients, get-recipient, cancel |
| domains | domain | list, get, create, verify, update, delete, get-logo, set-logo, remove-logo, set-logo-certificate, remove-logo-certificate, list-addresses, create-address, get-address, update-address, delete-address, set-address-photo, remove-address-photo, list-address-forwards, add-address-forwards, update-address-forward, delete-address-forward, resend-address-forward-consent, list-address-members, get-address-login, set-address-login, delete-address-login, get-mail-app-settings, list-app-passwords, create-app-password, delete-app-password, send-mail-app-setup, get-dns, set-dns-zone, sync-dns |
| rules | rule | list, get, create, update, delete, reorder, test, list-runs |
| webhooks | webhook | list, get, create, update, delete, rotate-secret, test, list-deliveries, get-delivery, replay-delivery, list-workspace-deliveries, list-activity, list-workspace-activity, list-events, stats |
| imports | import | list, get, create, upload-state, upload-chunk, start, cancel, list-failures, delete-upload, import-files |
| provider-imports | provider-import, providerImports | inspect, create, list, get, cancel |
| calendar | list-events, get-event, get-event-ics, create-event, update-event, delete-event, cancel-event, respond-to-event | |
| settings | setting | get, update |
| roles | role | list, get, create, update, delete, list-permissions |
| members | member | list, get, add, update, remove, grant-address, revoke-address, list-invitations, revoke-invitation, resend-invitation, grant-domain, revoke-domain |
| suppressions | suppression | list, get, add, remove |
| files | file | list, get, stats, download, list-links, create-link, revoke-link, revoke-all-links, upload, delete, delete-many |
| temp-mail | tempMail | list-domains, create, get, extend, delete, list-messages, get-message, delete-message, list-attachments |
| tools | check-dmarc, check-bimi, check-deliverability, check-address, check-addresses | |
| support | send | |
| encryption | list-keys, publish-key, lookup-keys | |
| chats | list, get, rename, delete | |
| exports | preview, list, get, start, download | |
| senders | get, research | |
| analytics | mailbox, sending | |
| subscriptions | list, list-domains, keep, unsubscribe, unsubscribe-many, unsubscribe-domain, move, move-many | |
| dns-connections | dnsConnections | list, get, delete |
| billing | get, list-plans, get-usage, list-alerts, list-countries, get-pay-as-you-go, set-pay-as-you-go, set-pay-as-you-go-limit, confirm-pay-as-you-go, start-checkout, open-portal, list-invoices, get-invoice, save-invoice-details, list-add-ons, start-add-on-checkout, cancel-add-on | |
| knowledge | list, levels, usage, search, create-note, add-link, upload-file, get, update, delete, refresh, stats, list-suggestions, accept-suggestion, dismiss-suggestion, list-flags, dismiss-flag, list-connectors, add-connector, get-connector, update-connector, delete-connector, sync-connector, draft-from-thread | |
| follow-ups | followUps | list, set, cancel |
| out-of-office | outOfOffice | list, set, clear |
| sending | list-streams, resume-stream, list-dedicated-ips, get-dedicated-ip | |
| signatures | list, get, create, update, delete, copy | |
| tasks | task | list, get, create, update, delete, pause, resume, run, list-runs, get-run, start-run, cancel-run, list-approvals, get-approval, approve, deny |
| connectors | connector | list-apps, get-app, list-categories, list, get, connect, update, disconnect, reconnect, list-actions, get-action, run-action, list-calls |
Each area has a page of its own, with every command in its namespaces, the scopes they need and worked examples. Every command is also on one page of its own, with the endpoint and scope of each.
Aliases
| Alias | For |
|---|---|
| ls | list |
| show, view | get |
| new, add | create |
| edit | update |
| rm, del, remove | delete |
| nextmail ls | nextmail inbox |
| nextmail show | nextmail read |
In members and suppressions, whose verbs are add and remove, new and create lead to add, and rm, del and delete lead to remove. A few hand-written subcommands have aliases of their own, which their help lists.
Any REST call
nextmail api <method> <path> sends one request to the REST API through the same transport as every other command, so your profile or key, token renewal and verification codes all apply. A path on its own is a GET. A JSON answer prints formatted, and a failed request prints the API error and exits with the matching code.
nextmail api /keys/selfnextmail api GET /threads --query folder=inbox --query limit=5nextmail api POST /labels --data '{"name":"Receipts"}'nextmail api PATCH /threads/CAHk7pQ2x9LmZ4 --data @patch.jsonnextmail api GET /files/file_6bb640f5b99e47deb758f1f5/content --out report.pdf-d,--datatakes the body as inline JSON, from a file with@path, or from stdin with-.-q,--queryand-H,--headertakekey=valueand can be repeated, and-o,--outsaves the answer to a file as it came.- The path is relative to the API origin. A full URL, a path that would leave the origin and an
Authorizationheader are refused with exit code2before anything is sent, because the CLI sets the credential itself. - A
DELETE, and any call a resource command would confirm, such as revoking or rotating a key, cancelling a send or sending a broadcast, asks you to confirm first. Unattended it stops with exit code2unless you pass--yes.
Help
nextmail --helpnextmail help sendnextmail domains --helpnextmail domains create --helpnextmail domains create --help --jsonnextmail --help lists every command by what it is for. A group lists its subcommands with examples, and a command shows everything it takes. nextmail docs open cli opens these pages.
Add --json to any of them and the same help prints as one JSON document, with every argument, flag, scope and example, for a script or an AI agent to read. The For AI agents page describes its fields.
Google Workspace