Unauthorized

The unauthorized error occurs when Command Code CLI is not properly authenticated or your credentials are invalid. This error signals that you need to authenticate before using Command Code.

  • Not logged in to Command Code CLI.
  • Invalid or expired authentication session.
  • Authentication token has been revoked.
  • A stale or revoked key in the COMMAND_CODE_API_KEY environment variable. It overrides ~/.commandcode/auth.json, so cmd login won't fix it while it's set.
  • Running in CI or another non-interactive environment without COMMAND_CODE_API_KEY set.

  1. Login to Command Code: Run cmd login command to authenticate with Command Code CLI.
  2. Verify authentication status: Check if you're properly logged in and your session is active.
  3. Re-authenticate: If your session has expired, log out and log back in to refresh your authentication.
  4. Check the env var: Run cmd status. If it shows Source: $COMMAND_CODE_API_KEY, the env var is the active credential. Replace it with a valid key, or clear it to fall back to your cmd login session: unset COMMAND_CODE_API_KEY on macOS / Linux, Remove-Item Env:COMMAND_CODE_API_KEY in Windows PowerShell.
  5. In CI: Set COMMAND_CODE_API_KEY from your CI provider's secrets store. See Headless authentication.

Ensure you are logged in to Command Code CLI with valid credentials. If you continue to experience issues, try logging out and logging back in.