Global Options
These options work with any command:| Option | Description |
|---|---|
--version | Print the CLI version |
--help | Display help |
init
Scaffold a newrevstack.config.ts and revstack/ directory structure in the current directory.
Usage
Options
| Option | Description | Default |
|---|---|---|
-t, --template <name> | Choose a starting template | starter |
Available Templates
- starter: Basic setup with a free default plan and a paid plan
- b2b-saas: Tiered pricing model for business software
- usage-based: Metered billing for API/infrastructure products
- ecommerce-platform: Transaction-based pricing
- developer-tools: Per-developer seat licensing
- ai-agent-platform: Token-based consumption pricing
Examples
Initialize with the default starter template:Behavior
- Checks if
revstack.config.tsalready exists (exits if found) - Creates a
revstack/directory with the following files:features.ts- Feature definitionsplans.ts- Plan definitionsaddons.ts- Add-on definitionscoupons.ts- Coupon definitionsindex.ts- Exports all entities
- Creates
revstack.config.tsthat imports and combines all entities - Detects your package manager (npm, yarn, or pnpm)
- Attempts to install
@revstackhq/coreautomatically
Output
login
Authenticate with your Revstack Secret Key and store credentials locally.Usage
Behavior
- Prompts for your Revstack Secret Key (input is hidden)
- Validates that the key starts with
sk_ - Saves the key to
~/.revstack/credentials.json
Output
Security
- Credentials are stored locally on your machine only
- The credentials file is created with appropriate permissions
- The secret key never leaves your machine except when making authenticated API calls
Getting Your Secret Key
- Log in to the Revstack Dashboard
- Navigate to Settings > API Keys
- Copy your Secret Key (starts with
sk_)
logout
Clear stored Revstack credentials from your machine.Usage
Behavior
- Checks if credentials exist
- Removes
~/.revstack/credentials.json
Output
If logged in:push
Push your local billing configuration to Revstack Cloud. This command validates your config, calculates a diff, and deploys changes after confirmation.Usage
Options
| Option | Description | Default |
|---|---|---|
-e, --env <environment> | Target environment | test |
Examples
Push to test environment (default):Behavior
- Authentication Check: Verifies you’re logged in
- Config Loading: Loads and parses
revstack.config.ts - Validation: Performs two-tier validation:
- Tier 1: Schema validation (correct structure, types, required fields)
- Tier 2: Business logic validation (valid feature references, pricing rules, etc.)
- Diff Calculation: Sends config to Revstack API to compute changes
- Change Preview: Displays color-coded diff with additions, removals, and updates
- Confirmation: Prompts for confirmation (especially prominent for production)
- Deployment: Applies changes to the target environment
Output
Production Warning
When pushing to production, you’ll see a prominent warning:Validation Errors
Schema errors:Blocked Pushes
Some changes are destructive and cannot be pushed (e.g., deleting a plan with active subscribers):pull
Pull the remote billing configuration from Revstack Cloud and overwrite your localrevstack.config.ts and revstack/ files.
Usage
Options
| Option | Description | Default |
|---|---|---|
-e, --env <environment> | Target environment | test |
Examples
Pull from test environment (default):Behavior
- Authentication Check: Verifies you’re logged in
- Fetch Remote Config: Downloads the current config from Revstack Cloud
- Schema Validation: Validates the remote config against the schema
- Summary Display: Shows what will be pulled (feature count, plan count, etc.)
- Confirmation: Asks for confirmation before overwriting local files
- File Generation: Regenerates all local config files from remote state
- Formatting: Runs Prettier to format the generated files (if available)
Output
Use Cases
Syncing dashboard changes:Generated Files
The pull command regenerates:revstack.config.tsrevstack/features.tsrevstack/plans.tsrevstack/addons.ts(if addons exist)revstack/coupons.ts(if coupons exist)revstack/index.ts
Environment Variables
The CLI respects the following environment variables:| Variable | Description | Default |
|---|---|---|
REVSTACK_API_URL | Override the Revstack API base URL | https://app.revstack.dev |
Example
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (validation failed, API error, etc.) |
Troubleshooting
”Not authenticated” error
Runrevstack login to authenticate with your secret key.
”revstack.config.ts already exists”
Theinit command won’t overwrite existing configs. Delete the file first or manually edit it.
Config validation fails
Check the error messages carefully:- Schema errors: Usually typos, missing required fields, or incorrect types
- Business logic errors: Invalid references between entities or conflicting settings
Push blocked
Some changes are destructive (e.g., deleting active plans). The error message will explain why and suggest alternatives.Pull overwrites local changes
Always commit your changes before runningpull. Review the diff with git diff before deploying.
Next Steps
- Configuration Guide - Learn how to configure plans, features, and pricing
- Environment Management - Best practices for managing multiple environments
- API Reference - Use the Revstack SDK in your application