Fawran
CLI

Commands

Reference for all Fawran CLI commands

CLI Commands

Choosing an environment

Every command that talks to the API needs to know which environment to target. The CLI never guesses — it resolves the mode from, in order:

  1. --mode sandbox or --mode live
  2. the FAWRAN_MODE environment variable
  3. the API key prefix: fawran_sk_test_… → sandbox, fawran_sk_live_… → live

With a legacy (unscoped) key and no --mode, the command exits with code 2 and tells you what to pass. If --mode contradicts the key's scope the command also refuses to run — before making any request.

--prod still works as a deprecated alias for --mode live.

Shared options

OptionDescription
--mode <mode>sandbox or live. Also FAWRAN_MODE.
--key <api-key>API secret key. Also FAWRAN_SECRET_KEY, else the key stored by fawran connect.
--config <path>Path to fawran.config.ts (defaults to the usual names in the current directory).
--jsonPrint exactly one JSON document on stdout — no spinners, colours or prompts.

FAWRAN_API_URL overrides the host for the selected mode (self-hosted / local API).

Exit codes

CodeMeaning
0Success, including "nothing to do"
1The operation failed (API error, network error, sync rejected)
2Usage or configuration error (missing key or mode, key/mode mismatch, no config file)
3diff --exit-code found differences

In --json mode failures are JSON too: { "ok": false, "error": { "code", "message", "hint?" }, "exitCode" }.

init

Scaffold fawran.config.ts from your sandbox catalog. Runs connect first if no key is stored.

npx @copto/fawran-cli init

connect

Link the CLI to your organization through the browser. One approval issues a sandbox key and a live key; commands pick the one matching --mode.

npx @copto/fawran-cli connect

sync

Push your local catalog to the selected environment. Shows the diff and asks for confirmation unless --yes is passed.

npx @copto/fawran-cli sync --mode sandbox
npx @copto/fawran-cli sync --mode live --yes

Options:

  • --dry-run: Show what would change without applying.
  • --yes: Apply without the interactive prompt. Required together with --json.

CI example — preview, then apply:

FAWRAN_SECRET_KEY=$SANDBOX_KEY npx @copto/fawran-cli sync --dry-run --json
FAWRAN_SECRET_KEY=$SANDBOX_KEY npx @copto/fawran-cli sync --yes --json

--json output:

{
  "ok": true,
  "command": "sync",
  "mode": "sandbox",
  "apiUrl": "https://sandbox.fawran.copto.org/api/v1",
  "dryRun": true,
  "hasChanges": true,
  "applied": false,
  "changes": {
    "plans": { "added": ["pro"], "removed": [], "changed": [] },
    "features": { "added": [], "removed": [], "changed": [] },
    "creditSystems": { "added": [], "removed": [], "changed": [] },
    "creditPacks": { "added": [], "removed": [], "changed": [] },
    "total": 1
  }
}

When changes are applied the document also carries "applied": true and the server's result (plans, features, creditSystems, creditPacks, warnings).

pull

Write the remote catalog for the selected environment into your local config.

npx @copto/fawran-cli pull --mode sandbox

Options:

  • --force: Overwrite an existing config file without asking.
  • --dry-run: Print the generated config without writing it.

diff

Compare your local config with the remote catalog.

npx @copto/fawran-cli diff --mode live
npx @copto/fawran-cli diff --mode live --exit-code   # exit 3 on drift, for CI

Options:

  • --exit-code: Exit with code 3 when the catalogs differ.

validate

Validate fawran.config.ts locally and confirm the selected environment is reachable with your key.

npx @copto/fawran-cli validate --mode sandbox

On this page

Ask about fawran

Ready

Start a new chat below.