Skip to main content
By the end of this page you will know every rail402 command, every global flag, the machine-readable --json shape, and how the CLI decides which facilitator to talk to. This is the reference for @rail402.dev/cli, which ships the rail402 binary.
CLI amounts are decimals in the asset’s units. --max 0.10 is 0.10 USDC. This is the opposite of the SDK, where amounts are atomic-unit strings.

Commands

Every paying command (buy, pay) requires an explicit --max cap. The cap is enforced on the request that is actually paid, immediately before signing, so a seller cannot quote cheap and charge dear. The CLI never spends an unbounded amount.

Global flags

Command options

--max is a decimal in the asset’s units, so --max 0.10 is 0.10 USDC. It is required on every paying command (buy, pay).
Supply the secret with the RAIL402_SECRET environment variable rather than --secret, so it never lands in your shell history. An agent cannot type an interactive password, so the environment variable is the path for automation.

The —json envelope

Pass --json to any command for a single structured object. It is the same envelope on success and on failure, so an agent can branch on ok.
On failure, error carries a machine-readable code, a non-null reason, and a retryable flag. Branch on code, never on the reason text. See Error registry. Common codes: mcp_budget_required (you omitted --max), mcp_budget_exceeded (price above the cap), config_no_signer (no RAIL402_SECRET).

Configuration precedence

Every endpoint defaults to Rail402’s hosted testnet infrastructure, and every one is overridable, so the same binary drives your own self-hosted facilitator or explorer. Precedence, highest first:
  1. a command-line flag (--facilitator, --network, …),
  2. an environment variable (RAIL402_SECRET, and the endpoint overrides),
  3. the saved config at ~/.rail402/config.json,
  4. the built-in default (https://facilitator.rail402.dev, stellar:testnet).

Next steps

Buyer quickstart

Fund, discover, and pay from the terminal.

SDK reference

The same operations as library calls.

Error registry

Codes that appear in the --json error object.

Packages

Where the CLI sits among the packages.