---
name: flowpayra-deploy
description: Deploy, configure and operate a self-hosted FlowPayra Lite crypto payment server (flowpayra-lite binary plus PostgreSQL) - Docker compose or binary install, config.toml and FLOWPAY_* variables, reverse proxy and public_url, the master key, the first admin, chains and RPC nodes, quote signer keys (local or KMS), merchant contract deployment and verification, tokens, payees and splits, hot wallet and gas sponsorship, webhooks and API keys, email, alerts and monitoring, backups, upgrades, key rotation, multi-instance roles and test mode. Use it whenever the user wants to install, self-host, deploy, configure, upgrade, back up, monitor or troubleshoot a FlowPayra Lite instance or set up its chains, contracts or keys, or mentions flowpayra-lite, its config.toml, deploy/.env, the master key, the signer key, the hot wallet or the admin console, even without saying "deploy". Not for writing a business system's integration code (orders, checkout redirects, webhook handlers) - that is the flowpayra-integration skill.
---

# Deploying and operating FlowPayra Lite

FlowPayra Lite is a self-hosted, self-custodial crypto payment server; one deployment serves one merchant. It is a
single binary, `flowpayra-lite`, plus PostgreSQL 15 or later, serving the hosted checkout, the business REST API and
the admin console (`/admin/`), and running one indexer per chain, a notifier, a relayer with the subscription
keeper, and scheduled jobs. Payers pay on EVM, TRON or Solana networks through the merchant's own contracts, which
split the funds straight to the payee addresses: the server never holds funds. What it does hold are keys: the
**master key** (encrypts every secret stored in the database), the **quote signer key** (its address is embedded in the
merchant contracts) and an optional **hot wallet** (pays sponsored gas and sends subscription charges).

The CLI's own help is authoritative for commands and flags: `flowpayra-lite --help` and
`flowpayra-lite <command> [<subcommand>] --help` (in Docker: `docker run --rm flowpayra-lite <command> --help`). Use only
flags the help shows. Every option of the configuration file is commented in `config.example.toml`.

## Who does what

You work from a shell and the files; the operator holds the secrets and the console. The console signs in with
passkeys or security keys bound to the site's host name, and every sensitive change needs a fresh step-up
verification bound to that one operation. That is deliberate: a stolen session, a leaked API key or a misbehaving
script (an agent included) cannot redirect funds or swap keys. So prepare those steps and explain them, but do not
try to automate them, call `/admin/api` yourself, or ask for passwords, passkeys, recovery codes or private keys.

