The R4 CLI is the easiest way for an agent to use R4 as its password manager.
npm install -g @r4-sdk/cliRequires Node.js 18 or newer.
The CLI follows the same zero-trust runtime flow as the SDK:
projectId and trustStorePathUse this exact flow when you are setting up an agent with the CLI for the first time.
npm install -g @r4-sdk/clir4 configureThat flow can either:
By default it stores the profile under:
~/.r4/
config.json
profiles/<profile>/credentials.json
profiles/<profile>/private-key.pem
profiles/<profile>/trust-store.jsonr4 space infoThis confirms the active profile, API-key scope, principal, base URL, and the managed credential/private-key/trust-store paths.
If you used the bootstrap mode in r4 configure, the first public key is
already registered. If you saved existing credentials instead, run:
r4 doctorThis first public-key registration should happen before operators add the agent to security groups, projects, or direct vault shares.
r4 vault list-vaultsr4 vault itemsr4 vault get GITHUB_PRODUCTION_TOKENIf you already have a credentials handoff file and want the older one-shot bootstrap, use:
r4 agent init --credentials-file ./agent-creds.csvThat reads the handoff file, generates the key if needed, registers the public
key, saves the profile, and runs r4 doctor.
If you only need to save an existing key non-interactively, r4 auth login
still works too.
r4 vault list-vaultsr4 vault listr4 vault itemsr4 vault list-items
r4 vault items --metadata-onlyr4 vault search githubr4 vault get GITHUB_PRODUCTION_TOKENr4 run -- node deploy.js
r4 run --prefix R4 -- docker compose upr4 machine request GET /me
r4 machine request POST /webhook --body '{"name":"primary","url":"https://example.com/r4"}'r4 space info
r4 profile show
r4 auth whoamiAll major CLI commands support --json:
r4 auth whoami --json
r4 vault items --json
r4 vault search github --json
r4 vault list --jsonOn first use, the CLI:
~/.r4/config.json~/.r4/profiles/<profile>/credentials.jsonIt also caches the last resolved identity with the saved profile so r4 space info
can still tell you which scope and principal the profile was last verified as,
even if the current live lookup is unavailable.
The CLI now separates general profile settings from secret material:
~/.r4/
config.json
profiles/<profile>/credentials.json
profiles/<profile>/private-key.pem
profiles/<profile>/trust-store.jsonconfig.json stores the current profile, runtime settings, and cached identity metadatacredentials.json stores split accessKey and secretKeyUse r4 doctor first. It registers the public key idempotently, checks
visible vaults, checks wrapped keys, and verifies the local decrypt path.
| Exact error | Fix |
|---|---|
No API key found. Provide one via: | Set --api-key, R4_API_KEY, or both R4_ACCESS_KEY and R4_SECRET_KEY. Then save it with r4 auth login. |
No private key path found. Provide one via: | Run r4 configure to create the managed key, or pass --private-key-path / R4_PRIVATE_KEY_PATH to point at an existing PEM file. |
R4 API Error [agent_scope_required]: This endpoint requires an AGENT-scoped API key. | Use the agent API key from Platform -> Developer -> Agents. USER, TENANT, and ORG keys are not the agent retrieval path. |
R4 API Error [wrapped_key_not_found]: No wrapped key found for this agent and vault. | Register the public key first, then ask the operator to re-share or re-assign the vault, project, or security-group access so wrapped keys are created for this agent. |
R4 SDK: failed to register the local agent public key. | Confirm the API key is AGENT-scoped and the private key PEM matches the runtime identity you expect. Re-run r4 doctor. |
Failed to fetch public transparency witness artifact (403). | Allow outbound access to https://transparency-prod.r4.dev for production or https://transparency-dev.r4.dev when targeting https://dev.r4.dev, or point the CLI at a custom witness URL for other environments. |
If decryption is failing but access looks correct, use r4 vault list-vaults,
r4 vault list-items, or r4 vault items --metadata-only to inspect metadata
without relying on the local private-key decrypt path.
Choose the CLI when the runtime:
r4 run style environment injectionChoose the Node SDK when the runtime already runs inside Node.js code.
Use r4 machine request when the raw machine API already exposes the workflow
you need but the higher-level CLI commands have not wrapped it yet.
If the CLI is missing a capability you need and the current SDK, MCP server, or raw machine API also does not cover it, submit product-gap feedback through POST /api/v1/machine/feedback with an AGENT API key. Do not include secrets or private user data in that payload.