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

# CLI

> Manage your Waffo Pancake stores, products, discounts and webhooks from the terminal — built for humans and AI agents alike

The Waffo Pancake CLI (`pancake`) wraps the Merchant API in one command-line tool. Use it interactively, in scripts, or hand it to an AI coding agent: every command is discoverable as JSON, every write can be previewed offline, and nothing irreversible happens without an explicit confirmation flag.

> [!NOTE]
>
> **Release candidate.** The CLI ships as `@waffo/pancake-cli` on npm's `next` channel (currently `0.0.1-rc.2`). There is no stable release yet; Homebrew installation arrives with the first stable version. Node.js 22.14 or newer is required.

## Install

```bash npm (global) theme={"system"}
npm install -g @waffo/pancake-cli@next
pancake --version
```

```bash npx (no install) theme={"system"}
npx @waffo/pancake-cli@0.0.1-rc.2 --help
```

Pin an exact version for automation. To update within the release-candidate channel, rerun the install command.

## Log in

### Browser login (recommended)

```bash theme={"system"}
pancake login
```

The CLI prints a short code and opens the Dashboard sign-in page. Check that the page shows the same code and the account you expect, then click **Authorize CLI**. Only approve a login you started yourself — the authorization expires after 15 minutes.

Browser login starts in **Test**. Switch environments explicitly; the CLI verifies access before saving the selection:

```bash theme={"system"}
pancake whoami
pancake env test
pancake env prod
```

Browser sessions cover day-to-day business operations in Test and Production within your existing merchant and store permissions. They cannot manage API Keys, payout or bank details, other devices, or read webhook `secret` fields. Active CLI sessions are listed under **Dashboard → Settings → Security**; `pancake logout` revokes the session on the server and clears local credentials.

### API Key login

For CI and unattended scripts, log in with a Merchant ID and the RSA private key from **Dashboard → API & Development → API Keys**:

```bash theme={"system"}
chmod 600 /absolute/path/key.pem
pancake login --merchant-id MER_xxx --private-key-file /absolute/path/key.pem
```

Use `pancake login --key-login` for a hidden interactive prompt. The CLI stores only the key's absolute path. The Test or Production environment is determined by which key you use — `env` is not available for API Key sessions.

Automation can inject credentials through environment variables instead of a saved login: set `WAFFO_MERCHANT_ID` plus exactly one of `WAFFO_PRIVATE_KEY_FILE` or `WAFFO_PRIVATE_KEY`. A complete pair overrides the saved login; a partial pair fails.

Configuration lives in `~/.waffo-pancake/config.json` (`%USERPROFILE%\.waffo-pancake\config.json` on Windows). Set `WAFFO_CONFIG_DIR` to use another directory.

## Everyday commands

Every command accepts `--json` for a single machine-readable envelope; piped output switches to JSON automatically.

| Area | Commands |
| - | - |
| Identity | `whoami`, `env test\|prod`, `doctor`, `config show`, `logout` |
| Stores | `stores list`, `stores get`, `stores create`, `stores update`, `stores delete` |
| Products | `products list`, `products get`, `products versions`, `products create`, `products update`, `products publish`, `products set-status` — all take `--type onetime\|subscription` |
| Subscription groups | `groups create`, `groups update`, `groups delete`, `groups publish` |
| Orders & payments | `orders list`, `subscriptions list`, `subscriptions cancel`, `payments list`, `payments get` |
| Refunds | `refunds list`, `refunds get`, `refunds create`, `refunds resubmit`, `refund-tickets list` |
| Discounts | `coupons list\|get\|create\|update\|deactivate`, `promotion-codes list\|create\|generate\|deactivate` |
| Checkout & customers | `checkout create`, `sessions create` (customer session tokens, API Key login only) |
| Webhooks | `webhook list\|add\|update\|remove` (Test webhooks only), `listen` |
| Notifications & safety | `recipients list\|add\|update\|remove`, `content scan` |
| Data | `graphql query`, `analytics query` (read-only, single operation) |
| Local | `commands`, `schema <command.id>`, `operations list\|show`, `diagnostics export` |

A few examples:

```bash theme={"system"}
pancake stores list --limit 20 --fields id,name,status --json
pancake products list --type onetime --store-id STO_xxx --json
pancake payments list --json
pancake coupons list --store-id STO_xxx --json
```

Lists return one page at a time (`--limit`, `--offset`); filters go in a JSON file via `--file`.

## Writing data safely

Writes follow the same pattern: describe the input in a JSON file, preview it offline, then execute with an explicit confirmation.

**1. Read the input contract**

```bash theme={"system"}
pancake schema products.create --json
```

