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

# AuthForge CLI: Manage Licenses From the Terminal

> Install the authforge command line, sign in by device pairing, and manage apps, licenses, webhooks and the authentication log from a terminal, a script or CI.

`authforge` is the command line for the [Developer API](https://docs.authforge.cc/api/overview.md). Run it with no arguments for a full-screen interactive mode, or with a command for one result and an exit code. Every command takes flags and prints JSON with `--json`, so the same tool works by hand and in a pipeline.

![The interactive mode: browsing apps, filtering licenses, issuing three new ones and watching the live log](https://mintcdn.com/authforgecc/k85XmHzKi1yXPwRm/images/cli/demo.gif?s=af084a5a243ad0fe40fb0adb7132f297)

The interactive mode, recorded against made-up data

It manages your account: apps, licenses, webhooks, logs. Checking a license inside your own software is the job of an [SDK](https://docs.authforge.cc/sdk/overview.md).

## Install

```bash theme={null}
npm install -g authforge
```

It needs Node.js 22.12 or later and runs in PowerShell and Windows Terminal, and in any terminal on macOS and Linux. To try it without installing, run `npx authforge`.

## Sign in

```bash theme={null}
authforge login
```

**1. The CLI shows a code and opens the pairing page**

The page is `app.authforge.cc/pair`. If no browser can be opened (over SSH, for example), the link is printed: open it on any device where you are signed in to the dashboard.

**2. You check the code and approve**

The page lists what the key will be allowed to do. Untick anything you do not want, choose how long the key lives (7, 30 or 90 days) and approve.

**3. The CLI stores the key**

It goes into the operating system's credential store: Windows Credential Manager, the macOS Keychain, or the Secret Service (GNOME Keyring, KWallet) on Linux. Where there is none, it goes into a file only your user account can read. The CLI says which one it used.

No password is typed in the terminal, and the whole key is never printed: `authforge whoami` shows its first characters, its scopes, when it expires and where it is stored. The key appears on the dashboard's **API Keys** page with a CLI badge and can be revoked there. `authforge logout` revokes it and removes it from the machine, and signing in again replaces it and revokes the old one.

### Scopes

A key from `authforge login` may read and write apps and licenses, read logs and read the account, unless you ask for something else:

```bash theme={null}
# Everything the CLI can do, including pausing and deleting apps, and webhooks
authforge login --scopes all

# A key that can only look
authforge login --scopes read

# What you have now, plus two scopes
authforge login --scopes +admin:apps,+write:webhooks
```

The scopes are the Developer API's [scopes](https://docs.authforge.cc/api/overview.md#scopes). Each command's `--help` names the ones it needs, and a command your key lacks the scope for fails with the scope's name and the `login` command that adds it.

## First commands

```bash theme={null}
authforge use "My Game"                  # the app the next commands work on
authforge licenses create --days 30      # issue a 30-day license
authforge licenses list --status active
authforge licenses show A3K9-BFWX-7NP2-QHDT
authforge licenses revoke A3K9-BFWX-7NP2-QHDT
authforge logs tail --failures           # watch failed authentications live
```

An app is given by its ID, its name, or the start of either, with `--app` or once with `authforge use`. `authforge <command> --help` describes every flag and gives examples.

![Three commands and their output: status, licenses create and logs search](https://mintcdn.com/authforgecc/k85XmHzKi1yXPwRm/images/cli/commands.png?fit=max\&auto=format\&n=k85XmHzKi1yXPwRm\&q=85\&s=3559e1497d05dabcea9220750bd1be93)

## Interactive mode

`authforge` on its own opens a full-screen view of your apps, each app's licenses, a live log, webhooks with their deliveries, and your account. Quitting leaves the terminal as it was.

![The apps screen: the list of apps on the left, the selected app's settings and last 24 hours on the right](https://mintcdn.com/authforgecc/k85XmHzKi1yXPwRm/images/cli/apps.png?fit=max\&auto=format\&n=k85XmHzKi1yXPwRm\&q=85\&s=c61f5d0c3602be6d911a73e931a86818)

| Key | Does |
| - | - |
| `↑` `↓` or `j` `k` | Move. `g` and `G` jump to the ends, `PgUp` and `PgDn` move a page |
| `Enter` | Open what is selected |
| `Esc` | Back |
| `/` | Filter the list |
| `?` | Every key on this screen |
| `a` | Account, key and sign-in |
| `q` or `Ctrl+C` | Quit |

Each screen lists its own keys in the bottom line: `n` creates, `r` revokes or reactivates a license, `e` extends it, `t` opens an app's live log, and so on. Anything destructive asks first, and deleting an app asks you to type its name. An action your key has no scope for is dimmed, and pressing it says which scope is missing.

The interactive mode needs a terminal. When output is piped or the CLI runs in CI, `authforge` with no arguments prints help instead.

## Commands

### Account

| Command | What it does |
| - | - |
| `login` | Pair this device. `--scopes`, `--name`, `--no-browser` |
| `logout` | Revoke the stored key and remove it |
| `whoami` | The key in use: scopes, expiry, where it is stored, and the account |
| `status` | Credit balance and every app's last 24 hours |
| `use [app]` | Set, show or `--clear` the default app |

### Apps

| Command | What it does |
| - | - |
| `apps list`, `apps show` | Your apps; one app's settings |
| `apps create <name>` | Create an app. Prints its secret, which is shown once |
| `apps delete` | Delete an app. Asks for its name; needs `write:apps` and `admin:apps` |
| `apps pause`, `apps unpause` | Refuse every validation until resumed. Needs `admin:apps` |
| `apps set` | Hourly and daily credit caps, self-serve offline activation |
| `apps stats`, `apps problems` | Usage over 24 hours or 7 days; recent failures grouped by license and reason |
| `apps vars get`, `set`, `unset` | [App variables](https://docs.authforge.cc/features/variables.md) |

### Licenses

| Command | What it does |
| - | - |
| `licenses list` | One page of an app's licenses; `--status`, `--all`, `--cursor` |
| `licenses show <key>` | Status, expiry, devices, variables |
| `licenses create` | `-n` up to 100 at once, `--days` or `--expires`, `--devices` or `--unlimited-devices`, `--label`, `--email` |
| `licenses revoke`, `activate` | Stop a license validating, or let it again. Take several keys |
| `licenses extend <key>` | `--days` adds to the current expiry; `--until` sets a date |
| `licenses reset-hwid` | Forget the bound devices. Takes several keys |
| `licenses set-devices`, `set-email` | Device limit; the customer's email for the [portal](https://docs.authforge.cc/features/portal.md) |
| `licenses delete` | Delete for good. Takes several keys |
| `licenses vars get`, `set`, `unset` | License variables |
| `licenses import <file>`, `import-undo <id>` | [Import existing keys](https://docs.authforge.cc/guides/import-licenses.md) from CSV; `--dry-run` first |
| `licenses offline mint`, `list`, `machines`, `release` | [Offline license files](https://docs.authforge.cc/features/offline-license-files.md) and self-activated machines |

An expiry cannot be removed through the API. `licenses extend --days` therefore refuses a license that never expires, and `--until` on one gives it an expiry for good.

### Logs

| Command | What it does |
| - | - |
| `logs tail` | The newest rows, then each new one as it arrives, until Ctrl+C. `--failures`, `--result`, `--license`, `--hwid`, `--ip`, `--since`, `--no-follow` |
| `logs search` | The last 90 days, newest first. `--from`, `--to` and the same filters |

`logs tail` keeps going through a dropped connection or a rate limit and picks up where it stopped. Rows appear about two seconds after the event.

### Webhooks and security

| Command | What it does |
| - | - |
| `webhooks list`, `create <url>`, `update`, `delete` | Manage an app's [webhooks](https://docs.authforge.cc/features/webhooks.md). `create` prints the signing secret once |
| `webhooks test` | Send a test event and report what the endpoint answered |
| `webhooks rotate-secret` | A new signing secret; the old one is accepted for 24 more hours |
| `webhooks deliveries`, `replay` | The last 14 days of deliveries; send one again, or every failed one in a range |
| `security list`, `block`, `unblock`, `allow`, `unallow` | An app's device and IP [lists](https://docs.authforge.cc/features/security.md) |

The webhook commands need the `read:webhooks` and `write:webhooks` scopes, which `authforge login` does not ask for by default: sign in with `--scopes +read:webhooks,+write:webhooks`.

### Everything else

| Command | What it does |
| - | - |
| `api <method> <path>` | An authenticated request to any Developer API route, for what the CLI has no command for. `--data`, `--query`, `--idempotency-key` |
| `completion <shell>` | A completion script for `bash`, `zsh`, `fish` or `powershell` |

```bash theme={null}
authforge api GET /v1/apps
authforge api POST /v1/licenses --data '{"appId":"...","quantity":1}'
```

## Scripts and CI

Set `AUTHFORGE_API_KEY` to a key created on the dashboard's **API Keys** page. Nothing is stored and no sign-in is needed.

```bash theme={null}
export AUTHFORGE_API_KEY=af_live_...
export AUTHFORGE_APP="My Game"

# 50 keys, one per line, into a file
authforge licenses create -n 50 --days 365 --label reseller-7 > keys.txt

# Revoke every license of one customer
authforge licenses list --all --json \
  | jq -r '.licenses[] | select(.email == "sam@example.com") | .licenseKey' \
  | xargs authforge licenses revoke --yes
```

What a script can rely on:

* **stdout carries the result and nothing else.** Progress, hints and errors go to stderr.
* **`--json`** prints one JSON document; `logs tail --json` prints one object per line. An error is then JSON on stderr: `{"error":{"code":"...","message":"...","hint":"...","status":403}}`.
* **Piped output is plain.** Tables become tab-separated lines with no header and no colour, and `licenses create` prints only the keys.
* **Nothing waits for an answer in a pipeline.** Without a terminal, a command that needs a confirmation fails and says to pass `--yes`.
* **Creating licenses is safe to retry.** The request carries an idempotency key, so a retry after a dropped connection never issues twice.
* **`--wait`** waits out a rate limit instead of failing.

The same properties let an AI coding agent run the CLI for you. [Developing with AI](https://docs.authforge.cc/guides/ai-development.md#let-an-agent-run-the-cli) covers the key to give it and a prompt to start from.

### Exit codes

| Code | Meaning |
| - | - |
| `0` | Done |
| `1` | Failed |
| `2` | Wrong usage: an unknown command or flag, a bad value |
| `3` | Not signed in, the key expired or was revoked, or a scope is missing |
| `4` | Not found |
| `5` | Rate limited, or a limit of the account was reached |
| `6` | Out of credits |
| `7` | AuthForge could not be reached, or is in maintenance |
| `130` | Interrupted with Ctrl+C |

### Flags for every command

| Flag | |
| - | - |
| `--json` | Print the result as JSON |
| `-y`, `--yes` | Answer yes to confirmations |
| `--no-input` | Never ask a question; fail instead |
| `--no-color` | Plain text, no colour |
| `-q`, `--quiet` | Results and errors only |
| `--wait` | When rate limited, wait and retry |
| `--debug` | Print each API request to stderr (never the key) |
| `-h`, `--help` | Help for the command |

### Environment variables

| Variable | |
| - | - |
| `AUTHFORGE_API_KEY` | Use this key instead of a stored sign-in |
| `AUTHFORGE_APP` | The app to work on when `--app` is not given |
| `AUTHFORGE_KEY_STORAGE` | Where `login` keeps the key: `keychain` or `file` |
| `AUTHFORGE_CONFIG_DIR` | Where settings are kept. Default: `%APPDATA%\authforge` on Windows, `$XDG_CONFIG_HOME/authforge` or `~/.config/authforge` elsewhere |
| `AUTHFORGE_ASCII` | Set to `1` to draw with plain ASCII characters |
| `NO_COLOR` | Turn colour off |

## Shell completion

```powershell PowerShell theme={null}
authforge completion powershell >> $PROFILE
```

```bash Bash theme={null}
authforge completion bash > ~/.local/share/bash-completion/completions/authforge
```

```bash Zsh theme={null}
authforge completion zsh > ~/.zfunc/_authforge
```

```bash Fish theme={null}
authforge completion fish > ~/.config/fish/completions/authforge.fish
```

## Troubleshooting

| The CLI says | What to do |
| - | - |
| Not signed in | Run `authforge login`. In CI, set `AUTHFORGE_API_KEY` |
| This key lacks a scope | Sign in again with it, for example `authforge login --scopes +write:webhooks`. For a dashboard key, create a new key with the scope ticked |
| Your key expired | Keys from `login` live 7, 30 or 90 days. Run `authforge login` again |
| Rate limited | Wait the time the message names, or pass `--wait`. The limits are in the [API overview](https://docs.authforge.cc/api/overview.md#rate-limits) |
| Out of credits | Buy more on the dashboard's credits page |
| Could not reach AuthForge | Check the connection and the [status page](https://authforge.cc/status/) |

> [!NOTE]
>
> The key file used where there is no credential store is `credentials.json` in the settings folder, readable by your user account only. Set `AUTHFORGE_KEY_STORAGE=file` to choose it on purpose, for example on a server without a keyring.

The source is at [github.com/AuthForgeCC/authforge-cli](https://github.com/AuthForgeCC/authforge-cli).


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