| You can do | The operator does |
|---|---|
| Write `deploy/config.docker.toml` or `config.toml`, `docker-compose.yml`, the reverse proxy configuration, and the non-secret lines of `deploy/.env` | Type every secret value: keystore passwords, `POSTGRES_PASSWORD`, admin passwords, provider and KMS credentials |
| Build the image, start and restart services (on a live instance, with the operator's go-ahead), read logs | Create keystores (`cast wallet new` prompts for a password); copy the master key into their password manager |
| Probe `/healthz`, `/readyz`, `/metrics` | Sign in, enroll passkeys and a backup security key, keep the recovery codes |
| Read-only checks: `deploy inspect`, `deploy capabilities`, `tokens probe` (chain reads, no database); status commands `signer list`, `secrets status`, `kms list` (JSON without secrets; run them inside the deployment, e.g. `docker compose … exec app`, because like the server they first apply pending migrations) | Every step-up action in the console: chains and RPC endpoints, quote signer keys, **Verify and record**, tokens, payees and split rules, gas modes, webhooks, API keys, mail and alert channels, master key re-encryption, deleting test data |
| Set up backup jobs, metric scrapes and alert routing into their tools | Wallet transactions: deploying merchant contracts, funding the hot wallet, withdrawals |
| Write the exact console steps and commands for the operator, in order | Paste one-time secrets (API keys, `whsec_…` webhook secrets) straight into the business system's secret store |

Some console operations have CLI equivalents that act on the database directly (`signer generate`, `signer import`,
`signer verify`, `signer activate`, `apikey create`, `kms …`, `secrets reencrypt`; `deploy all` sends transactions).
They skip step-up verification and are audited as `cli`. Use them only when the operator explicitly picks that path
for that step, and let the operator run any command that prints or needs a secret.

## Deployment checklist

Go in order; each step points to the reference with the details.

1. **Plan.** The HTTPS host name(s): `public_url`, optionally a separate console host (`[admin] public_url`); Docker
   or binary; a testnet as the first network. → [install.md](references/install.md)
2. **Install.** `docker build -t flowpayra-lite .` (or the binary); PostgreSQL 15+ (compose ships `postgres:16`).
   → [install.md](references/install.md)
3. **Master key.** Generate it straight into the environment file (`deploy/.env`) without printing it; the operator
   backs it up offline **before the first start**. → [install.md](references/install.md#generating-the-master-key)
4. **Quote signer key.** A keystore at `deploy/keys/quote-signer.json` (adopted as the active key on the first
   start), or a key generated later in the console, or a KMS key.
   → [install.md](references/install.md#quote-signer-key-three-ways-to-start)
5. **Configure and start.** `deploy/.env` and the configuration file, then
   `docker compose --env-file deploy/.env up -d --build`. → [configuration.md](references/configuration.md)
6. **Reverse proxy.** TLS in front; `public_url` = the HTTPS address; `trusted_proxies` = the proxy's IP as the server
   sees it. Settle host names now, because passkeys enrolled later are bound to them.
   → [install.md](references/install.md#reverse-proxy-and-https)
7. **First admin.** The operator runs `flowpayra-lite admin create --username <name>` (password of 12+ characters from
   `FLOWPAY_ADMIN_PASSWORD` or standard input), signs in, enrolls a passkey plus a backup security key, stores the 10
   recovery codes, and sets a notification email under **Account security**.
   → [install.md](references/install.md#the-first-admin)
8. **Check the backups.** `secrets check-backup` for the master key copy; `signer export` and `signer check-backup`
   for each local quote signer key. → [operations.md](references/operations.md#backups)
9. **Each chain, testnet first.** Add it with at least 2 RPC endpoints (one `wss`); have an active quote signer key of
   its scheme; deploy and **Verify and record** the merchant contracts (Solana: the merchant account); list tokens;
   enable it. Merchant contracts can only be created where FlowPayra's shared contracts exist.
   → [chains-and-contracts.md](references/chains-and-contracts.md)
10. **Payees and a default split rule.** → [console-setup.md](references/console-setup.md#payees-and-split-rules)
11. **Hot wallet and gas modes**, for gas sponsorship or subscriptions (subscriptions always need it).
    → [console-setup.md](references/console-setup.md#hot-wallet-and-gas-sponsorship)
12. **Business system access.** A test API key with only the scopes it needs, the test webhook endpoint and its
    secret; live ones at go-live. → [console-setup.md](references/console-setup.md#api-keys-for-the-business-system)
13. **Merchant details, WalletConnect, email and receipts, alert channels and routing, risk screening.**
    → [console-setup.md](references/console-setup.md)
14. **Monitoring and backups.** Probes on `/healthz` and `/readyz`, `/metrics` with a token, database dumps plus WAL
    archiving, a restore drill. → [operations.md](references/operations.md)
15. **Smoke test in test mode** (below). Then repeat step 9 on mainnets and switch the business system to live
    credentials.

## Security rules

- **Keep secrets out of the conversation and out of command output.** Whatever you print lands in transcripts and
  logs. Secrets here: the master key, keystore files and their passwords, hot wallet and deployer keys, admin
  passwords and recovery codes, API keys, webhook secrets, KMS, SMTP and provider credentials, RPC URLs embedding an
  API key, the metrics token, the database password. Refer to them by variable name and let the operator put the
  values in place. Do not run commands that echo them (`cat deploy/.env`, `env`, `printenv`, `docker compose config`,
  `docker inspect`, `secrets keygen`), and never put one on a command line, where it reaches shell history and the
  process list.
- **Never commit secrets.** `deploy/.env`, `deploy/keys/*` and a root `config.toml` are git-ignored; keep it that way,
  keep secrets in the environment rather than in configuration files (`deploy/config.docker.toml` is tracked), and
  check `git status` before any commit.
- **Back up the master key offline before the first start.** The first start already seals data under it; without
  the key, everything it sealed (RPC URLs, webhook secrets, email addresses, stored signer keys, credentials) is lost
  for good. Keep the copy apart from database backups, verify it with `secrets check-backup`, and never generate a
  new key for an instance that has already started.
- **Keep each backup apart from what unlocks it:** database dumps apart from the master key, signer keystore backups
  apart from their passwords.
- **One key, one job.** The hot wallet is a different key from the quote signer and holds only a small balance.
  Contract deployments are paid from a throwaway key holding only the gas; the deployer gets no rights over the
  contracts.
- **Least privilege for API keys.** One key per system, only the scopes it uses (`risk:*` only when needed), test keys
  (`fpk_test_…`) while integrating. Leave the **Split whitelist** on, so even a leaked key cannot send funds to
  unregistered addresses.
- **Test first.** Start on a testnet in test mode: testnets accept test orders only and mainnets live orders only, so
  nothing real moves while you rehearse.
- **HTTPS and settled host names before passkeys.** Passkeys are bound to the host of `public_url` (or
  `[admin] public_url`); moving hosts later leaves admins with keys that no longer work.
- **Do not remove what live subscriptions still need.** A retired quote signer key still cancels subscriptions on its
  contracts: keep it, its backup, and any KMS key with its permissions until they have all ended.
- **Production stays locked down:** `[diag] enabled = false`; `/metrics` only with a token of 16+ characters; offer
  the operator dual approval (**Security & access → Approvals**) once there are two admins.
- **Leave FlowPayra's shared contracts alone.** Merchants create only their own merchant contracts. If the console
  reports the shared contracts missing on a network, stop and ask the operator how to proceed.

## Verify it works

1. Liveness and readiness (both on the public listener):

   ```sh
   curl -fsS https://pay.example.com/healthz     # ok
   curl -fsS https://pay.example.com/readyz
   ```

   `/readyz` answers 503 (`"status": "unavailable"`) only when the database is down. Otherwise 200 with `"status"`
   `ready` or `degraded`, and per-part detail: `chains[].rpc` (`ok` / `down`), `walletconnect`, `signer.status` (`ok`,
   `no_active_key`, `key_not_loaded`, `key_unavailable`, `chains_without_clones`) and `hot_wallets`. Whatever is not
   healthy points at the step to revisit.
2. A test order, with a **test** API key the operator placed in an environment variable:

   ```sh
   curl -fsS -X POST "$FLOWPAY_BASE_URL/v1/orders" \
     -H "Authorization: Bearer $FLOWPAY_TEST_API_KEY" \
     -H "Idempotency-Key: smoke-1" -H 'Content-Type: application/json' \
     -d '{"merchant_order_no":"SMOKE-1","amount":"1.00","currency":"USD"}'
   ```

   The `201` response carries `id` and `checkout_url`. The operator opens the link with a testnet wallet holding a
   listed test token and pays. Expected: the checkout shows **Payment complete**; with the console switched to
   **Test**, the order is **Confirmed** under **Payments → Orders**; `GET /v1/orders/{id}` returns `"status": "paid"`;
   if a test webhook is set, **Developers → Webhooks** lists `order.paid` as **Delivered**.
3. With metrics enabled:
   `curl -fsS -H "Authorization: Bearer $FLOWPAY_METRICS_TOKEN" https://pay.example.com/metrics | head`.

Common startup failures (missing master key, a keystore password variable not set, data sealed under an unconfigured
master key, wrong `trusted_proxies`) are listed with fixes in
[operations.md](references/operations.md#startup-errors-and-their-causes).

## References

Load only what the current step needs:

- [references/install.md](references/install.md) — installing: docker compose files and `deploy/.env`, which variables
  reach the container, the binary, PostgreSQL, generating the master key and the quote signer keystore without
  exposing them, the reverse proxy (Caddy and nginx, one or two host names), the first admin, a local devnet trial.
- [references/configuration.md](references/configuration.md) — editing `config.toml` or `FLOWPAY_*` variables: each
  operator-facing key with its default and variable name, where each secret goes, the console listener, database pool
  sizing, roles and multi-instance deployments.
- [references/chains-and-contracts.md](references/chains-and-contracts.md) — adding a network: chain families, where
  the shared contracts exist, RPC endpoints, quote signer keys (local and KMS), deploying and verifying merchant
  contracts (console or CLI), TRON and Solana specifics, tokens, enabling a chain.
- [references/console-setup.md](references/console-setup.md) — the console steps after the chains: payees and split
  rules, hot wallet and gas sponsorship, API keys and webhooks, merchant and checkout settings with WalletConnect,
  email and receipts, alert center, risk screening, team and dual approval, plans.
- [references/operations.md](references/operations.md) — running it: health, readiness, metrics, logs and alerts;
  backups and restore drills; upgrades; master key, quote signer key and hot wallet rotation; admin recovery;
  incidents; test mode and deleting test data; startup errors.

Further sources: https://docs.flowpayra.com/en/start/deployment/ and the other pages under
https://docs.flowpayra.com/en/ (everything in one file: https://docs.flowpayra.com/llms-full.txt); in the repository,
`config.example.toml`, `deploy/config.docker.toml`, `docker-compose.yml`, and `docs/RUNBOOK-KEY-ROTATION.md` (key
rotation and recovery drills, in Chinese). For the business system's code, use the `flowpayra-integration` skill.
