Signing in
Every login targets one environment. Pass the environment as a flag, or run the command without one in a terminal and the CLI will ask:- Sandbox
- Production
Terminal
--new-session.
After signing in, the CLI lists every organization you can access across the
environments you are signed in to and asks which one to make active.
The active organization
Commands that act on an organization, such aspolar webhook listen, use the active
organization. Its environment comes with it: choosing a sandbox organization
means the CLI talks to sandbox, choosing a production organization means it
talks to production. There is no separate environment switch.
Terminal
Terminal
Terminal
Terminal
--org. Every command that acts on an
organization accepts it:
Terminal
Create an access token for your app
Your application needs an organization access token to call the API.polar auth token creates one for the active organization and prints it:
Terminal
--scope, repeated:
Terminal
https://sandbox-api.polar.sh.
Tokens created this way show up with the rest in Settings → Access Tokens in the
dashboard, where you can also create or revoke them. See
Organization access tokens.
Signing out
Log out of one environment or all of them:Terminal
CI and headless use
On machines without a browser or keychain, and for coding agents, authenticate with an access token instead of a session: an organization access token, or an OAuth or agent access token.Terminal
POLAR_ENVIRONMENT selects the environment the token belongs to and defaults
to production. An organization access token belongs to one organization, so
commands use that organization.
While
POLAR_ACCESS_TOKEN is set, saved sessions are ignored and polar auth login and polar auth org refuse to run. Unset it to go back to your
browser session.Where things are stored
- Sessions live in the operating system keychain under the service name
polar-cli, with one entry per environment. - The active organization is saved in
~/.config/polar-cli/config.json, or$XDG_CONFIG_HOME/polar-cli/config.jsonwhen that variable is set.

