CLI Reference

Reference

CLI Reference

7 min readUpdated April 2026

Installation

The StackBlaze CLI is distributed as an npm package. Install it globally to use the stackblaze command from anywhere.

terminal

# Install globally (requires Node.js 18+)

$ npm install -g @stackblaze/cli

# Or with pnpm

$ pnpm add -g @stackblaze/cli

# Verify installation

$ stackblaze --version

@stackblaze/cli 2.14.0

# Authenticate

$ stackblaze login

Opening browser for authentication...

Authenticated as alex@acmecorp.com

Global flags

FlagDescription
--project NAMETarget a specific project (overrides active project)
--token TOKENUse a specific API token (overrides stored credentials)
--output jsonOutput results as JSON instead of human-readable format
--no-colorDisable ANSI color codes (useful for CI environments)
--debugEnable verbose debug logging
--helpShow help for any command
--versionPrint the CLI version and exit

Authentication

stackblaze loginAuthenticate with your StackBlaze account (browser-based OAuth flow)
stackblaze login --sshAuthenticate using an SSH key pair (non-interactive)
stackblaze logoutLog out and revoke the local session token
stackblaze whoamiPrint the currently authenticated user and project

Deploying

stackblaze deployDeploy the current directory (requires stackblaze.yaml)
stackblaze deploy --service NAMEDeploy a specific service by name
stackblaze deploy --branch BRANCHDeploy a specific branch (overrides configured trigger branch)
stackblaze deploy --no-waitQueue the deploy and return immediately without streaming logs
stackblaze rollbackRoll back the current service to its previous successful deploy
stackblaze rollback --service NAMERoll back a specific service
stackblaze rollback --deployment IDRoll back to a specific deployment by ID

Logs

stackblaze logsStream live logs for the current service
stackblaze logs --service NAMEStream logs for a specific service
stackblaze logs --tail 100Show the last 100 lines then exit
stackblaze logs --since 1hShow logs from the past hour (supports: 1h, 30m, 2d)
stackblaze logs --level errorFilter to error-level log lines only

Environment variables

stackblaze env listList all environment variables for the current service
stackblaze env list --service NAMEList env vars for a specific service
stackblaze env set KEY=VALUESet a plain environment variable
stackblaze env set KEY=VALUE --secretSet a secret (encrypted, redacted in UI)
stackblaze env unset KEYRemove an environment variable
stackblaze env import .envImport all variables from a .env file

Services

stackblaze psList all running services and their status
stackblaze openOpen the current service URL in your browser
stackblaze open --service NAMEOpen a specific service URL
stackblaze run "COMMAND"Run a one-off command in a temporary container (same image as service)
stackblaze run --service NAME "COMMAND"Run a command in a specific service's container
stackblaze scale --replicas NScale a service to N replicas

Project

stackblaze initCreate a stackblaze.yaml configuration file in the current directory
stackblaze upApply a stackblaze.yaml blueprint to create or update services
stackblaze downDestroy all services defined in the local stackblaze.yaml
stackblaze statusShow the full status of all project services

Running one-off commands

stackblaze run spins up a temporary container using your service's current Docker image and runs the specified command inside it. The container is destroyed after the command exits. All environment variables configured for the service are injected.

One-off commands

# Run database migrations

$ stackblaze run --service my-api "npx prisma migrate deploy"

Running command in temporary container...

3 migrations applied successfully

# Open a Rails console

$ stackblaze run --service rails-app "rails console"

# Seed the database

$ stackblaze run --service my-api "node scripts/seed.js"

Using the CLI in CI/CD

In CI environments, authenticate using an API token rather than browser OAuth. Set the STACKBLAZE_TOKEN environment variable or pass --token to any command. All commands support --output json for machine-readable output.

# In your CI environment:

export STACKBLAZE_TOKEN=sb_live_xxxxxx

$ stackblaze deploy --service my-api --no-wait

$ stackblaze run --service my-api "npx prisma migrate deploy"