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-cli project list --json
monito-cli run view <id> --json
monito-cli credits --json

Output Separation

The CLI separates data from human text:

  • stdout: JSON data (when --json is used) or raw token output
  • stderr: Human-readable text, tables, progress spinners, error messages

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

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

Error Handling

In JSON mode, errors are printed to stderr and the process exits with a non-zero code. The error format:

Error: API error: Not Found

Exit Codes

CodeMeaning
0Command succeeded
1Test run failed (used by scenario run, project run)
2CLI error — bad arguments, auth failure, API error

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-cli auth token)

Piping Examples

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

On this page