Monito CLI

JSON Output

How the Monito CLI handles structured output for scripting and automation.

The --json Flag

Every command that produces output supports --json:

monito project list --json
monito run view <id> --json
monito credits --json

Output Separation

The CLI separates data from human text:

  • stdout: JSON data and typed error envelopes (when JSON mode is enabled), or raw token output
  • stderr: Human-readable text, tables, progress spinners, and human-mode error messages

This means you can safely pipe stdout to jq or other tools:

monito project list --json | jq '.projects[0]'

Error Handling

In JSON mode, errors are printed to stdout as a typed envelope and the process exits with a stable non-zero code:

{
  "error": {
    "code": "not_found",
    "message": "Project not found"
  }
}

Exit Codes

CodeMeaning
0Command succeeded
1Command ran, but the test result failed
2Authentication failed or expired
3Requested resource was not found
4Input or command validation failed
5Insufficient Monito credits
6A blocking run timed out
7Network, server, or unknown error
8Existing state conflicts with the requested mutation

Token Output

The auth token command writes the raw token to stdout without a newline, making it ideal for shell substitution:

export MONITO_TOKEN=$(monito auth token)

Piping Examples

# Count projects
monito project list --json | jq '.projects | length'
 
# Get the latest run status
monito run list --json --limit 1 | jq '.runs[0].status'
 
# Extract all scenario names for a project
monito scenario list --project-id <id> --json | jq -r '.scenarios[].name'
 
# Check if any runs failed
monito run list --json | jq '[.runs[] | select(.status == "failed")] | length'

On this page