Overview
Install the CLI, authenticate it, and run the whole money story from a terminal: mint a cap, spend under it, read the wallet back.
codespar is the CodeSpar API with a terminal in front of it. The 134 commands are derived from the same OpenAPI document the SDK and the HTTP reference are, so anything you can call over HTTP you can also call here, with a key and no integration.
The terminal above is not a mock. Four commands are the whole money story: log in, mint a capped mandate, spend against it, read the wallet back.
Install
npm install -g @codespar/cli
codespar --versionIf codespar: command not found after install, your global npm bin directory is not on $PATH. npm config get prefix tells you where it is.
Authenticate
codespar loginIt prompts for an API key and saves it to ~/.codespar/config.json. No browser opens. Pass --api-key to skip the prompt.
In CI, where there is nobody to prompt, use the environment instead:
export CODESPAR_API_KEY=csk_test_...
codespar whoamiwhoami is the right first call, and the right first thing to run when something stops working: it answers whether the key is valid, which organization and project it is bound to, which environment it acts in, and which scopes it holds. Four questions in one call.
The four commands
# 1. authenticate once per machine
codespar login
# 2. mint a mandate: a cap the agent cannot exceed
codespar mandate create --consumer csm_0000 --currency BRL --cap 50000
# 3. spend against it — refused if it would exceed the cap
codespar spend --mandate cm_0000 --payee vendedor@empresa.com.br --amount 2500
# 4. read the wallet back — the consumer is positional
codespar wallet csm_0000The cap is enforced on the server, not here: a spend that would exceed it is refused whatever the client asks. That is the point of step 2, and it is why step 3 can be handed to an agent.
By the job you are doing
Each page below teaches its commands with a worked example and the real output, and names which refusal a retry can fix.