CLI Reference
CLI Overview
Global flags, output format, exit codes, and the capabilities command
CLI Overview
The NextPay CLI is an agent-first command-line tool for managing your NextPay account. It defaults to JSON output on stdout with errors on stderr, making it easy for AI agents and scripts to parse. When connected to a TTY, it auto-detects and switches to human-friendly output.
Global flags
These flags are available on every command:
| Flag | Env var | Description |
|---|---|---|
--format <json|human> | NEXTPAY_FORMAT | Output format. Defaults to json for pipes, human for TTY. |
--workspace <id> | NEXTPAY_WORKSPACE_ID | Workspace ID to operate on (overrides stored default). |
--org <id> | NEXTPAY_ORG_ID | Organization ID to operate on (overrides stored default). |
--api-key <key> | NEXTPAY_API_KEY | API key for non-interactive authentication. |
--env <dev|prod> | NEXTPAY_ENV | Environment to connect to. |
--quiet | — | Suppress informational messages on stderr. |
--verbose | — | Enable debug logging to stderr. |
--yes | — | Skip confirmation prompts for destructive operations. |
Output format
All commands output JSON to stdout by default:
nextpay --env dev workspace list
# {"workspaces": [{"id": "ws_abc123", "name": "Finance", ...}]}Errors are written to stderr with a non-zero exit code:
nextpay --env dev workspace get ws_invalid 2>/dev/null
# Exit code: 1Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | General error (invalid input, not found, etc.) |
2 | Authentication error (not logged in, invalid API key) |
The capabilities command
The capabilities command outputs a JSON document describing all available commands, their arguments, valid values, and descriptions. This is designed for AI agents to discover CLI capabilities at runtime:
nextpay capabilities{
"commands": [
{
"name": "auth login",
"description": "Log in to your NextPay account via browser",
"args": []
},
{
"name": "directory list",
"description": "List directory entries with optional filtering",
"args": [
{"name": "--type", "values": ["person", "organization"], "required": false},
{"name": "--status", "values": ["active", "inactive"], "required": false},
{"name": "--limit", "default": "25", "required": false}
]
}
]
}Recommended agent workflow:
- Call
nextpay capabilitiesonce at startup to discover commands. - Parse the JSON to understand available operations and their parameters.
- Construct and execute commands as needed.
- Parse JSON output from each command to make decisions.