Output modes and scripting
The CLI supports multiple output modes for both human reading and machine processing. This guide covers how to use them effectively in scripts and workflows.
Output modes
Human-readable (default)
The default output renders formatted tables with colors. Best for interactive terminal use.
JSON
Use --json for structured output. Pass all for every field, or select specific fields:
NDJSON (streaming)
When listing with --page-all, the CLI streams one JSON object per line (newline-delimited JSON).
This works well with line-based tools and avoids loading the entire result set into memory.
Quiet
Use -q or --quiet to suppress all non-error output. The exit code indicates success or failure.
Verbose
Use -v or --verbose to log HTTP request and response details to stderr. Combine with
any other output mode for debugging.
Verbose output goes to stderr, so it doesn’t interfere with JSON output on stdout.
Field selection
Select specific JSON fields to reduce output size — especially useful in scripts and when working with AI agents where token usage matters.
Available fields vary by command. Run any command with --json all to see all available fields,
or check the command reference.
Filtering with —jq
The --jq flag applies a jq expression to the JSON output.
It implies --json, so you don’t need to specify both.
Extract a single field:
Filter a list:
Reshape output:
Count files:
Composing commands with piping
Commands that accept --from-stdin read UUIDs (or file paths, or URLs) from standard input.
This lets you chain commands together.
Delete all unstored files:
Store the 10 most recently uploaded files:
Create a group from stored images:
Upload files listed in a text file:
The CLI auto-detects whether stdin contains plain text (one value per line) or NDJSON.
Dry-run mode
Use --dry-run on destructive or mutating commands to preview what would happen without
making changes.
Dry-run works on: file upload, file upload-from-url, file store, file delete,
file local-copy, file remote-copy, metadata set, metadata delete, group create,
group delete, webhook create, webhook update, webhook delete, convert document,
convert video, addon execute, project create, project update, project delete.
Scripting best practices
Always use --json in scripts. Human-readable output may change between versions;
JSON output is stable.
Check exit codes. Don’t parse output to detect errors — use $?:
Handle pagination for large file sets. Use --page-all to stream all results:
Disable colors in logs. Use --no-color or set NO_COLOR=1 to avoid ANSI escape codes
in log files: