Authentication
Every command except --help needs a bearer token. There are three ways to
supply one, checked in this order:
--tokenon the command- Stored credentials, selected by
--alias - The
POLYMESA_TOKENenvironment variable
Browser login
Section titled “Browser login”The usual path for a human at a terminal. It opens your browser, you sign in, and the CLI stores the resulting token.
polymesa auth login --url https://api.polymesa.comNothing to copy and paste, and no password touches your shell history.
Password login
Section titled “Password login”For environments with no browser. Prints the JWT to stdout rather than storing it.
polymesa login --email you@example.com --password 'hunter2' --url https://api.polymesa.comConnected apps (machine-to-machine)
Section titled “Connected apps (machine-to-machine)”For CI and scripts, use the JWT bearer flow with an RSA key rather than a password. No interactive step, no user credentials.
polymesa auth login \ --jwt \ --client-id <client-id> \ --key-file ./private-key.pem \ --username service@example.com \ --url https://api.polymesa.comThe CLI signs an assertion with your private key and exchanges it for a token. The private key never leaves your machine.
Aliases
Section titled “Aliases”Credentials are stored under named aliases, so one machine can talk to several instances — production, staging, a local stack — without re-authenticating.
# Store under a namepolymesa auth login --alias prod --url https://api.polymesa.compolymesa auth login --alias local --url http://localhost:3000
# Use onepolymesa retrieve ./config --alias prod
# Inspectpolymesa auth listpolymesa auth whoami --alias prod
# Removepolymesa auth logout --alias localpolymesa auth logout --allCommands default to the default alias when --alias is omitted.
Where credentials live
Section titled “Where credentials live”Tokens are written to ~/.polymesa/credentials.json (%USERPROFILE%\.polymesa\
on Windows) as JSON:
{ "defaultAlias": "prod", "instances": { "prod": { "...": "..." } }}Workspaces
Section titled “Workspaces”On a multi-workspace account, each alias has a default workspace. Override it per command without switching alias:
polymesa retrieve ./config --alias prod --workspace acmepolymesa auth whoami --alias prod --workspace acmeEnvironment variables
Section titled “Environment variables”Useful in CI, where flags get unwieldy:
| Variable | Purpose |
|---|---|
POLYMESA_TOKEN | Bearer token, used when no --token or alias applies |
POLYMESA_API_URL | Default API base URL, replacing --url |
export POLYMESA_API_URL=https://api.polymesa.comexport POLYMESA_TOKEN="$(cat token.txt)"
polymesa deploy ./configWithout either, the API URL defaults to http://localhost:3000.