---
title: "The CLI"
description: "The command-line interface, @doorman/inbox-cli (doorman): signing in through the browser or with a key, connecting an agent, subcommands mirroring the API resource groups, terminal tables and piped JSON, and live event streaming."
url: https://doorman.fyi/docs/cli
markdown: https://doorman.fyi/docs/cli.md
area: "SDKs and tools"
section: "Command line"
---

# The CLI

The command-line interface, @doorman/inbox-cli (doorman): signing in through the browser or with a key, connecting an agent, subcommands mirroring the API resource groups, terminal tables and piped JSON, and live event streaming.

Source: https://doorman.fyi/docs/cli

## Installation and signing in

> Note: The CLI is not on a package registry yet, so installing it from one does not work today. Until the first release, build and run it from the repository as below. See [Installing the packages](https://doorman.fyi/docs/sdk.md#install).

`@doorman/inbox-cli` provides the `doorman` executable for managing inboxes, reading threads, sending mail, inspecting deliveries and tailing the live event stream from a terminal or a shell script. From a checkout of the repository:

Shell:
```sh
pnpm install
pnpm --filter "@doorman/inbox-cli..." build

# Until the first release, the built program stands in for the doorman command
alias doorman="node $PWD/packages/inbox-cli/dist/bin.js"

# Sign in through the browser; the sign-in is kept in your user config directory (mode 0600)
doorman login --base-url "https://api.doorman.fyi"

# Check the active account, plan and what the sign-in may do
doorman me
```

`doorman login` opens the browser on the same approval screen an agent uses: you sign in, read what the command line asks for and choose `Allow access`. No key is created. Without `--scope` it asks for [the default agent permissions](https://doorman.fyi/docs/connect.md#permissions); `--scope` with a space-separated list asks for the ones you name. `--no-browser` prints the address to open instead of opening it, for a browser on the same machine. `doorman whoami` shows the caller and the account it acts for: a person's own or an [organization's](https://doorman.fyi/docs/organizations.md#me), and for a console session the member's role and permissions. `doorman logout` removes the sign-in and the saved configuration from this machine; the connection stays listed under [Agents](https://doorman.fyi/console/connect) until you disconnect it there or it goes unused.

A sign-in holds the permissions you approved, so a command that needs another one answers `403 insufficient_scope`, and the error prints the `doorman login --scope` line that adds it. Custom domains and API keys are not open to a sign-in at all. The sign-in renews itself while it is used. If you disconnect it in the console, the next command says that the sign-in has ended and asks you to sign in again.

A key and a sign-in are not held to a member's role in an organization. A console session given as the credential is: a command its role does not cover answers `403 permission_denied`, and the error names the missing permission and what it allows.

Automation uses a key instead: `--api-key` or `DOORMAN_API_KEY`, with the origin in `--base-url` or `DOORMAN_API_URL`. A key given either way takes precedence over a browser sign-in, and CI can use the two variables without writing a file. A browser sign-in is kept in `credentials.json` and a key saved with `doorman login --api-key` in `config.json`, both in `~/.config/doorman/` (or `$XDG_CONFIG_HOME/doorman/`) with `0600` file permissions.

## Commands mirror the resource groups

The CLI organizes its commands into the same resource groups as [`@doorman/inbox-sdk`](https://doorman.fyi/docs/sdk.md) and tests its command tree against `publicSurface()` from `@doorman/inbox-api`, covering all 84 public operations. Every path parameter becomes a positional argument and every query or body field becomes a kebab-case flag. [The CLI command reference](https://doorman.fyi/docs/cli/commands.md) lists every command with its flags, and [Signing in, connecting and the local server](https://doorman.fyi/docs/cli/commands/session.md) the commands that are not an operation:

Shell:
```sh
# Issue an inbox with a webhook and an inbox-scoped key in one call
doorman inboxes create --mailbox-name concierge --display-name "Acme concierge" --webhook-url "https://agent.example.com/hooks/doorman" --key '{"name":"Acme concierge"}'

# List unread threads in an inbox and read a thread's messages
doorman inboxes threads list inb_01jc4q7w9k2m5n8p3r6t1v4x7z --is-read false
doorman threads messages thr_01jc5a1b2c3d4e5f6g7h8j9k0m

# Send a new message or reply in a thread with an idempotency key
doorman inboxes send inb_01jc4q7w9k2m5n8p3r6t1v4x7z --to sam@example.com --subject "Thursday" --text "Thursday works."
doorman inboxes send inb_01jc4q7w9k2m5n8p3r6t1v4x7z --thread-id thr_01jc5a1b2c3d4e5f6g7h8j9k0m --text "Thanks, confirming for Thursday." --idempotency-key order-2847-reply

# Create a non-mail rule and read its execution history with an account key
doorman inboxes rules create inb_01jc4q7w9k2m5n8p3r6t1v4x7z --name "Invoice triage" --when '{"subjectContains":"invoice"}' --then '[{"type":"label","label":"billing"}]'
doorman inboxes rules runs inb_01jc4q7w9k2m5n8p3r6t1v4x7z rul_01jc5f1a2b3c4d5e6f7g8h9j0k
doorman inboxes threads list inb_01jc4q7w9k2m5n8p3r6t1v4x7z --label billing

# Download a raw RFC 822 message or an attachment's extracted text
doorman messages raw msg_01jc5a6g7h8j9k0m1n2p3q4r5s > message.eml
doorman attachments text msg_01jc5a6g7h8j9k0m1n2p3q4r5s invoice.pdf
```

- `doorman inboxes`: `create`, `list`, `get`, `update`, `delete`, `send`, plus nested `keys`, `webhook`, `threads`, `messages` and `rules` subcommands. Use `list --external-id` for your own identifier and `send --thread-id` to reply.
- `doorman threads`, `messages`, `attachments`: Read and update threads (`get`, `messages`, `update`, `trash`), inspect messages and download their `raw` or `html` bodies, and fetch attachment bytes (`download`) or `text`.
- `doorman events`: `list` to page back through the log, `list --after` to read forward from a `seq` cursor, `get` to inspect one event and its deliveries, and `tail` to stream live events over the WebSocket.
- `doorman webhooks`, `deliveries`: Create, list, update, rotate secrets for, test and delete account endpoints; list and `retry` individual webhook deliveries.
- `doorman domains`: `list`, `create --name`, `get`, `verify` and `delete` for the account's custom domains, with an account key. App tokens are refused, and automatic DNS setup stays in the console.
- `doorman services`: `list`, `get`, `update` and `delete` for the [passport](https://doorman.fyi/docs/passport.md), plus `doorman inboxes services create <inboxId> --domain` to declare a sign-up and `doorman inboxes verifications list <inboxId> --domain --wait-seconds` to wait for its code. Connected sign-ins may list services, declare sign-ups and read codes; `get`, `update` and `delete` need an API key.
- `doorman me`, `metrics`, `health`, `openapi`: Inspect the authenticated caller and account, query usage metrics over a range, check service health, or print the deployment's OpenAPI 3.1 document.
- `doorman connect`: List the agents a connection is documented for, with the ones found on this machine marked. `doorman connect <id>` shows one agent's steps and, once you confirm, carries them out: [From the Doorman command line](https://doorman.fyi/docs/connect.md#command-line).
- `doorman mcp`: Start the local [Model Context Protocol stdio server](https://doorman.fyi/docs/mcp.md#connect-stdio) on the command line's sign-in or key, for an agent that can only launch a program.
- `doorman apps`, `doorman installs`: Session-only app management and installation revocation. API keys and app tokens are refused; these commands do not approve consent. Use [Apps in the console](https://doorman.fyi/console/apps) for the normal registration and consent flow.

## Terminal tables and piped JSON

When standard output is an interactive terminal (TTY), `doorman` formats responses as compact tables and key-value summaries so a person can scan them quickly. When standard output is piped to another program, or when `--json` is passed explicitly, every command emits the API's exact JSON response so scripts and `jq` pipelines never have to parse human-formatted tables.

Piping JSON to jq:
```sh
# Emit structured JSON automatically when piped, or force it with --json
doorman inboxes list --json | jq '.data[] | {id, address}'

# Poll forward from sequence 1042 and extract the next sequence number
NEXT_SEQ=$(doorman events list --after 1042 | jq -r '.latestSeq')
```

> Note: When a command creates or rotates a `dm_` key or a `whsec_` signing secret, the CLI prints the one-time secret in full so you can capture it before it leaves view.

## Streaming live events with events tail

`doorman events tail` connects to [the WebSocket stream](https://doorman.fyi/docs/stream.md) (`GET /v1/ws`), subscribes to the account's events or the `--inbox-id` values you pass, and sends keepalive pings. With a key it is one connection: it exits when the connection closes, and `--last-event-id` resumes it. An interactive terminal shows a typed summary for every [event type](https://doorman.fyi/docs/events.md#types); when piped or run with `--json`, it writes newline-delimited JSON (NDJSON), one event object per line.

Shell:
```sh
# Watch all inboxes on the account in real time
doorman events tail

# Resume from a known event id for one inbox and pipe each event as NDJSON
doorman events tail --inbox-id inb_01jc4q7w9k2m5n8p3r6t1v4x7z --last-event-id evt_01jc5e5f6g7h8j9k0m1n2p3q4r --json
```

- Pass `--inbox-id <id>` (repeatable) to narrow the subscription to specific inboxes.
- Pass `--event-type <type>` (repeatable) to select event types; omission includes all types visible to the key.
- Pass `--last-event-id <evt_...>` to replay missed events from the log before switching to the live feed.
- Send `SIGINT` (`Ctrl-C`) to close the WebSocket cleanly and exit with status `0`.

On a browser sign-in the watch needs the `events:read` permission, which the default sign-in does not ask for: sign in with `--scope` to add it. The API closes a stream when the access token it was opened with runs out, so `events tail` renews the sign-in, connects again and asks for the events after the last one it printed. The watch goes on for as long as the sign-in lasts, and ends with a message when it has ended.
