Authentication
How Studio signs in to your Format account, on your own computer, on a remote machine, or from an agent's sandbox.
Studio runs under your Format account. The first time it starts on a machine it asks you to sign in and choose an organization, then saves the credentials in a .format folder in your home directory on the machine. This authentication is only needed once per machine.
You should note that authenticating is separate from your API keys. Using Studio to preview your PDF designs requires authentication, whereas generating PDFs needs an API key, covered in Preview as PDF. format compile needs neither.
On your own computer
When you run format dev for the first time, you will be directed through the authentication flow in the browser. The link is also printed in the terminal, so an agent can pass it to you. Next you should:
- Sign in to Format if you're not already signed in.
- Choose the organization Studio should use.
- Click Approve connection.
Your browser returns to Studio, which confirms the connection, and you're ready to build.
You can bypass the automatic opening of any browser tabs by passing --no-open:
# Don't open auth or studio tabs
npx format dev --no-openYou can connect more organizations by using the Connect another organization option in Studio.
On a remote machine
When Studio runs on a machine your browser can't reach, the browser has nowhere to return to. This is the case over SSH, in a dev container or Codespace, and in a cloud agent's sandbox. format dev detects these and exits with code 3, which tells scripts and agents it needs a person to intervene. It also displays the message:
Studio isn't connected (AUTH_REQUIRED). Studio is running over SSH. Run `format auth start` to connect with a one-time code.In these scenarios, you should first authenticate the machine with format auth.
-
Start authentication. It prints the link and the command to run next.
npx format auth start -
Open the link in a browser where you can sign in to Format. Choose an organization and click Approve connection. The page shows a one-time code.
-
Run the command printed in the console and paste the code when it asks. Your typing is hidden. It should look something like this:
npx format auth complete --request <id> -
Run
format dev.
The code works once and expires after 10 minutes. Paste it only into the terminal or agent you started the sign-in from. Anyone who has it can sign in to Studio as you.
For more advanced options, read the format auth reference.
From an agent
A coding agent runs Studio to preview its work. On your computer, it runs format dev and you approve the link it prints. In a cloud sandbox, it runs the format auth commands with --json and you relay the link and the code. The agent instructions that ship with the CLI, node_modules/@format.dev/cli/AGENTS.md, tell agents to do this, and format auth documents the output and error codes an agent acts on.
Membership changes
Leaving an organization, or being removed from it, revokes your Studio sessions for that organization. See Organizations.
Troubleshooting
Studio printed a link, but approving it fails
Studio can mistake a remote machine for your own computer, for example inside tmux or a VM reached through a web terminal. It then prints the normal link. When you approve it, your browser tries to return to 127.0.0.1 on your computer, where Studio isn't running, and shows a connection error. Studio keeps waiting.
Stop Studio with Ctrl+C and sign in with format auth start instead.
Studio asks for format auth on a machine your browser can reach
Some remote setups forward ports back to your computer. VS Code Remote and Codespaces do this for any port a process starts listening on. Your browser can then reach the remote machine's 127.0.0.1, so the normal link works even though Studio detected SSH. Tell Studio so:
npx format dev --auth-mode local