# The am CLI

Source: https://amanucci.com/docs/developers/cli

> Install and sign in to the am command-line client, and run Amanucci's task catalog as terminal commands.

`am` is the Amanucci command-line client. It is a client of the same `/v1` API as the web app: each domain command runs exactly one API operation.

## Requirements

Node.js 24.19.0 or newer.

## Point it at the API

Every command needs an explicit origin, from `--base-url` or the environment:

```bash
export AMANUCCI_BASE_URL=https://api.amanucci.com
```

## Sign in

```bash
am login
```

`am login` asks for your email, sends you a one-time code, and asks for the code with hidden input. It needs an interactive terminal: there is no flag or environment variable for the code, and no browser opens. The session is saved for that origin under `~/.config/amanucci` (or `AMANUCCI_CONFIG_DIR`), readable only by you.

Other account commands:

| Command | Does |
| --- | --- |
| `am step-up` | proves presence with a fresh code, for signed acts and creating a key (valid 15 minutes) |
| `am keys create` / `list` / `revoke` | manages your own API keys |
| `am auth forget` | removes the saved session from this machine |
| `am invite accept` | accepts an invitation in the terminal |

For scripts, set `AMANUCCI_API_KEY` instead of signing in. Set `AMANUCCI_HAT` to the seat you act in (see [Authentication](/docs/developers/authentication)).

## Commands are the task catalog

Domain commands have the shape `am <noun> <verb> [action]`. They are generated from the same task catalog the MCP server exposes. To see them all:

```bash
am --help
am books inspect --help
```

A few of the tasks:

| Command | Does |
| --- | --- |
| `am workspace inspect self` | your identity and your seats |
| `am documents exchange upload <file>…` | uploads one or more files |
| `am documents inspect list` | lists sales documents |
| `am matching inspect bank_transactions` | lists bank movements and their match status |
| `am matching review confirm` | confirms a proposed match |
| `am cases inspect requests` | lists the questions on an entity |
| `am filings prepare generate` | generates a filing from a locked period |
| `am filings sign` | signs a filing (session and step-up only) |

## Input and output

Request parameters go in one JSON object with `path`, `query` and `body` keys, passed with `--input <file>` or `--input -` for stdin. It is validated against the operation's schema before anything is sent.

```bash
echo '{"path":{"entityId":"0192f0c4-..."},"query":{"limit":50,"direction":"inbound"}}' \
  | am documents inspect list --input - --json
```

Without `--json`, results print as tables. With `--json`, one record is written to stdout with `operationId`, `status` and the unchanged `data`. Binary results, such as an invoice PDF, need `--output <file>`; an existing file is never overwritten.

## Uploading files

```bash
am documents exchange upload receipt.pdf invoice.pdf --input upload.json --json
```

with `upload.json`:

```json
{ "path": { "entityId": "0192f0c4-..." }, "body": { "kind": "pdf" } }
```

For each file, the command asks the API for an upload URL, sends the bytes straight to storage, and finalizes the file. Several files form one batch, and the batch id is printed. A file the books already hold is reported, not uploaded again. If a run stops partway, continue the same batch with `--batch <id>`. Nothing is retried automatically.

## Exit codes

| Exit | Meaning |
| --- | --- |
| 0 | success |
| 2 | the command, options or input were refused locally |
| 3 | the API refused the request (the problem is printed unchanged) |
| 4 | the request could not be sent |
| 5 | the response was not what the contract declares |
| 6 | a local file could not be read or written |
| 130 | interrupted |
