A beautiful terminal CLI for the FlexPrice usage-based billing platform. Manage customers, plans, subscriptions, invoices, meters, events, wallets, features, and entitlements β all from your terminal. Includes an interactive TUI dashboard built with Ratatui.
- Prerequisites
- Installation
- Authentication
- Commands
- Configuration
- Global Options
- JSON Output
- Project Structure
- License
- Rust toolchain (1.70+) β install via rustup
- Access to the FlexPrice API (default base URL:
https://api.cloud.flexprice.io)
git clone https://github.com/flexprice/flexprice-cli.git
cd flexprice-cli
cargo build --releaseThe binary will be at target/release/flexprice. You can copy it to a directory in your $PATH:
cp target/release/flexprice /usr/local/bin/cargo run -- <COMMAND>Before using most commands, configure an API key. The default API URL is https://api.cloud.flexprice.io.
flexprice auth set-api-key <YOUR_API_KEY>
# Override the API URL (optional):
flexprice auth set-api-key <YOUR_API_KEY> --api-url https://api.cloud.flexprice.ioThe key is validated against the API before being stored.
flexprice auth status # Show credentials & test API connection
flexprice auth whoami # Show current user details
flexprice auth logout # Remove stored credentials| Command | Description |
|---|---|
auth set-api-key <KEY> |
Store an API key (default URL: cloud API) |
auth whoami |
Show authenticated user info |
auth status |
Show auth status & test connection |
auth logout |
Remove stored credentials |
| Command | Description |
|---|---|
customers list |
List all customers |
customers get <ID> |
Get a customer by ID |
customers create --json <FILE> |
Create a customer from a JSON file |
customers delete <ID> |
Delete a customer |
customers usage <ID> |
View customer usage summary |
customers entitlements <ID> |
View customer entitlements |
Example β create a customer:
cat > customer.json << 'EOF'
{
"name": "Acme Corp",
"email": "billing@acme.com",
"external_id": "acme-001"
}
EOF
flexprice customers create --json customer.json| Command | Description |
|---|---|
plans list |
List all pricing plans |
plans get <ID> |
Get a plan by ID |
plans create --json <FILE> |
Create a plan from a JSON file |
plans delete <ID> |
Delete a plan |
| Command | Description |
|---|---|
subscriptions list |
List all subscriptions |
subscriptions get <ID> |
Get a subscription by ID |
subscriptions create --json <FILE> |
Create a subscription from a JSON file |
subscriptions cancel <ID> |
Cancel a subscription |
subscriptions usage --json <FILE> |
Query subscription usage |
| Command | Description |
|---|---|
invoices list |
List all invoices |
invoices get <ID> |
Get an invoice by ID |
invoices finalize <ID> |
Finalize a draft invoice |
invoices void <ID> |
Void an invoice |
invoices pdf <ID> |
Download invoice as PDF |
Download a PDF:
flexprice invoices pdf inv_abc123 --output ./invoice.pdf| Command | Description |
|---|---|
meters list |
List all meters |
meters get <ID> |
Get a meter by ID |
meters create --json <FILE> |
Create a meter from a JSON file |
meters delete <ID> |
Delete a meter |
| Command | Description |
|---|---|
events ingest --json <FILE> |
Ingest a single event |
events ingest-bulk --json <FILE> |
Bulk ingest events |
events list |
List recent events |
events get <ID> |
Get an event by ID |
events usage --json <FILE> |
Query event usage |
Example β ingest an event:
cat > event.json << 'EOF'
{
"event_name": "api_call",
"external_customer_id": "acme-001",
"properties": {
"tokens": 150,
"model": "gpt-4"
}
}
EOF
flexprice events ingest --json event.json| Command | Description |
|---|---|
wallets list |
List all wallets |
wallets get <ID> |
Get a wallet by ID |
wallets create --json <FILE> |
Create a wallet from a JSON file |
wallets top-up <ID> --json <FILE> |
Top up a wallet |
wallets balance <ID> |
Get real-time wallet balance |
| Command | Description |
|---|---|
features list |
List all features |
features get <ID> |
Get a feature by ID |
features create --json <FILE> |
Create a feature from a JSON file |
features delete <ID> |
Delete a feature |
| Command | Description |
|---|---|
entitlements list |
List all entitlements |
entitlements get <ID> |
Get an entitlement by ID |
entitlements create --json <FILE> |
Create an entitlement from a JSON file |
entitlements delete <ID> |
Delete an entitlement |
flexprice configDisplays the current configuration: API URL, masked API key, environment ID, and credentials file path.
flexprice dashboardLaunches an interactive terminal dashboard powered by Ratatui. Navigate between panels showing customers, subscriptions, invoices, and more using keyboard controls.
| Key | Action |
|---|---|
Tab / Shift+Tab |
Switch between panels |
β / β |
Navigate lists |
r |
Refresh data |
q / Esc |
Quit |
Credentials are resolved in the following priority order (highest β lowest):
| Priority | Source | Details |
|---|---|---|
| 1 | CLI flags | --api-url, --api-key |
| 2 | Environment variables | FLEXPRICE_API_URL, FLEXPRICE_API_KEY, FLEXPRICE_ENVIRONMENT_ID |
| 3 | .env file |
Loaded from the current working directory |
| 4 | Credentials file | ~/.flexprice/credentials.json |
export FLEXPRICE_API_URL=https://api.cloud.flexprice.io
export FLEXPRICE_API_KEY=fp_live_xxxxxxxxxxxx
export FLEXPRICE_ENVIRONMENT_ID=env_prodOr use a .env file in your working directory:
FLEXPRICE_API_URL=https://api.cloud.flexprice.io
FLEXPRICE_API_KEY=fp_live_xxxxxxxxxxxx
FLEXPRICE_ENVIRONMENT_ID=env_prodThese flags can be used with any command:
--api-url <URL> Override the API base URL
--api-key <KEY> Override the API key
--help Show help for any command
--version Show CLI version
Most list and get commands support a --json flag to output raw JSON instead of formatted tables:
flexprice customers list --json
flexprice invoices get inv_abc123 --jsonflexprice-cli/
βββ Cargo.toml # Dependencies & build config
βββ src/
β βββ main.rs # CLI entry point & command routing
β βββ api/
β β βββ client.rs # HTTP client (reqwest-based)
β β βββ models.rs # API request/response types
β βββ cli/
β β βββ auth.rs # Authentication commands
β β βββ customers.rs # Customer management
β β βββ plans.rs # Plan management
β β βββ subscriptions.rs# Subscription management
β β βββ invoices.rs # Invoice management
β β βββ meters.rs # Meter management
β β βββ events.rs # Event ingestion & queries
β β βββ wallets.rs # Wallet & credit management
β β βββ features.rs # Feature management
β β βββ entitlements.rs # Entitlement management
β βββ config/
β β βββ store.rs # Credential storage & resolution
β βββ tui/
β β βββ dashboard.rs # Interactive TUI dashboard
β β βββ theme.rs # TUI color theme
β βββ utils/
β βββ output.rs # Table/JSON formatting & colored output
β βββ spinner.rs # Loading spinners
βββ target/ # Build output (gitignored)
MIT