Skip to main content
The CLI supports two credentials. Interactive users log in once with a browser; scripts, CI jobs, and agents set an API key in the environment.

Interactive login

This starts a device-code flow. The CLI prints a verification URL and a short user code, opens your browser when it can, and waits for you to approve the request:
Approving writes a session token to credentials.json in the config directory with 0600 permissions. Check it at any time:
To sign out and delete the stored token:
Session tokens expire. When one does, the CLI clears it and asks you to run chainpatrol login again, exiting with code 2.

Logging in without a browser

In a remote shell, a container, or a CI runner, the CLI detects that it is not attached to a terminal and falls back to plain text — the verification URL is printed on stdout immediately instead of being hidden behind an interactive UI. Open it on any device. For a caller that parses output, --json emits one JSON object per milestone:
chainpatrol login --no-input is rejected unless you also pass --json. Without one of them there is no way to surface the device code, so the command would appear to hang.

API key authentication

Set CHAINPATROL_API_KEY and the CLI uses it instead of a stored session — no login step, nothing written to disk. This is the right choice for CI, cron jobs, and service accounts.
The key is sent as the X-API-KEY header, the same one the External API uses, so an existing API key works with the CLI as-is. An organization-scoped key carries its organization with it. Commands that would otherwise need --orgthreats list, takedowns list, orgs assets list, reports search, proposals review — resolve it from the key.
CHAINPATROL_API_KEY takes precedence over any stored session, so you can point a single shell at a service account for one command:

Which identity am I using?

With an API key, whoami validates the key and reports the organization it is bound to. With a session token, it returns the logged-in user. Either way it is the fastest check before a command that writes.

Permissions

The CLI has exactly the permissions of the credential behind it — it does not widen them. Two consequences worth knowing:
  • Staff-only surfaces (for example queues snapshot --all) fail with exit code 5 for customer credentials.
  • Proposal reviews must be attributed to a customer-role member of the organization, so staff credentials are refused there.