Skip to content

CLI Reference

@tenantscale/cli provides command-line tools for initializing your TenantScale project, running migrations, and managing tenants. It is the primary interface for administrative operations.

Overview

The TenantScale CLI lets you:

  • Initialize a new TenantScale project with database migrations
  • Run & roll back database schema migrations
  • Create, list, and inspect tenants
  • Generate and revoke API keys
  • Sync subscription plans to Stripe
  • Purge old audit log entries

Commands

CommandDescriptionSource
initInitialize TenantScale and create database tablesdocs
migrateRun or roll back database migrationsdocs
create-tenantCreate a new tenantdocs
list-tenantsList all tenants (table or JSON output)docs
get-tenantGet details for a specific tenantdocs
create-api-keyGenerate a new API key for a tenantdocs
revoke-api-keyRevoke an existing API keydocs
stripe:syncSync subscription plans to Stripe products/pricesdocs
audit:purgePurge expired audit log entriesdocs

Using npx vs Global Install

npx (No Install Required)

Run any command without installing:

bash
npx @tenantscale/cli init
npx @tenantscale/cli list-tenants
npx @tenantscale/cli create-tenant --name "Acme Corp"

Use npx for one-off commands or CI/CD pipelines.

Global Install

Install once for repeated use:

bash
npm install -g @tenantscale/cli
tenantscale init
tenantscale list-tenants

Use the global install for local development workflow.

Source

The CLI is part of the TenantScale monorepo:

@tenantscale/cli
├── src/
│   ├── commands/        # Command implementations
│   │   ├── init.ts
│   │   ├── migrate.ts
│   │   ├── create-tenant.ts
│   │   ├── list-tenants.ts
│   │   ├── get-tenant.ts
│   │   ├── create-api-key.ts
│   │   ├── revoke-api-key.ts
│   │   ├── stripe-sync.ts
│   │   └── audit-purge.ts
│   ├── config.ts        # Config file loading
│   ├── db.ts            # Database connection
│   └── utils.ts         # Shared utilities
├── package.json
└── tsconfig.json

Source: github.com/TenantScale/sdk/tree/main/packages/cli

Getting Started

bash
# Quick start with npx
npx @tenantscale/cli init

# Or install globally
npm install -g @tenantscale/cli
tenantscale init

Configuration

The CLI needs a connection to your Supabase database. Configure it via:

  1. Config file.tenantscalerc (JSON or YAML) in your project root
  2. Environment variablesSUPABASE_URL and SUPABASE_SERVICE_KEY
  3. .env file — Auto-loaded from the current directory

See CLI Configuration for full details.

Global Options

OptionAliasDescription
--config-cPath to config file
--env-ePath to .env file
--json-jOutput as JSON (machine-readable)
--help-hShow help for a command
--version-VShow CLI version

Command Documentation

Detailed documentation for each command is available:

Version

bash
npx @tenantscale/cli --version
# or
tenantscale --version

Current stable version: 1.0.0


Source: github.com/TenantScale/sdk/tree/main/packages/cli

Released under the MIT License (SDK) and BSL 1.1 (API).