# CLI

The Inboxjot CLI sends email, verifies domains and manages contacts, templates, campaigns and webhooks from your terminal. It installs as `inboxjot`, with the short alias `ij`.

## Log In

```sh
inboxjot login
```

The CLI opens your browser. Pick a workspace and the access the CLI gets, then approve. The CLI saves the login in the OS keychain, and every command uses it within the access you approved.

Each login shows in Connected Apps in the dashboard, one row per computer, such as “Inboxjot CLI on riti-thinkpad”. Open the row to change its access. `inboxjot logout` revokes the login, and so does Disconnect in Connected Apps.

`inboxjot whoami` shows the profile, the workspace and the key in use.

## Send an Email

```sh
inboxjot send --from "Acme <hi@acme.com>" --to jane@example.com --subject "Hello" --text "It works"
```

| Option           | Use                                                         |
| ---------------- | ----------------------------------------------------------- |
| `--html-file`    | Reads the HTML body from a file.                            |
| `--template`     | Sends a published template. Add `--data` for its variables. |
| `--attach`       | Attaches a file. Repeat it for more files.                  |
| `--scheduled-at` | Sends later, such as `"in 10m"` or an ISO 8601 time.        |
| `--wait`         | Waits until the email is delivered or fails.                |
| `--dry-run`      | Prints the request body and sends nothing.                  |

`inboxjot emails inspect <id> --wait` follows an email that is already sent.

## Test Addresses

Email to `inboxjot.dev` is never sent. Inboxjot simulates the result and sends the usual webhook events. Test sends count toward your sending limits like any other email. They do not affect your stats or sender reputation.

| Address                   | Result     |
| ------------------------- | ---------- |
| `delivered@inboxjot.dev`  | Delivered  |
| `bounced@inboxjot.dev`    | Bounced    |
| `complained@inboxjot.dev` | Complained |

Any other address on `inboxjot.dev` is delivered. Add a label to tell tests apart, such as `bounced+signup@inboxjot.dev`.

## Listen for Webhooks

```sh
inboxjot listen --forward-to localhost:3000/webhooks
```

`listen` streams live events from your workspace and posts each one to your local URL. You need no public URL and no endpoint in the dashboard. Each request is signed like a real webhook. `inboxjot listen --print-secret` prints the signing secret for your local code.

In a second terminal, cause an event:

```sh
inboxjot trigger email.bounced
```

`trigger` takes `email.sent`, `email.delivered`, `email.bounced`, `email.complained`, `contact.created`, `contact.updated` and `contact.deleted`. Add `--events` to `listen` to show only some types.

## Local Development

```sh
inboxjot init
```

