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

# Authentication & Configuration

> x402-only authentication, private key signing, environments, and configuration precedence for the Brickken CLI.

## x402-only model

The CLI is **x402-only**. It does not send an `x-api-key` header, and it ignores `BRICKKEN_API_KEY` / `BKN_API_KEY` if they are set. Preparing a transaction is free; the send is paid through x402:

1. The CLI prepares a transaction with `/prepare-transactions` (free).
2. On send, the API responds `402 Payment Required` with a `PAYMENT-REQUIRED` header.
3. The CLI signs the x402 payment locally and retries with an `X-PAYMENT` header.

In the recommended `brickken-relayed` mode the private key signs **only the x402 payment** — Brickken's relayer signs and broadcasts the operation. In the default `client-signed` mode the same key also **signs the blockchain transaction** locally.

<Warning>
  Your private key never leaves your machine. Treat it as a secret: prefer an `.env` file or environment variable over passing `--private-key` inline.
</Warning>

## Provide a private key

```bash theme={null}
export BRICKKEN_PRIVATE_KEY=0x...
```

`BKN_PRIVATE_KEY` is accepted as an alias.

## Environments and base URLs

Select the environment with `--env` or `BRICKKEN_ENV` (default: `sandbox`):

| Environment         | Base URL                           |
| ------------------- | ---------------------------------- |
| `sandbox` (default) | `https://api.sandbox.brickken.com` |
| `production`        | `https://api.brickken.com`         |

Override the base URL directly with `--base-url` or `BRICKKEN_BASE_URL` when needed.

<Note>
  The CLI's default sandbox base URL is `https://api.sandbox.brickken.com`. Some older API Reference pages show `https://api-sandbox.brickken.com` — use the value above for the CLI.
</Note>

## Networks and chain IDs

Pass the target chain with `--chain`. Both decimal and hex forms are accepted, and common decimal IDs are normalized automatically — for example Base Sepolia can be passed as `84532` or `14a34`.

| Network                   | Decimal    | Hex        |
| ------------------------- | ---------- | ---------- |
| Base mainnet              | `8453`     | `0x2105`   |
| Base Sepolia              | `84532`    | `0x14a34`  |
| Ethereum Sepolia (legacy) | `11155111` | `0xaa36a7` |

## RPC URL

Some commands (notably [`create-token`](/cli/commands/token-economics)) wait for the deployment receipt to read back the deployed `tokenAddress`. Set an RPC for the target chain:

```bash theme={null}
export BRICKKEN_RPC_URL="https://sepolia.base.org"   # Base Sepolia
```

`BKN_RPC_URL` is accepted as an alias, or use `--rpc-url`.

## Configuration precedence

Configuration is resolved in this order (highest priority first):

1. **Command-line flags** — `--env`, `--base-url`, `--private-key`, `--rpc-url`, `--env-file`, `--json`
2. **Environment variables** — `BRICKKEN_*` or `BKN_*`
3. **`.env` file** in the current working directory (or the path given by `--env-file`)
4. **Defaults** — `sandbox` environment, `client-signed` execution mode (pass `--execution-mode brickken-relayed` to opt into relayed)

### Global flags

| Flag                          | Description                                        |
| ----------------------------- | -------------------------------------------------- |
| `--env <sandbox\|production>` | Target Brickken environment                        |
| `--base-url <url>`            | Override the Brickken API base URL                 |
| `--private-key <key>`         | Private key for local signing and x402 payments    |
| `--rpc-url <url>`             | RPC URL used to wait for token deployment receipts |
| `--env-file <path>`           | Env file to load before resolving config           |
| `--json`                      | Print machine-readable JSON output                 |

### Environment variables

| Variable               | Alias             | Purpose                      |
| ---------------------- | ----------------- | ---------------------------- |
| `BRICKKEN_PRIVATE_KEY` | `BKN_PRIVATE_KEY` | Signing and x402 payment key |
| `BRICKKEN_BASE_URL`    | `BKN_BASE_URL`    | API base URL                 |
| `BRICKKEN_RPC_URL`     | `BKN_RPC_URL`     | RPC for receipt polling      |
| `BRICKKEN_ENV`         | `BKN_ENV`         | `sandbox` or `production`    |

## Budget note

Preparing is free; only the `send` is x402-priced. On Base Sepolia and other non-production environments the reference price is `0.01 USDC` per send. Fund the wallet behind `BRICKKEN_PRIVATE_KEY` with enough USDC on the x402 payment chain (Circle USDC `0x036CbD53842c5426634e7929541eC2318f3dCF7e` on Base Sepolia). See [Pricing](/api-reference/endpoint/agentic-pricing) for the mainnet per-operation table.
