Skip to content

CLI

The flockvm CLI

Install the flockvm command-line tool from npm, log in with an API key, and create, drive and SSH into VMs and environments from your terminal or scripts.

flockvm is the command line for flockvm. It does what the dashboard does with VMs, environments and your SSH keys, from a terminal or a script, and it sets up MCP clients such as Claude Code. It talks to the flockvm API with an API key.

npm install -g flockvm
flockvm login
flockvm vm create web-1 --wait
flockvm vm ssh web-1

The command is flockvm. It is never flock: that name belongs to util-linux's flock(1), the file-locking tool already on most Linux machines.

Install

The CLI needs Node.js 20 or later. It is one JavaScript file with no dependencies.

npm install -g flockvm
flockvm --version

npx flockvm runs the latest version without installing it, which suits CI jobs and one-off machines. To update a global install, run npm install -g flockvm again.

Log in

The CLI acts with an API key. A key belongs to one organization and one user, and acts as that user with their role in that organization at the time of each request: an admin's key can change environments, a member's key cannot. A key also has a scope: what it may do (a preset such as Create and use VMs, or actions one by one) and which environments and VMs it reaches. See API keys and scopes.

  1. Create an API key

    In the dashboard, open Settings → API keys. Give the key a name (the machine or job that uses it, such as laptop), pick when it expires (1 day, 7 days, 30 days, 90 days, 1 year, a date or never) and what it can do, and click Create key. The secret, flk_ and 40 characters, is shown once: copy it now.

  2. Save it with flockvm login

    flockvm login

    flockvm login offers to open the API keys page in your browser, then asks for the key without echoing it. It checks the key with the API before saving it:

    Logged in as Ana Duarte <ana@northwind.test>, admin of Northwind Labs, with the key laptop (flk_r4qhzk…).
    Saved to /home/ana/.config/flockvm/config.json.
  3. Check who you are

    flockvm whoami
    User          Ana Duarte <ana@northwind.test>
    Organization  Northwind Labs (northwind-labs)
    Role          admin
    API key       laptop (flk_r4qhzk…), expires 2027-01-30
    Key from      /home/ana/.config/flockvm/config.json
    API           https://flockvm.com

Where no one can type, read the key from standard input:

flockvm login --with-token < key.txt

Typed at a terminal instead of piped, --with-token reads the key hidden, like flockvm login.

flockvm logout forgets the saved key. The key itself keeps working until you revoke it in Settings → API keys. Owners and admins see and revoke every key of the organization there; members see and revoke their own. More on keys in API overview.

Configuration

flockvm login saves the key in ~/.config/flockvm/config.json ($XDG_CONFIG_HOME/flockvm/config.json when that variable is set). The file has mode 0600 in a 0700 folder: only you can read it.

Variable What it does
FLOCKVM_API_KEY The API key to use. It wins over the saved one: use it in CI and scripts.
FLOCKVM_API_URL The API's base URL, https://flockvm.com by default.
FLOCKVM_TIMEOUT How long one request may take, in seconds, 30 by default. Past it, the command fails with No answer from … after 30s.
XDG_CONFIG_HOME The folder that holds flockvm/config.json, ~/.config by default.
NO_COLOR No colours in the output. There are none when the output is not a terminal either.

The API URL comes from --api-url, then FLOCKVM_API_URL, then the one saved by flockvm login, then https://flockvm.com.

The CLI sends the key over https only. Plain http is allowed to this machine alone, for a local server: localhost, a *.localhost name, 127.0.0.1 or ::1. To reach another machine over http, open an SSH tunnel to localhost instead. There is no override: any other http:// URL is refused before a request is sent.

The key is your access

Anyone with the key can do what you can do in that organization, VMs and environments included. Keep it out of repositories and shell history: in CI, store it as a secret and expose it as FLOCKVM_API_KEY. Give each machine or job its own key with an expiry, so you can revoke one without the others.

Names and ids

Commands take a VM or an environment by id (vm_ceau36, env_intjph4v) or by name (web-1, staging). An SSH key is taken by id or by name too. VM names are 1 to 40 characters among lowercase letters, digits and dashes.

Help

Every command has its own help:

flockvm help
flockvm help vm create
flockvm vm create --help

The full list, with examples, is in Commands.

JSON output

Every command takes --json. The output is then the API's own JSON, the same fields as the API reference, with nothing else on standard output, so you can pipe it to jq:

flockvm vm list --json | jq -r '.vms[] | select(.status == "running") | .name'
flockvm vm get web-1 --json | jq -r .ssh.command

With --json, an error goes to standard error as one JSON line:

{"error":{"status":400,"code":"bad_request","message":"none is reserved: it means no environment.","field":"name"}}

status, code, message and field are the API's error; hint, when there is one, is the CLI's advice, such as how to log in again after a 401. An error the CLI finds itself has "code": "cli" (no such VM, a missing file, not logged in), a wrong command line "code": "usage". Without --json, the CLI prints the message, the status and the code, and for a refused key, how to log in again:

flockvm: This is not a valid flockvm API key. (401 unauthorized)
The key in FLOCKVM_API_KEY was refused: set a valid one (create it at https://flockvm.com/dashboard/settings/api-keys).

Exit codes

Code Meaning
0 Done.
1 Failed: the API refused (the message says why), the network, a missing file, a VM that failed while --wait waited for it, or a confirmation answered no.
2 Wrong usage: unknown command or option, a missing argument, or a confirmation needed where nobody can answer (add --yes).
other flockvm vm ssh exits with ssh's own code.

Next steps