01Run it
Straight from the command's own help.
p202 whoamip202 whoami --profile staging --json02What 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 profile: default roles: ["super user"] scopes: ["*"] url: https://track.example.com user_email: [email protected] user_id: 1 user_name: demo
$ p202 whoami --json { "data": { "profile": "default", "roles": [ "super user" ], "scopes": [ "*" ], "url": "https://track.example.com", "user_email": "[email protected]", "user_id": 1, "user_name": "demo" } }
$ 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.
$ AI_AGENT=1 p202 whoami {"error":{"category":"auth","command":"p202 whoami","exit_code":2,"hint":"Verify your API key: run `p202 config show`, then `p202 config set-key <key>` if it's wrong.","http_status":401,"message":"API error (401): Invalid API key."}}
A refused key: exit 2.
03Build your command
Pick values and the command line writes itself, quoted and ready to paste.
p202 whoamiSet 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,CLAUDECODEor another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with ahint. - Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
{
"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
}