Skip to content
Command line (CLI)

CLI authentication

Browser sign-in with the device flow, or an API key in an environment variable.

Which method to use

SituationMethod
Your computer with a browser.postemi auth:login
Server, container, scheduled run, CI.POSTEMI_API_KEY environment variable

Browser sign-in

postemi auth:login

The command opens a browser, where you approve access with a code. The CLI then stores the credential on your machine (~/.postemi/credentials.json), so you don't have to put it in your scripts, and it doesn't end up in your command history.

No account yet? Create one from the CLI (see New account) or on postemi.com, then run postemi auth:login.

The approval page opens even if you aren't signed in

This is intentional. If you aren't signed in, you first see what you are approving, including the device and code. You sign in only after that. Nothing is approved unless you sign in.

New account

postemi auth:signup --email [email protected]
# a six-digit code arrives by email (valid 10 minutes)
postemi auth:signup --email [email protected] --code 123456 --accept-terms

The first run e-mails a code. On a terminal the CLI then asks for the code and whether you agree to the terms and the privacy notice; an agent passes --code and --accept-terms in a second run, only after you agreed. The CLI stores the new account's key like auth:login does. Optional: --workspace-name, --timezone, --language.

There is no free trial on an account made this way: next come postemi billing:plans and postemi billing:subscribe. The CLI keeps working only on a plan with API access, which Basic does not have. If the address already has an account, sign in with postemi auth:login instead. You can also sign up on postemi.com.

API key via an environment variable

If there's no browser, put the API key in an environment variable. Create the key in Postemi under Automations → Developers. See the Developer settings page.

export POSTEMI_API_KEY=psty_your_key
postemi integrations:list
  • Stored sign-in credentials take precedence over the environment variable.
  • Pass the key through a secrets manager. Don't put it in the script or commit it to version control.
  • For scheduled runs, it's also a good idea to set the POSTEMI_TIMEZONE variable so the dates are unambiguous.

Status and logout

postemi auth:status   # which workspace this machine is linked to
postemi auth:logout   # delete the stored credentials

auth:status doesn't just print the status. It also checks the credential with a real call. If that works, authentication is working. Any errors after that relate to the command itself.

Workspaces

postemi workspaces:list        # what the credential reaches; "current" is the active one
postemi workspaces:use <id>    # every following command acts on it
postemi workspaces:current     # the one commands act on now
postemi posts:list --workspace <id>   # one command in another workspace

A key can reach one workspace or several: tick “All my workspaces” on the approval page for the rest. Channel ids belong to a workspace, so the CLI has to know which one you mean. auth:login asks when the key spans several; the choice is stored with your login, and POSTEMI_WORKSPACE or --workspace override it. Without a choice the API refuses a multi-workspace key with 403 on every route except workspaces:list, so nothing is ever posted to a guessed workspace.

Your own backend

By default, the CLI connects to https://api.postemi.com. To connect to another instance, use the --auth-server flag or the POSTEMI_API_URL variable.

export POSTEMI_API_URL=https://your-instance.example/api
postemi auth:login --auth-server https://your-instance.example/api
Is something missing from this page? Email [email protected] or use the form on the Help page.