Skip to content

Authentication

Every command except --help needs a bearer token. There are three ways to supply one, checked in this order:

  1. --token on the command
  2. Stored credentials, selected by --alias
  3. The POLYMESA_TOKEN environment variable

The usual path for a human at a terminal. It opens your browser, you sign in, and the CLI stores the resulting token.

Terminal window
polymesa auth login --url https://api.polymesa.com

Nothing to copy and paste, and no password touches your shell history.

For environments with no browser. Prints the JWT to stdout rather than storing it.

Terminal window
polymesa login --email you@example.com --password 'hunter2' --url https://api.polymesa.com

For CI and scripts, use the JWT bearer flow with an RSA key rather than a password. No interactive step, no user credentials.

Terminal window
polymesa auth login \
--jwt \
--client-id <client-id> \
--key-file ./private-key.pem \
--username service@example.com \
--url https://api.polymesa.com

The CLI signs an assertion with your private key and exchanges it for a token. The private key never leaves your machine.

Credentials are stored under named aliases, so one machine can talk to several instances — production, staging, a local stack — without re-authenticating.

Terminal window
# Store under a name
polymesa auth login --alias prod --url https://api.polymesa.com
polymesa auth login --alias local --url http://localhost:3000
# Use one
polymesa retrieve ./config --alias prod
# Inspect
polymesa auth list
polymesa auth whoami --alias prod
# Remove
polymesa auth logout --alias local
polymesa auth logout --all

Commands default to the default alias when --alias is omitted.

Tokens are written to ~/.polymesa/credentials.json (%USERPROFILE%\.polymesa\ on Windows) as JSON:

{
"defaultAlias": "prod",
"instances": {
"prod": { "...": "..." }
}
}

On a multi-workspace account, each alias has a default workspace. Override it per command without switching alias:

Terminal window
polymesa retrieve ./config --alias prod --workspace acme
polymesa auth whoami --alias prod --workspace acme

Useful in CI, where flags get unwieldy:

VariablePurpose
POLYMESA_TOKENBearer token, used when no --token or alias applies
POLYMESA_API_URLDefault API base URL, replacing --url
Terminal window
export POLYMESA_API_URL=https://api.polymesa.com
export POLYMESA_TOKEN="$(cat token.txt)"
polymesa deploy ./config

Without either, the API URL defaults to http://localhost:3000.