Private betav0.4.1
DocsSign in
Format developer documentation

format auth

Sign Studio in from a machine your browser can't reach, such as over SSH, in a container, or in an agent's sandbox.

The format auth CLI allows you to programmatically authenticate Studio. It's useful for cloud agents or CI when Studio runs somewhere your browser can't return to. You use the auth command on the remote machine, approve it in any browser, and bring the one-time code back.

When running Studio on your own computer, format dev handles authentication, so you don't need these commands. Authentication explains more about each situation.

Start a sign-in

Prints the link to open and the command to run next. Nothing is sent to Format until someone approves the link.

npx format auth start
pnpm dlx format auth start
yarn dlx format auth start
bun x format auth start

The sign-in waits 30 minutes for its code. Start another if that passes.

Reference

--jsonType booleanPrints the result as a JSON object to stdout. Useful for scripts and agents.

Complete a sign-in

Trades the one-time code from the browser for Studio credentials. At a terminal it prompts you for the code.

npx format auth complete --request <id>
pnpm dlx format auth complete --request <id>
yarn dlx format auth complete --request <id>
bun x format auth complete --request <id>

The code works once and expires 10 minutes after the page showed it. A code that was mistyped leaves the sign-in open, so run the command again with the right one.

Reference

--requestThe sign-in request to complete against. You obtain this from running format auth start.
Details

The id format auth start printed, which names the sign-in on this machine. It is not a secret.

Type
string
--codePass your sign-in code with the command as text. Be aware that it lands in your shell history.
Details

Passes the code as an argument. It then appears in your shell history, so at a keyboard let the prompt ask instead.

npx format auth complete --request <id> --code <code>
pnpm dlx format auth complete --request <id> --code <code>
yarn dlx format auth complete --request <id> --code <code>
bun x format auth complete --request <id> --code <code>
Type
string
--code-stdinReads your sign-in code from stdin. Useful for scripts and agents that pipe it in. Standard terminals default to this behaviour but this flag forces it regardless of the terminal.
Details

Reads the code from stdin even when stdin is a pipe. Without this flag the command only asks a terminal, and stops with MISSING_CODE anywhere else, so a script that forgot the code fails at once rather than waiting.

echo "$CODE" | npx format auth complete --request <id> --code-stdin
Type
boolean
--jsonPrints the result as a JSON object to stdout. Useful for scripts and agents.
Type
boolean

Check sign-ins

Lists the sign-ins started on this machine and the organizations it holds credentials for. It reads local files only, so it can't say whether a browser has approved a sign-in or whether Format still accepts the saved credentials.

npx format auth status
pnpm dlx format auth status
yarn dlx format auth status
bun x format auth status

Reference

--requestType stringLimit the status to a specific sign-in request ID.
--jsonType booleanPrints the result as a JSON object to stdout. Useful for scripts and agents.

Cancel a sign-in

npx format auth cancel --request <id>
pnpm dlx format auth cancel --request <id>
yarn dlx format auth cancel --request <id>
bun x format auth cancel --request <id>

Reference

--requestType stringThe sign-in request ID to cancel.
--jsonType booleanPrints the result as a JSON object to stdout. Useful for scripts and agents.

Scripts and agents

An agent in a cloud sandbox runs these commands and relays the link and the code through you. Each command can run in its own process, and a fresh sandbox needs a fresh sign-in unless its .format home folder is kept.

npx format auth start --json
{
	"status": "pending",
	"attemptId": "k3Yd…",
	"url": "https://dash.format.dev/studio/link?v=2&mode=remote&attempt=k3Yd…",
	"expiresAt": "2026-11-13T12:45:00.000Z",
	"next": "npx format auth complete --request k3Yd… --code-stdin"
}

The agent gives you the url. You open it in a browser, approve the connection, and give the one-time code to your agent.

echo "$CODE" | npx format auth complete --request <id> --code-stdin --json
{
	"status": "signed-in",
	"organization": { "id": "…", "name": "Acme" },
	"account": { "name": "Ada Lovelace", "email": "[email protected]" }
}

A failure prints { "status": "error", "error": { "code", "message" } } and exits with code 1.

CodeMeaningWhat to do
INVALID_CODEThe code was mistyped, already used, or expiredAsk for the code again, or start over
UNREACHABLEFormat could not be reached, or did not give a clear answer. The code may or may not be usedTry the same code again. If it is refused, run format auth start again
INTERRUPTEDThe sign-in ended without finishing and its code is used upRun format auth start again
EXPIREDThe sign-in waited more than 30 minutesRun format auth start again
NOT_FOUNDNo connection request with that --request id on this machineCheck the id for a typo, or run format auth start again
ACCESS_DENIEDThe account can no longer use Studio for that organizationA person needs to check their membership
UNSUPPORTED_PROTOCOLFormat no longer accepts sign-in from this Studio versionRun format update latest
MISSING_REQUESTNo --request id was givenPass the attemptId from format auth start
MISSING_CODEStdin is not a terminal and no code was givenPass --code, or pipe the code in with --code-stdin

format dev itself exits with code 3 and prints AUTH_REQUIRED when it detects a machine the browser can't reach, so an agent knows to run these commands first. Never log or store the code.

Was this page helpful?