CTRLctrl docs

CLI

ctrl is CTRL's command-line client. It needs Node.js 22.18 or later and has no runtime dependencies.

Install#

The CLI isn't published to npm yet. Build it from the repository:

cd ctrl-cli
npm install && npm run build
npm link

npm link puts ctrl on your PATH.

Log in#

ctrl login

ctrl login asks for an API key with a hidden prompt. If stdin is piped, it reads the first line instead. It checks the key against the API, then saves it to ~/.config/ctrl/config.json, readable only by you (mode 600). The key is never printed.

To log in without a prompt, for example in CI:

CTRL_API_KEY=ctrl_... ctrl login

Commands#

Command What it does
ctrl login Save and verify your API key
ctrl ps List your apps
ctrl deploy Redeploy an app, or create one from an image
ctrl logs Show recent logs for an app
ctrl env Get or set environment variables
ctrl rollback Redeploy an earlier successful deploy

Every command takes --help. Add --json for machine-readable output.

ctrl ps#

ctrl ps [--json]

Lists each app's id, status, region and URL.

ctrl deploy#

ctrl deploy <app>

Redeploys the app with its current environment variables. A Git-sourced app is rebuilt from its branch; an image app re-pulls its image. The result says redeployed: true or redeployed: false with the reason.

An app from a private registry image can't be redeployed, because registry credentials aren't stored.

ctrl deploy --image <ref> --name <name> --region <region> --port <n> \
  [--repo <r>] [--branch <b>] [--vcpu 1] [--mem 2048] [--disk 30720]

With --image, creates a new app from a container image. --name, --region and --port are required:

Flag Meaning Default
--image Image reference, such as ghcr.io/acme/api:1
--name Display name
--region Region to run in, such as us-east
--port Port your app listens on
--repo Repository name used to build the app's id the --name
--branch Branch name used to build the app's id main
--vcpu vCPUs 1
--mem Memory in MB 2048
--disk Disk in MB 30720

If the first deploy is still running when the API answers, the CLI waits for it to finish (up to an hour), then prints the app's URL.

ctrl logs#

ctrl logs <app> [--tail 100] [--json]

Shows the last lines of the app's log: 100 by default, at most 1000. --follow isn't supported, because the API only serves a one-time tail.

ctrl env#

ctrl env get <app> [KEY] [--json]
ctrl env set <app> KEY=VALUE ... [--stdin] [--json]

get prints every variable, or just KEY.

set adds or changes the variables you pass and keeps the rest. Then it redeploys the app and reports whether the redeploy happened.

With --stdin, set reads KEY=VALUE lines from stdin so secrets stay out of your shell history. Blank lines and lines starting with # are skipped:

printf 'DB_PASS=...\n' | ctrl env set my-app --stdin

Key names must start with a letter or underscore and contain only letters, digits and underscores.

set reads the current variables, merges in yours, and writes the whole set back. Two people setting variables on the same app at the same moment can overwrite each other's change.

See Environment variables.

ctrl rollback#

ctrl rollback <app> [--to <deploy-id>] [--json]

Redeploys the commit of the previous successful deploy, or the deploy you name with --to. It works only for Git-sourced apps, and only for deploys with a recorded commit.

Settings#

Variable Effect
CTRL_API_KEY Use this key instead of the saved one
CTRL_API_URL API base URL. Default: https://api.getctrl.dev

Output and exit codes#

  • Any failure exits with status 1, including a redeploy that reports redeployed: false.
  • Errors print as error: <message> on stderr. With --json, they print as {"error": "..."} on stderr instead.
  • A rejected key prints an error telling you to run ctrl login with a valid key.