`schema` prints the fields, flags, output protocol and an example for any command. Monetary amounts are **decimal strings** such as `"19.99"`.

**2. Preview with --dry-run**

```json product.json theme={"system"}
{
  "storeId": "STO_xxx",
  "name": "Pro plan",
  "prices": { "USD": { "amount": "19.99", "taxCategory": "saas" } }
}
```

```bash theme={"system"}
pancake products create --type onetime --file product.json --dry-run --json
```

A dry run validates locally: no credentials, no network, no operation record.

**3. Execute with --yes**

```bash theme={"system"}
pancake products create --type onetime --file product.json --yes \
  --idempotency-key MER_xxx_product_001 --json
```

Pass your own `--idempotency-key` so a retried script never creates duplicates. The CLI sends each write exactly once and records it locally; `operations show <id>` shows what happened.

### Confirmation flags

| Flag | Required when |
| - | - |
| `--yes` | Any write |
| `--confirm-production` | Writing in Production, and for `products publish` / `groups publish` (they copy Test data **to Production**) |
| `--confirm-shared` | Store and notification-recipient changes — these resources are shared between Test and Production |
| `--output <new file>` | `checkout create`, `sessions create`, `graphql query`, `analytics query` — URLs, tokens and full query results are written to a new private file instead of stdout |

> [!WARNING]
>
> `products update` replaces the **whole price table**. To change one currency, include every currency you want to keep. Omit `prices` entirely to leave prices untouched.

### Outcomes

| `meta.outcome` | Meaning |
| - | - |
| `completed` | Done. Product creation and Test-webhook changes are verified by reading the resource back; other actions verify the response only. |
| `rejected` | The server refused the request; nothing was written. |
| `unknown` | The request may have been applied. Inspect `operations show` and query the resource — do **not** replay with a new idempotency key. |
| `committed_unverified` | The server accepted the write but read-back, export or local record failed. Query the resource; do not repeat the write. |

Exit codes: `0` success, `1` execution or verification failure, `2` input or configuration error, `130` interrupted.

## Forward webhooks to localhost

Test your webhook handler without a public URL. After browser login:

```bash theme={"system"}
pancake listen --store-id STO_xxx --forward-to http://localhost:3000/webhook
pancake listen --store-id STO_xxx --forward-to http://localhost:3000/webhook \
  --events order.completed,subscription.created --json
```

`listen` opens a temporary session and forwards each event with its original body, `X-Waffo-Signature` and `X-Waffo-Event` headers, so your handler verifies signatures exactly as in production — see [Webhooks](https://docs.waffo.ai/guides/webhooks.md). It always starts in Test; add `--live` to listen in Production. A 2xx from your handler acknowledges delivery; other responses retry up to three times. Ctrl+C cleans up the session, and nothing is changed on your configured webhooks.

## Using the CLI with AI agents

The CLI is designed to be driven by coding agents such as Claude Code, Codex or Cursor:

* `pancake commands --json` lists every command; `pancake schema <command.id> --json` returns its input contract. Agents never have to guess flags.
* `--dry-run` lets an agent validate a plan before anything touches your account, and `--yes` keeps the decision to write with you.
* `--no-interactive` fails fast on missing input instead of prompting.
* The package ships a `SKILL.md` agent reference — [read it on jsDelivr](https://cdn.jsdelivr.net/npm/@waffo/pancake-cli@0.0.1-rc.2/SKILL.md).

Prefer a one-line setup? The Dashboard's **API & Development → AI** tab gives you a prompt that installs the [Pancake Skill](https://docs.waffo.ai/integrate/skill.md) or the CLI for your store.

## Limits of the release candidate

* Webhook `add` / `update` / `remove` work on **Test** webhooks only.
* `sessions create` requires API Key login.
* `listen` requires browser login and cannot trigger synthetic events.
* There is no `orders get`, `subscriptions get` or group read command; use `graphql query` for anything not covered.
* Product writes reject `taxIncluded` — prices are always tax-exclusive.

## Reference

> [card] [Usage guide](https://cdn.jsdelivr.net/npm/@waffo/pancake-cli@0.0.1-rc.2/docs/usage.md)
>
> Full walkthrough of every command, shipped with the package.

> [card] [API coverage matrix](https://cdn.jsdelivr.net/npm/@waffo/pancake-cli@0.0.1-rc.2/docs/api-coverage.md)
>
> Which command calls which endpoint, with its verification mode.

> [card] [Source on GitHub](https://github.com/waffo-com/waffo-pancake-cli)
>
> MIT-licensed. Issues and contributions welcome.

> [card] [Merchant API reference](https://docs.waffo.ai/api-reference/introduction.md)
>
> The REST actions and GraphQL the CLI is built on.


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