octo auth: sign in to the CLI

Sign in to the Askocto CLI with an API key, check which workspace you are using, sign out, and use OCTO_API_KEY in CI.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

octo auth stores and checks the API key that every other command uses. Run it once on your machine, or skip it and set an environment variable in automated jobs.

Before you start

Create an API key in Workspace Settings > API keys. Keys start with oc_live_ for production or oc_test_ for testing, and the full key is shown once. A key acts on the whole workspace, so store it like a password. See Authentication for the rules that apply to keys.

Commands

Command What it does
octo auth login Prompts for an API key and saves it to the config file.
octo auth login --api-key KEY Saves the key without a prompt.
octo auth status Shows the key prefix, the workspace and where the key came from.
octo auth logout Removes the saved key.

Sign in

  1. Run the login command.

    octo auth login
    
  2. Paste your API key when asked. The input is hidden.

  3. Run the status command to confirm.

    octo auth status
    

You should see the workspace name, the key prefix such as oc_live_a1b2, and a line saying the key is stored in the config file. The key is written to ~/.config/octo/config.json. See Config.

Use the environment variable

In CI, set OCTO_API_KEY and run commands directly.

export OCTO_API_KEY="oc_test_your_key_here"
octo agents list --json

Which key wins

The CLI picks the first key it finds in this order:

  1. The --api-key flag on the command.
  2. The OCTO_API_KEY environment variable.
  3. The key saved in the config file.

octo auth status tells you which source it used, which helps when a shell still has an old variable set.

Troubleshooting

  • unauthorized error. The key is wrong, revoked or copied with a space. Create a new key and sign in again.
  • Wrong workspace. Keys belong to one workspace. Check octo auth status and sign in with the key from the right workspace.
  • Key shown in shell history. Avoid --api-key on shared machines. Use the prompt or the environment variable.

After signing in, run octo health to test the connection.

Something unclear or missing? Tell us and we will fix the page.