> ## Documentation Index
> Fetch the complete documentation index at: https://devs.izap.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Call the iZap REST API from a terminal with @izapai/cli.

`izap` lists chats, WhatsApp templates and broadcasts, and sends messages from a
terminal or a script. It uses the [TypeScript SDK](/en/api-reference/sdks).
`izap init` runs the [setup wizard](/en/api-reference/wizard).

| Package | Install | Source |
| - | - | - |
| CLI | `npm install -g @izapai/cli` | [versariai/izap-cli](https://github.com/versariai/izap-cli) |

Requires Node.js 20 or later. Create a [personal access token](/en/api-reference/authentication)
in the Dashboard under **User Settings → API Keys**.

## Install

```bash theme={null}
npm install -g @izapai/cli
izap --help
```

Or run once with `npx @izapai/cli whoami`.

## Log in

```bash theme={null}
izap login                           # prompts for the token (input is hidden)
izap login --browser                 # OAuth 2.0 authorization-code + PKCE
izap whoami                          # checks the saved credential
```

`izap login` saves the token without calling the API. `izap whoami` is the check.
`--browser` opens iZap's login page, registers a public OAuth client, and listens
on `127.0.0.1` at a random port. The session renews itself when the access token
expires. `izap logout` revokes it on the server.

The CLI saves credentials in `$XDG_CONFIG_HOME/izap/config.json`, or
`~/.config/izap/config.json` when `XDG_CONFIG_HOME` is not set. It creates the
directory with mode `0700` and the file with mode `0600`.

The CLI picks the token in this order:

1. The `IZAP_TOKEN` environment variable. It always wins.
2. The profile's saved token.
3. The profile's browser login.

```bash theme={null}
izap login --profile staging --staging            # https://api-staging.izap.ai
izap login --business 8f0b9e2a-...                # saves a default business
izap chats list --profile staging
```

The profile is `default` unless you pass `--profile` or set `IZAP_PROFILE`.

## Commands

| Command | What it does |
| - | - |
| `izap login [--token <t> \| --browser]` | Saves a credential for a profile |
| `izap logout` | Removes the saved credential (and revokes a browser login) |
| `izap whoami` | Shows the user, business and token the credential resolves to |
| `izap chats list` | Lists conversations (`--kind`, `--page`, `--page-size`, `--since`) |
| `izap messages send --chat <id> --text <t>` | Sends a WhatsApp message into a chat (asks you to confirm) |
| `izap templates list` | Lists WhatsApp message templates (`--status`) |
| `izap transmissions list` | Lists bulk transmissions (`--status`, `--limit`) |
| `izap transmissions show <id>` | Shows one transmission's status and counts |
| `izap init [args...]` | Runs the [setup wizard](/en/api-reference/wizard) |

`izap <command> --help` shows a command's flags. `--json` prints JSON on stdout.
`--business` / `IZAP_BUSINESS_ID` / the profile default pick the business.
`--staging` points at `https://api-staging.izap.ai`.

Sends are real. `izap messages send` asks before sending. Pass `--yes` to skip
the question. A script whose stdin is not a terminal must pass `--yes`.

> [!TIP]
>
> Prefer a typed client in your app? See [SDKs](/en/api-reference/sdks).
> Need a scaffold in an existing repo? `izap init` or `npx @izapai/wizard` —
> the [setup wizard](/en/api-reference/wizard).

[npm: @izapai/cli](https://www.npmjs.com/package/@izapai/cli)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.