Skip to main content
1

Start the login

Run the login command in your terminal:
The CLI shows a short code and opens the authorization page in your browser.
2

Approve in the browser

Type the code on the page and approve. The CLI receives its own API key, no copy and paste needed, and saves it on this machine.
Output
A key issued this way has only the permissions the CLI’s commands use and expires after 90 days. auth whoami shows the date; run squarecloud auth login again to renew it. The key is saved in a config.json file readable only by you: in %APPDATA%\Square Cloud CLI on Windows, and in $XDG_CONFIG_HOME/squarecloud or ~/.config/squarecloud on macOS and Linux.

squarecloud auth login

Usage
Output with an API key
  • Press Ctrl+C to cancel a login that is waiting for approval.
  • If this machine is already logged in to another account, auth login asks before replacing it. Pass -y to skip the question.
  • If your account has reached its API key limit, the browser login says so and continues on its own as soon as you revoke a key in the dashboard.
  • Without a terminal, the command doesn’t prompt: it exits with a hint. With CI=true, the browser login refuses to run. See CI and scripts.

squarecloud auth whoami

Usage
Shows the account you are logged in as, its plan and how many days are left before the plan expires. For a key issued by the browser login, it also shows when the key expires and its scopes; when the key comes from SQUARECLOUD_API_KEY, it says so instead.
Output
With --json, it prints the account (ID, name, email, locale, plan and creation date) as JSON.

squarecloud auth logout

Usage
Removes the saved API key from this machine. It doesn’t revoke the key: to do that, delete it in the dashboard. When SQUARECLOUD_API_KEY is set, commands keep using it after a logout.
Output
When no account is connected, it prints No account is connected on this machine. and exits with code 0.

CI and scripts

In CI, don’t log in at all: create an API key in the dashboard and set it in the SQUARECLOUD_API_KEY environment variable. Every command uses it instead of the saved key, and the CLI runs even on machines without a home folder.
  • Without a terminal, auth login doesn’t prompt for anything: it exits with a hint. Use --with-token, --token or SQUARECLOUD_API_KEY.
  • With CI=true, the browser login refuses to run, since its key expires in 90 days and only a person can renew it.
More on exit codes and JSON output in Global flags and CI.

When the key stops working

If a command says your session expired or the API key was revoked, run squarecloud auth login again. Commands that need an account print You need to be logged in to run this command. and exit with code 1 when no key is saved or set.