p202 whoami

Show the user, roles and scopes the configured API key acts as

New in 1.9.77
All commands

01Run it

Straight from the command's own help.

p202 whoami
p202 whoami --profile staging --json

02What you get

Captured from the real binary, run against a demo store with 30 days of traffic. Switch tabs to see the same run as JSON, the shape scripts and agents parse.

p202 whoami
$ p202 whoami
profile:     default
roles:       ["super user"]
scopes:      ["*"]
url:         https://track.example.com
user_email:  [email protected]
user_id:     1
user_name:   demo
Real output · p202 1.9.77 · demo dataexit 0
p202 whoami
$ p202 whoami
Error [auth]: API error (401): Invalid API key.
Hint: Verify your API key: run `p202 config show`, then `p202 config set-key <key>` if it's wrong.
Real output · p202 1.9.77 · demo dataexit 2

A refused key: exit 2.

03Build your command

Pick values and the command line writes itself, quoted and ready to paste.

p202 whoami

Set flags below; the command updates as you type.

04How it works

Asks the server who the configured key belongs to: its user id and username, the user's roles, and the key's scopes (* is full access; read, campaigns:write and the like narrow it). Fails with exit 2 when the server refuses the key.

p202 whoami
p202 whoami --profile staging --json

05For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands whoami --json.
  • With AI_AGENT, CLAUDECODE or another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with a hint.
  • Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
p202 commands whoami --json
{
  "path": "p202 whoami",
  "use": "whoami",
  "short": "Show the user, roles and scopes the configured API key acts as",
  "long": "Asks the server who the configured key belongs to: its user id and username, the\nuser's roles, and the key's scopes (`*` is full access; `read`, `campaigns:write`\nand the like narrow it). Fails with exit 2 when the server refuses the key.\n\n  p202 whoami\n  p202 whoami --profile staging --json",
  "runnable": true
}