`init` creates a sending key for the project and saves it to `.env.local`. To test without sending real email, send to a [test address](#test-addresses).

`inboxjot doctor` checks the key, the clock, the API, SMTP and every domain.

## Output

stdout holds only the result. Tables, IDs and JSON go to stdout. Progress, hints and errors go to stderr.

```sh
id=$(inboxjot send --from hi@acme.com --to jane@example.com --subject Hi --text Hello)
inboxjot emails list --json
inboxjot domains list --jq '.data[].name'
```

`--json` prints the API response unchanged and turns off prompts. `--jq` filters the JSON with a jq expression. When an AI agent runs the CLI, the output is JSON by default.

`inboxjot api` calls any API route with your credentials:

```sh
inboxjot api /v1/domains --paginate
```

## Agents

When an agent such as Claude Code runs the CLI, or you add `--non-interactive`, prompts are off and a failure prints one JSON object on stdout. The exit code stays the same.

```json
{
  "status": "action_required",
  "reason": "confirmation_required",
  "message": "Delete the domain acme.com? Add --yes to confirm.",
  "next": [
    {
      "command": "inboxjot domains delete acme.com --yes",
      "description": "Run the command again after the user approves it"
    }
  ]
}
```

| Field     | Meaning                                                                                                                                                   |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`  | `action_required` when the command must change or the user must act first, such as missing input, a confirmation or a login. `error` for everything else. |
| `reason`  | A stable code, such as `not_logged_in`.                                                                                                                   |
| `message` | A sentence for people.                                                                                                                                    |
| `next`    | Commands to run next. Empty when there is none.                                                                                                           |

Run a `next` command that adds `--yes` only after the user approves it.

## Safety

Ordinary writes do not ask. Destructive actions ask `(y/N)`. Sending a campaign or erasing a contact asks you to type its name. Without a terminal, these actions fail until you add `--yes`.

A write is retried only when the server did not receive it, so a retry never runs it twice.

## CI and Profiles

In CI, set `INBOXJOT_API_KEY`. It takes priority over the saved login.

```sh
INBOXJOT_API_KEY=ibx_… inboxjot send --from hi@acme.com --to jane@example.com --subject Hi --text Hello
```

To save a key without the browser, pipe it in:

```sh
inboxjot login --api-key - < key.txt
```

A profile keeps a second login, such as another workspace. Add `--profile staging` to any command, or set `INBOXJOT_PROFILE`.

| Variable              | Use                                                    |
| --------------------- | ------------------------------------------------------ |
| `INBOXJOT_API_KEY`    | API key. Overrides the saved one.                      |
| `INBOXJOT_PROFILE`    | Profile to use. The default is `default`.              |
| `INBOXJOT_CONFIG_DIR` | Config directory. The default is `~/.config/inboxjot`. |
| `INBOXJOT_GUIDANCE=0` | Hides next-step hints.                                 |
| `NO_COLOR`            | Turns color off.                                       |

> The keychain holds the login. If no keychain is available, the CLI saves it to
> `credentials.toml` in the config directory, readable only by you.

## Commands

Every command has a reference page with its options and examples. Add `--help` to any command for the same details in the terminal.

| Group       | Commands                                                                                                                                                                                                                                                                                                                                                                        |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Get Started | [`login`](https://inboxjot.com/docs/cli/login.md), [`logout`](https://inboxjot.com/docs/cli/logout.md), [`whoami`](https://inboxjot.com/docs/cli/whoami.md), [`init`](https://inboxjot.com/docs/cli/init.md), [`doctor`](https://inboxjot.com/docs/cli/doctor.md)                                                                                                               |
| Sending     | [`send`](https://inboxjot.com/docs/cli/send.md), [`emails`](https://inboxjot.com/docs/cli/emails.md), [`domains`](https://inboxjot.com/docs/cli/domains.md), [`templates`](https://inboxjot.com/docs/cli/templates.md), [`images`](https://inboxjot.com/docs/cli/images.md)                                                                                                     |
| Audience    | [`contacts`](https://inboxjot.com/docs/cli/contacts.md), [`segments`](https://inboxjot.com/docs/cli/segments.md), [`brands`](https://inboxjot.com/docs/cli/brands.md), [`topics`](https://inboxjot.com/docs/cli/topics.md), [`events`](https://inboxjot.com/docs/cli/events.md), [`suppressions`](https://inboxjot.com/docs/cli/suppressions.md)                                |
| Marketing   | [`campaigns`](https://inboxjot.com/docs/cli/campaigns.md), [`automations`](https://inboxjot.com/docs/cli/automations.md)                                                                                                                                                                                                                                                        |
| Developers  | [`api-keys`](https://inboxjot.com/docs/cli/api-keys.md), [`webhooks`](https://inboxjot.com/docs/cli/webhooks.md), [`listen`](https://inboxjot.com/docs/cli/listen.md), [`trigger`](https://inboxjot.com/docs/cli/trigger.md), [`logs`](https://inboxjot.com/docs/cli/logs.md), [`stats`](https://inboxjot.com/docs/cli/stats.md), [`api`](https://inboxjot.com/docs/cli/api.md) |
| Tools       | [`agent`](https://inboxjot.com/docs/cli/agent.md), [`open`](https://inboxjot.com/docs/cli/open.md), [`completion`](https://inboxjot.com/docs/cli/completion.md), [`help`](https://inboxjot.com/docs/cli/help.md)                                                                                                                                                                |

`list` has the alias `ls`, and `delete` has `rm`.

## Global Options

These options work with every command.

| Option                     | Description                                                                     |
| -------------------------- | ------------------------------------------------------------------------------- |
| `--json`                   | Print JSON on stdout and never prompt.                                          |
| `--jq <EXPR>`              | Filter JSON output with a jq expression.                                        |
| `--profile <PROFILE>`      | Use the credentials saved under this name. Default: `default`.                  |
| `-y, --yes`                | Confirm destructive actions without a prompt.                                   |
| `--non-interactive <BOOL>` | Never prompt; missing input fails and names the option. One of `true`, `false`. |
| `--no-color`               | Print without color.                                                            |
| `-d, --debug`              | Print each API request on stderr.                                               |

## Exit Codes

| Code  | Meaning                                       |
| ----- | --------------------------------------------- |
| `0`   | Success, including an empty list.             |
| `1`   | The operation failed.                         |
| `2`   | Usage error, or a confirmation is required.   |
| `3`   | Not logged in, or the login lacks the access. |
| `130` | Canceled.                                     |
