CLI reference
Commands, flags, exit codes and JSON output of the CLI.
This reference is generated from the machine-readable schema of the CLI.
CLI: untern-parsing, version 0.1.0.
Global flags
| Flag | Environment variable | Type | Default | Description |
|---|---|---|---|---|
--json | UNTERN_PARSING_OUTPUT | boolean | Print exactly one JSON document on stdout; errors as one JSON line on stderr. | |
--ndjson | UNTERN_PARSING_OUTPUT | boolean | Print an NDJSON event stream on stdout; the last line is a result or error event. | |
--progress | boolean | With --json: also write NDJSON progress events on stderr. | ||
--api-url | UNTERN_PARSING_API_URL | string | API base URL (https; http only for localhost). | |
--profile | UNTERN_PARSING_PROFILE | string | default | Profile for settings and stored login. |
--request-timeout | UNTERN_PARSING_REQUEST_TIMEOUT | integer | 30 s | Per-request HTTP timeout. |
--verbose | boolean | Log requests (method, path, status, duration, request id) on stderr; never bodies or credentials. | ||
--quiet | boolean | Text mode: no notes on stderr. | ||
--no-color | NO_COLOR | boolean | Text mode: no colour. | |
--version | boolean | Same as the version command. |
Environment variables
| Name | Secret | Description |
|---|---|---|
NO_COLOR | No | Disable colour in text mode. |
UNTERN_PARSING_API_URL | No | API base URL (https; http only for localhost). |
UNTERN_PARSING_CONFIG_DIR | No | Directory of config.toml (default: the user config directory). |
UNTERN_PARSING_CREDENTIAL_STORE | No | Where auth login stores credentials: auto (OS keychain, else a 0600 file), keychain or file. |
UNTERN_PARSING_DATA_DIR | No | Directory of the credentials file (default: the user data directory). |
UNTERN_PARSING_DEBUG | No | Set to 1 to print tracebacks of CLI bugs locally (never in CI logs). |
UNTERN_PARSING_OIDC_CLIENT_ID | No | OAuth client for auth login (default lens-cli). |
UNTERN_PARSING_OIDC_ISSUER | No | Keycloak issuer for auth login (default: discovered from the API, RFC 9728). |
UNTERN_PARSING_OUTPUT | No | Default output mode: text, json or ndjson. |
UNTERN_PARSING_PROFILE | No | Profile in the config file and the credential store (default: default). |
UNTERN_PARSING_REQUEST_TIMEOUT | No | Per-request HTTP timeout in seconds (default 30). |
UNTERN_PARSING_TOKEN | Yes | API key (ulk_…) from the portal's API keys page, or an access token; sent as Authorization: Bearer. Wins over a stored login. Never printed. |
Commands
untern-parsing auth login
Sign in with a device code, or store an API key read from stdin.
Without flags: OAuth device authorization grant on client lens-cli. The sign-in URL and code go to stderr (event auth.device_code in --ndjson/--json); the CLI polls until the browser approves, then stores the login in the OS keychain or a 0600 file. With --with-token: reads one API key from stdin, checks it with the API and stores it. A key is never accepted as an argument.
- JSON output:
AuthStatus - NDJSON events:
auth.device_code,result,error - Scopes: None
- Network: Yes
- Side effects: writes_config
- Idempotent: Yes
- Exit codes:
0,2,3,4,8,9,10,7
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--with-token | boolean | Read an API key from stdin instead of signing in. | |
--open | boolean | Open the sign-in page in the default browser. | |
--timeout | number | 600 s | Give up waiting for the browser after this long. |
--scope | string | OAuth scope to request (repeatable); default: openid offline_access. |
Examples
Sign in through the browser
untern-parsing auth loginStore an API key from an environment variable
untern-parsing auth login --with-token --jsonuntern-parsing auth logout
Delete the stored login of the profile.
Removes the profile's login from the keychain and the credentials file. --revoke also revokes an OIDC refresh token at the identity provider. UNTERN_PARSING_TOKEN is not touched (the command says when it is still set).
- JSON output:
AuthStatus - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: writes_config
- Idempotent: Yes
- Exit codes:
0,2,10
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--revoke | boolean | Also revoke the refresh token at the identity provider. | |
--dry-run | boolean | Report what would be deleted; delete nothing. |
Examples
Sign out
untern-parsing auth logout --jsonuntern-parsing auth status
Show which credential is used and whom it belongs to.
Checks the credential with the API (/api/me when the server offers it). UNTERN_PARSING_TOKEN wins over a stored login. --offline reports only the local source (authenticated then means 'a credential was found', unverified). Never prints the credential; API keys show as ulk_…last4.
- JSON output:
AuthStatus - NDJSON events:
result,error - Scopes: None
- Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
whoami - Exit codes:
0,2,3,4,8,9,10
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--offline | boolean | Do not contact the API. |
Examples
Is this environment signed in?
untern-parsing auth status --jsonWhich credential would be used, offline
untern-parsing auth status --offline --jsonuntern-parsing config get
Print one effective setting.
Text mode prints the bare value (empty when unset); --json prints a ConfigView holding that key only.
- JSON output:
ConfigView - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: none
- Idempotent: Yes
- Exit codes:
0,2
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
KEY | string | Yes | Setting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).) |
Examples
Which API URL is used
untern-parsing config get api_urluntern-parsing config list
Show the effective settings of the profile.
Each value is resolved flag > environment > profile > default. Secrets are never stored here; UNTERN_PARSING_TOKEN and logins are not shown.
- JSON output:
ConfigView - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: none
- Idempotent: Yes
- Exit codes:
0,2
Examples
Settings of the default profile
untern-parsing config list --jsonuntern-parsing config path
Print the config file path.
The file may not exist yet; config set creates it. Override the directory with UNTERN_PARSING_CONFIG_DIR.
- JSON output:
ConfigView - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: none
- Idempotent: Yes
- Exit codes:
0
Examples
Where the settings live
untern-parsing config pathuntern-parsing config set
Store a setting in the profile.
Validates the value (api_url must be https, or http on localhost; no credentials or query in the URL) and writes the per-user config file atomically.
- JSON output:
ConfigView - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: writes_config
- Idempotent: Yes
- Exit codes:
0,2
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
KEY | string | Yes | Setting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).) | |
VALUE | string | Yes | New value. |
Examples
Point a local profile at a development API
untern-parsing config set api_url http://127.0.0.1:8000 --profile localuntern-parsing config unset
Remove a setting from the profile.
Idempotent: removing a key that is not set succeeds and changes nothing.
- JSON output:
ConfigView - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: writes_config
- Idempotent: Yes
- Exit codes:
0,2
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
KEY | string | Yes | Setting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).) |
Examples
Forget the stored output mode
untern-parsing config unset outputuntern-parsing doctor
Check settings, network, credential, scopes, contract and MCP before real work.
Runs local checks (settings file, API URL, credentials file mode, keychain, proxy) and, unless --offline, network checks (reachability, Cloudflare Access in front of the API, clock skew, contract version, credential with /api/me or a probe, scopes, expiry, /mcp, credits). Prints the report either way; exit 1 (doctor_failed, also on stderr in --json) when a check failed.
- JSON output:
DoctorReport - NDJSON events:
result,error - Scopes: None
- Network: Yes
- Side effects: none
- Idempotent: Yes
- Exit codes:
0,1,2
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--offline | boolean | Only the local checks. |
Examples
First call of an agent session
untern-parsing doctor --jsonSettings only, no network
untern-parsing doctor --offlineuntern-parsing estimate
Credits a parse would use, before running it.
Sends metadata only (name, size, type, sha256) to POST /api/billing/estimate and prints the server's per-file ceilings (credits), likely cost (credits_expected) and total, valid until quote_expires_at (15 minutes); cached re-parses can be free, and an item the server cannot price has credits null and an error (complete: false). A --mode the server or the plan does not offer is refused first (exit 11 mode_unavailable, exit 13 mode_not_in_plan); --preset is priced by its mode. Exit 11 while the API does not offer estimates, or billing_unavailable while billing is off.
- JSON output:
Estimate - NDJSON events:
result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
estimate_credits - Exit codes:
0,2,3,4,8,9,10,11,13
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
input | path | Yes | Yes | Files or directories (directories are walked). |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--mode | string | Parse mode, one the server enables (see doctor). | |
--preset | string | Price with a document-type preset's mode (from the server). | |
--pages | string | Pages to parse, for example 1-5,8. |
Examples
Cost of a folder before parsing it
untern-parsing estimate ./invoices --jsonuntern-parsing extract
Extract schema fields with evidence from a parsed job, a result or a file.
SOURCE is a completed job id, a file or an https URL (parsed first, then waited for); --result-id names a result instead. --schema is a JSON Schema file in the supported subset (checked locally, exit 2 invalid_schema with details.path) or a server schema NAME@VERSION from schemas list. GET /api/schemas runs first, so an API without extractions is exit 11 before any upload. POST /api/extractions with an Idempotency-Key; --wait long-polls GET /api/extractions/{id} until it finishes (failed: exit 1 extraction_failed; deadline: exit 7, the extraction keeps running). --max-credits is a ceiling for the parse and the extraction together (the API refuses above it: exit 13); credits from the API's X-Credits-* headers are in the output. --dry-run is offline and prints the plan.
- JSON output:
Extraction - NDJSON events:
item.uploading,item.submitted,job.status,extraction.status,file.written,warning,result,error - Scopes:
documents:write - Network: Yes
- Side effects: creates_jobs
- Idempotent: No
- MCP tool:
extract_fields - Exit codes:
0,1,2,3,4,5,6,7,8,9,10,11,13
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
source | string | No | A completed job id, a file or an https URL (omit with --result-id). |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--schema | string | JSON Schema file (subset of CLI-CONTRACT §5.6) or a server schema NAME@VERSION. | |
--result-id | string | Extract from this result id instead of a job or file. | |
--instructions | string | Extra guidance for the model (at most 4000 characters). | |
--instructions-file | path | Read the instructions from this UTF-8 file. | |
--no-require-evidence | boolean | Keep values without a verified quote (at lower confidence) instead of dropping them. | |
--idempotency-key | string | Same key, same request: the same extraction comes back (a file's parse uses :parse). | |
--max-credits | integer | Ceiling for this call (parse and extraction); exit 13 above it. | |
--wait | boolean | Wait until the extraction finishes. | |
--timeout | number | 600 s | Deadline for the parse of a file and, with --wait, the extraction. |
--output-dir | path | Also write the Extraction as .extraction.json into this directory. | |
--dry-run | boolean | Check the schema and inputs; send nothing. |
Examples
Invoice fields from a parsed job, waiting for the answer
untern-parsing extract <job-id> --schema invoice@1 --wait --jsonParse a file and extract with your own schema
untern-parsing extract contract.pdf --schema fields.json --wait --max-credits 200 --jsonCheck a schema offline
untern-parsing extract <job-id> --schema fields.json --dry-run --jsonuntern-parsing extractions get
Show an extraction; with --wait, wait until it finishes.
GET /api/extractions/{id} (long poll with --wait). Without --wait the exit code is 0 whatever the status; with --wait a failed extraction is exit 1 extraction_failed and the deadline exit 7 (the extraction keeps running).
- JSON output:
Extraction - NDJSON events:
extraction.status,result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
get_extraction - Exit codes:
0,1,3,4,5,7,8,9,10,11
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
id | string | Yes | Extraction id. |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--wait | boolean | Wait until the extraction finishes. | |
--timeout | number | 600 s | With --wait: deadline. |
Examples
Wait for an extraction
untern-parsing extractions get <extraction-id> --wait --jsonuntern-parsing jobs cancel
Cancel jobs that have not started.
POST /api/tasks/{task_id}/cancel. A pending job ends failed with error.code cancelled; a running job answers not_cancellable and a finished one conflict (exit 6, details.status). Stops at the first refusal and prints the jobs already cancelled. Exit 11 on an API without cancel.
- JSON output:
JobList - NDJSON events:
result,error - Scopes:
documents:write - Network: Yes
- Side effects: cancels_jobs
- Idempotent: Yes
- MCP tool:
cancel_job - Exit codes:
0,3,4,5,6,9,10,11
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
id | string | Yes | Yes | Job ids. |
Examples
Cancel a queued job
untern-parsing jobs cancel <job-id> --jsonuntern-parsing jobs get
Show one job: status, result id, error, source.
GET /api/tasks/{task_id}, or the status route on an API without it. Exit 0 whatever the job's status; read status and error.
- JSON output:
Job - NDJSON events:
result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
get_job - Exit codes:
0,3,4,5,9,10
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
id | string | Yes | Job id (the task_id parse printed). |
Examples
Status of a job
untern-parsing jobs get <job-id> --jsonuntern-parsing jobs list
List this credential's parse jobs, newest first.
GET /api/tasks with an opaque cursor. --all follows cursors up to --max-items; with --ndjson each job is an item event and the final result carries only count and next_cursor. Exit 11 on an API without the task list.
- JSON output:
JobList - NDJSON events:
item,result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
list_jobs - Exit codes:
0,2,3,4,8,9,10,11
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--status | string | Only jobs in this status (repeatable). | |
--limit | integer | 20 | Page size, 1-100. |
--cursor | string | next_cursor of the previous page. | |
--all | boolean | Follow cursors to the end. | |
--max-items | integer | 10000 | With --all: stop after this many jobs. |
Examples
Failed jobs
untern-parsing jobs list --status failed --jsonEvery job as a stream
untern-parsing jobs list --all --ndjsonuntern-parsing jobs wait
Wait until jobs finish; exit 0 completed, 1 failed, 7 timeout.
Uses the API's long poll for one job and polls with backoff (1 s x1.5, at most 10 s) for several, or every --interval seconds. --timeout 0 checks once. A timeout never cancels work: the jobs keep running and jobs wait can be called again.
- JSON output:
JobList - NDJSON events:
job.status,result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
wait_for_job - Exit codes:
0,1,3,4,5,7,8,9,10
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
id | string | Yes | Yes | Job ids. |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--timeout | number | 600 s | Overall deadline; 0 checks once. |
--interval | number | Fixed polling interval instead of backoff and long poll. |
Examples
Wait up to 2 minutes
untern-parsing jobs wait <job-id> --timeout 120 --jsonuntern-parsing parse
Parse files, folders or https URLs; optionally wait and download the results.
One job per input (POST /api/files/process with an Idempotency-Key). Without --wait, exit 0 once every input is accepted. With --wait, poll until the jobs finish or --timeout, then write each --format (md, json, html, chunks, zip) into --output-dir with the API's defaults (en, its chunk size). --max-credits asks for an estimate first and submits nothing above it (exit 13). Prints the ParseRun even when an input failed; the error is the last stderr line. --dry-run is offline.
- JSON output:
ParseRun - NDJSON events:
item.planned,item.uploading,item.submitted,job.status,file.written,item.completed,item.failed,warning,result,error - Scopes:
documents:write - Network: Yes
- Side effects: creates_jobs
- Idempotent: No
- MCP tool:
parse_document - Exit codes:
0,1,2,3,4,6,7,8,9,10,11,13
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
input | path | Yes | Yes | Files, folders or https URLs (folders: top level, or every level with --recursive). |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--mode | string | Parse mode, one the server enables (see doctor). | |
--preset | string | Document-type preset from the server (sets mode and options; see the modes route). | |
--pages | string | Pages to parse, server syntax, for example 1-5,8. | |
--recursive | boolean | Walk folders into every level. | |
--include | string | In folders: only files matching this glob (repeatable). | |
--exclude | string | In folders: skip files matching this glob (repeatable). | |
--project | string | Project name stored with the file. | |
--group | string | Sub-group stored with the file. | |
--force-reparse | boolean | Parse again even when a cached result exists. | |
--version-check | boolean | Re-parse when the cached result is from an older parser. | |
--idempotency-key | string | Makes reruns safe: one input uses K, several use K/. | |
--max-credits | integer | Refuse (exit 13, nothing sent) when the estimate is above N; sent with each job. | |
--wait | boolean | Wait for the jobs to finish. | |
--timeout | number | 600 s | With --wait: overall deadline; 0 checks once. |
--format | string | With --wait: download this format (repeatable; md, json, html, chunks, zip). | |
--output-dir | path | Where --format writes . (default ./untern-parsing-out). | |
--concurrency | integer | 4 | Uploads in parallel, 1-16. |
--dry-run | boolean | Validate and print the plan; no network, no credential. |
Examples
Parse a PDF and save Markdown
untern-parsing parse report.pdf --wait --format md --output-dir out --jsonSubmit a folder and return at once
untern-parsing parse ./invoices --recursive --jsonSafe rerun in CI with a credit ceiling
untern-parsing parse a.pdf --idempotency-key ci-run-0042 --max-credits 200 --jsonSee what would be sent
untern-parsing parse ./docs --dry-run --jsonuntern-parsing result get
Download a completed job's result as Markdown, Document JSON, HTML, chunks or ZIP.
Looks the job up, then reads one route: md …/download/markdown, json …/document.json (the Document as the server wrote it; its schema_version is checked), html …/document.html (--lang), chunks …/chunks (one chunk per line, --max-chunk-chars), zip …/download/zip. Without a path the artifact goes to stdout as is; a ZIP needs -o or --output-dir and is never extracted. An API without the document routes is exit 11; a result too large for json, html or chunks is result_too_large (exit 11). A job that has not completed is not_ready (exit 6) unless --wait.
- JSON output:
ResultFiles - NDJSON events:
job.status,file.written,warning,result,error - Scopes:
documents:read - Network: Yes
- Side effects: writes_local_files
- Idempotent: Yes
- MCP tool:
read_result - Exit codes:
0,1,2,3,4,5,6,7,9,10,11
Arguments
| Argument | Type | Required | Repeated | Description |
|---|---|---|---|---|
id | string | Yes | Job id. |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--format | string | md | Result format: md, json (Document), html, chunks (NDJSON) or zip. |
--output | path | Write to this file. | |
--output-dir | path | Write . into this directory. | |
--lang | string | With --format html: language of the page (BCP 47, default en). | |
--max-chunk-chars | integer | With --format chunks: largest chunk in characters (200-4000; default the API's). | |
--wait | boolean | Wait for the job first if it is still running. | |
--timeout | number | 600 s | With --wait: deadline. |
Examples
Markdown to stdout
untern-parsing result get <job-id> --format mdDocument JSON to a file
untern-parsing result get <job-id> --format json -o doc.json --jsonChunks for a RAG index, one per line
untern-parsing result get <job-id> --format chunks --max-chunk-chars 1000ZIP with images into a folder
untern-parsing result get <job-id> --format zip --output-dir out --jsonuntern-parsing schema
Print the machine-readable description of every command, flag, model and code.
Always JSON, offline and deterministic. Contains global flags, environment variables, config keys, exit codes, error codes (with origin server or local and a hint), each command's arguments, flags, output model, exit codes, scopes, side effects and examples, and the JSON Schema of every output model under $defs.
- NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: none
- Idempotent: Yes
- Exit codes:
0,1,2
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--command | string | Only this command, for example "jobs wait". | |
--kind | string | Only the JSON Schema of the model with this kind, for example job. | |
--check | path | Compare with this file instead of printing; exit 1 (stale_file) when it differs. |
Examples
Whole description
untern-parsing schemaJSON Schema of the job model
untern-parsing schema --kind jobCI: is the committed copy current?
untern-parsing schema --check contracts/cli-schema.jsonuntern-parsing schemas list
List the server schemas extract accepts as --schema NAME@VERSION.
GET /api/schemas: each schema's ref, title, description and JSON Schema.
- JSON output:
SchemaList - NDJSON events:
result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
list_schemas - Exit codes:
0,3,4,8,9,10,11
Examples
Server schemas
untern-parsing schemas list --jsonuntern-parsing setup
Configure every agent client found here (plugin, remote MCP, CLI on PATH), then run doctor.
Detects Claude Code, Codex, Cursor, VS Code, Claude Desktop, Windsurf, CI and the terminal from executables on PATH and config directories under HOME (never starting a client), and ensures one entry named untern-lens per client: the untern-parsing plugin where plugins exist, the remote MCP config otherwise, the CLI on PATH for terminals, a snippet for clients it cannot configure. Configs reference UNTERN_PARSING_TOKEN (VS Code asks once and stores the key itself); a key read from stdin or a hidden prompt goes to the credential store, never into a file. Idempotent; every change is recorded and --uninstall removes exactly those.
- JSON output:
SetupResult - NDJSON events:
result,error - Scopes: None
- Network: Yes
- Side effects: writes_config
- Idempotent: Yes
- Exit codes:
0,1,2,3
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--for | string | auto | Targets: auto (default) or a comma-separated list of claude-code, codex, cursor, vscode, claude-desktop, windsurf, mcp-json, ci, python, terminal. |
--yes | boolean | Never prompt (implied when stdin or stderr is not a terminal, and in CI). | |
--dry-run | boolean | Print the plan; write nothing, run no client command. | |
--uninstall | boolean | Remove exactly what earlier setups added. | |
--purge-credentials | boolean | With --uninstall: also delete the stored key. | |
--marketplace | string | Plugin marketplace source (path or owner/repo). |
Examples
See what setup would do
untern-parsing setup --dry-run --jsonConfigure Claude Code and Codex only
untern-parsing setup --for claude-code,codex --yesUndo everything setup did
untern-parsing setup --uninstalluntern-parsing usage
Show the plan, credits used and left, and this key's budget.
Reads GET /api/me/usage: credits, or pages left on page-capped plans (Free), the token's budget and the launch stage (Preview, from the API's preview block). Numbers come from the API; the CLI never computes prices. Exit 11 while the API does not offer usage, or billing_unavailable while billing is off on the server.
- JSON output:
Usage - NDJSON events:
result,error - Scopes:
documents:read - Network: Yes
- Side effects: none
- Idempotent: Yes
- MCP tool:
get_usage - Exit codes:
0,2,3,4,8,9,10,11
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--period | string | current | Which billing period. |
Examples
Credits left
untern-parsing usage --jsonuntern-parsing version
Print the CLI, API contract, SDK and Python versions, and the launch stage.
Offline. The api_contract field names the OpenAPI contract version this CLI was built from; compare it with the server using openapi --check when that command is available.
- JSON output:
VersionInfo - NDJSON events:
result,error - Scopes: None
- Network: No
- Side effects: none
- Idempotent: Yes
- Exit codes:
0
Examples
Versions as JSON
untern-parsing version --jsonExit codes
| Code | Name | Retryable | Description |
|---|---|---|---|
0 | ok | No | Success. |
1 | failed | No | The command ran and the outcome is negative (a job failed, a gate failed, a check failed). Read the result's items or checks; do not resubmit blindly. |
2 | usage | No | Wrong command, flag or input. Fix the call. |
3 | auth_required | No | No valid credential. Set UNTERN_PARSING_TOKEN or run auth login. |
4 | permission | No | The credential is valid but not allowed to do this (missing scope or blocked at the edge). |
5 | not_found | No | The job, file or result does not exist, or it expired. |
6 | conflict | No | The request conflicts with the current state (not ready yet, idempotency key reused). |
7 | timeout | Yes | --timeout was reached. Work continues on the server; wait for the job again. |
8 | unavailable | Yes | Rate limited or the service is busy. Retry after retry_after_s. |
9 | server | No | The server failed or answered outside the contract. Report request_id. |
10 | network | Yes | The API could not be reached (DNS, connect, TLS, proxy). |
11 | unsupported | No | The server does not offer this operation or format. Use another format or a newer server. |
12 | internal | No | A bug in the CLI. Report the incident id. |
13 | credits | No | Out of credits or pages, over a budget or a Preview cap, above --max-credits, or the parse mode is not in the plan. Run usage; nothing more was submitted. |
130 | interrupted | No | Stopped by SIGINT or SIGTERM. Jobs already submitted keep running; their ids were printed. |
Error codes
| Code | Exit code | Retryable | Description | Hint |
|---|---|---|---|---|
auth_denied | 3 | No | The device login was denied in the browser. | |
auth_required | 3 | No | No credential: UNTERN_PARSING_TOKEN is not set and no login is stored for the profile. | Create an API key in the unfold. portal (API keys page) and set UNTERN_PARSING_TOKEN, or run: untern-parsing auth login |
auth_timeout | 3 | No | The device login code expired before approval. | |
bad_response | 9 | No | The server's answer could not be parsed or broke the contract. | |
billing_unavailable | 11 | No | Billing is off on this server: it offers no usage or estimate, and charges nothing. | Parse without --max-credits checks; usage and estimate work once billing is on. |
blocked_by_access | 4 | No | A Cloudflare Access login page answered instead of the API. | Check UNTERN_PARSING_API_URL; the API hostname must not be behind Access. |
budget_exceeded | 13 | No | This credential's credit budget is used up. | Run untern-parsing usage; raise the key's budget in the portal or use another key. |
busy | 8 | Yes | The parser is at capacity; wait retry_after_s. | |
capacity_limit | 13 | No | A capacity cap of the plan's tier is reached (details.scope, details.resets_at). | Run untern-parsing usage; follow details.next_step or wait for details.resets_at. |
cli_internal_error | 12 | No | A bug in the CLI; the message carries an incident id. | Report the incident id; set UNTERN_PARSING_DEBUG=1 to see the traceback locally. |
config_invalid | 2 | No | A setting is missing or invalid (config file, env var or flag). | |
conflict | 6 | No | The request conflicts with the resource's state. | |
contract_mismatch | 9 | No | The server's API contract does not match this CLI. | |
doctor_failed | 1 | No | At least one doctor check failed; see checks[]. | |
extraction_failed | 1 | No | An extraction finished with status failed. | |
file_not_found | 2 | No | An input path does not exist or is not readable. | |
forbidden | 4 | No | The credential may not do this. | |
gone | 5 | No | The result expired; parse the document again. | |
idempotency_conflict | 6 | No | The idempotency key was already used for a different request. | Use a new --idempotency-key. |
insufficient_scope | 4 | No | The credential lacks the scope named in details.missing_scope. | Create a key with that access in the portal (API keys page). |
insufficient_storage | 8 | Yes | The server is out of storage. | |
internal_error | 9 | No | The server failed; report request_id. | |
interrupted | 130 | No | Stopped by SIGINT or SIGTERM. | |
invalid_input | 2 | No | The request or an input value is invalid. | |
invalid_schema | 2 | No | The extraction schema is outside the supported subset, or the server schema is unknown (details.path; checked locally before sending, and by the API with 422). | Fix the node at details.path (CLI-CONTRACT §5.6), or pick a ref from untern-parsing schemas list. |
job_failed | 1 | No | A parse job finished with status failed. | |
length_required | 2 | No | The upload had no Content-Length. | |
limit_exceeded | 13 | No | The file has more pages than the plan allows in one file. | Parse fewer pages (--pages), split the file, or upgrade the plan in the unfold. portal (Plan and billing page). |
max_credits_exceeded | 13 | No | The estimate is above --max-credits; nothing was submitted. | Raise --max-credits, or reduce the work (--pages, another --mode, fewer files). |
metadata_required | 2 | No | An estimate item named a file_id that has no result in this mode yet (item error). | Estimate the local file instead, so its metadata is sent. |
mode_not_in_plan | 13 | No | The parse mode is not included in the account's plan (details.mode, details.allowed_modes). | Use a mode from details.allowed_modes, or upgrade the plan in the unfold. portal (Plan and billing page). |
mode_unavailable | 11 | No | The parse mode is not enabled on this server (details.mode, details.available). | Pick one of details.available, or run untern-parsing doctor to list the server's modes. |
network_error | 10 | Yes | The API could not be reached. | |
not_cancellable | 6 | No | The job is already running and cannot be stopped (details.status). | Wait for it: untern-parsing jobs wait |
not_found | 5 | No | No such job, file or result for this credential. | |
not_ready | 6 | Yes | The job has not completed yet. | Run: untern-parsing jobs wait |
partial_failure | 1 | No | Some inputs failed; see items[]. | |
payload_too_large | 2 | No | The file is larger than the upload limit. | |
payment_required | 13 | No | No credits left on the plan. | Run untern-parsing usage; the account owner adds credits in the portal. |
preview_limit | 13 | No | A Preview cap is reached: details.scope is key, account or global; details.resets_at says when it renews. | Run untern-parsing usage; follow details.next_step (raise the key's cap, ask for more in the portal, or wait for details.resets_at). |
proxy_error | 10 | Yes | The HTTPS proxy refused or failed the connection. | |
quality_gate_failed | 1 | No | A --min-* quality threshold was not met. | |
quota_exceeded | 13 | No | The plan's limit for this period is reached. | Run untern-parsing usage; wait for the next period or change the plan in the portal. |
rate_limited | 8 | Yes | Too many requests; wait retry_after_s. | |
result_too_large | 11 | No | This result is too large for the requested format. | Use --format md or --format zip. |
service_unavailable | 8 | Yes | A service behind the API is unavailable (for extraction: no model provider is configured on this server). | Retry later; if it persists, the server's operator must configure the service. |
setup_incomplete | 1 | No | Setup could not finish every action. | |
spend_cap_reached | 13 | No | The account's monthly spending cap would be passed. | Run untern-parsing usage; the account owner raises the cap in the portal. |
stale_file | 1 | No | A generated file differs from what this version produces (schema --check). | Regenerate it: untern-parsing schema > contracts/cli-schema.json |
storage_unavailable | 8 | Yes | Object storage is unavailable. | |
timeout | 7 | Yes | --timeout was reached; the work continues on the server. | Run: untern-parsing jobs wait |
tls_error | 10 | Yes | The TLS handshake or certificate check failed. | |
token_expired | 3 | No | The stored login expired and could not be refreshed. | Run: untern-parsing auth login |
unauthenticated | 3 | No | The API rejected the credential (revoked, expired or mistyped). | Create a new API key in the portal and set UNTERN_PARSING_TOKEN, or run: untern-parsing auth login |
unsupported | 11 | No | The server does not offer this operation or format (details.operation). | |
unsupported_media_type | 2 | No | The file type is not supported. | |
upstream_unavailable | 8 | Yes | The API or a proxy in front of it answered 502 or 504 without an error code. | |
usage | 2 | No | Unknown command or flag, or a missing argument. |
Output models
AuthStatus
| Property | Type | Required | Description |
|---|---|---|---|
kind | "auth_status" | No | Default: auth_status. |
schema_version | "1" | No | Default: 1. |
authenticated | boolean | Yes | |
source | string, one of env, keychain, file, token, none | Yes | |
credential | string, one of api_key, oidc, unknown or null | No | Default: null. |
key_hint | string or null | No | "ulk_…AB12" for API keys only. Default: null. |
principal | string or null | No | Default: null. |
name | string or null | No | Default: null. |
email | string or null | No | Default: null. |
roles | array of string | No | |
scopes | array of string | No | |
expires_at | string (date-time) or null | No | Default: null. |
api_url | string or null | No | Default: null. |
profile | string or null | No | Default: null. |
issuer | string or null | No | Default: null. |
BoxRef
A box on a page, top-left origin, in the page's unit (same fields as untern_docai.BBox).
| Property | Type | Required | Description |
|---|---|---|---|
x0 | number | Yes | |
y0 | number | Yes | |
x1 | number | Yes | |
y1 | number | Yes |
Budget
| Property | Type | Required | Description |
|---|---|---|---|
limit | number | Yes | |
used | number | Yes | |
remaining | number | Yes | |
period | string or null | No | Default: null. |
Check
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | |
status | string, one of ok, warn, fail, skip | Yes | |
message | string | Yes | |
hint | string or null | No | Default: null. |
ChunkPage
| Property | Type | Required | Description |
|---|---|---|---|
kind | "chunk_page" | No | Default: chunk_page. |
schema_version | "1" | No | Default: 1. |
result_id | string | Yes | |
items | array of map of JsonValue | Yes | untern_docai.Chunk objects. |
next_cursor | string or null | Yes |
CliError
The error object; stderr carries {"error": CliError}.
A superset of untern-common ErrorResponse (code, message, request_id).
| Property | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Stable error code (see the error_codes table). |
message | string | Yes | One sentence; never a secret or document content. |
exit_code | integer | Yes | The process exit code this error produces. |
retryable | boolean | Yes | True when the same call may succeed later unchanged. |
hint | string or null | No | The next action to take. Default: null. |
http_status | integer or null | No | HTTP status from the API, if any. Default: null. |
request_id | string or null | No | X-Request-ID of the failed request. Default: null. |
retry_after_s | number or null | No | Seconds to wait before retrying. Default: null. |
details | map of JsonValue | No | Machine-readable context. |
ConfigView
| Property | Type | Required | Description |
|---|---|---|---|
kind | "config" | No | Default: config. |
schema_version | "1" | No | Default: 1. |
path | string | Yes | |
profile | string | Yes | |
values | map of string or integer or boolean or null | Yes | Never contains a secret. |
DoctorReport
| Property | Type | Required | Description |
|---|---|---|---|
kind | "doctor" | No | Default: doctor. |
schema_version | "1" | No | Default: 1. |
ok | boolean | Yes | |
checks | array of Check | Yes | |
cli_version | string | Yes | |
api_contract | string or null | No | Default: null. |
server_version | string or null | No | Default: null. |
usage | Usage or null | No | Default: null. |
stage | string or null | No | Launch stage, e.g. "Preview". Default: null. |
DocumentWindow
| Property | Type | Required | Description |
|---|---|---|---|
kind | "document_window" | No | Default: document_window. |
schema_version | "1" | No | Default: 1. |
result_id | string | Yes | |
page_count | integer | Yes | |
from_page | integer | Yes | |
to_page | integer | Yes | |
document | map of JsonValue | Yes | An untern_docai.Document with only these pages. |
ErrorEnvelope
| Property | Type | Required | Description |
|---|---|---|---|
error | CliError | Yes |
Estimate
| Property | Type | Required | Description |
|---|---|---|---|
kind | "estimate" | No | Default: estimate. |
schema_version | "1" | No | Default: 1. |
items | array of EstimateItem | Yes | |
total_credits | number | Yes | |
complete | boolean or null | No | False when an item could not be priced (see its error). Default: null. |
credits_remaining | number or null | No | Default: null. |
within_balance | boolean or null | No | Default: null. |
rates_version | string or null | No | Default: null. |
quote_expires_at | string (date-time) or null | No | Until when these rates apply (the API quotes for 15 minutes); estimate again after it. Default: null. |
EstimateItem
| Property | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The file as given to the CLI (the API does not echo it). |
mode | string or null | No | Default: null. |
pages | integer or null | No | Default: null. |
credits | number or null | Yes | Upper bound for this item (the most it can cost); null when the API could not price it (see error). |
credits_expected | number or null | No | The likely cost (pages with an unknown text layer priced as text pages); equal to credits when every page is known. Default: null. |
exactness | string, one of exact, upper_bound or null | No | Default: null. |
cached | boolean | No | Default: false. |
basis | string or null | No | The server's explanation of the number. Default: null. |
error | CliError or null | No | Why this item has no price (e.g. metadata_required). Default: null. |
Event
One NDJSON line. Fields beyond type/seq/ts depend on the type (CLI-CONTRACT §6).
| Property | Type | Required | Description |
|---|---|---|---|
type | string, one of started, auth.device_code, item.planned, item.uploading, item.submitted, job.status, extraction.status, file.written, item.completed, item.failed, item, warning, result, error | Yes | |
seq | integer | Yes | At least 1. |
ts | string (date-time) | Yes |
Evidence
| Property | Type | Required | Description |
|---|---|---|---|
block_id | string | Yes | |
page | integer | Yes | |
quote | string | Yes | |
bbox | BoxRef or null | No | Default: null. |
reanchored | boolean | No | Default: false. |
ExtractedField
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | |
value | JsonValue | No | Default: null. |
status | string, one of ok, missing, unsupported, invalid | Yes | |
confidence | number | Yes | |
evidence | array of Evidence | No | |
message | string or null | No | Default: null. |
Extraction
| Property | Type | Required | Description |
|---|---|---|---|
kind | "extraction" | No | Default: extraction. |
schema_version | "1" | No | Default: 1. |
id | string | Yes | |
status | string, one of pending, processing, completed, failed | Yes | |
terminal | boolean | Yes | |
job_id | string or null | Yes | |
result_id | string | Yes | |
schema_ref | string | Yes | "NAME@VERSION" or "inline:sha256:<12 hex>". |
data | map of JsonValue or null | No | Default: null. |
fields | map of ExtractedField | No | |
needs_review | array of string | No | |
errors | array of string | No | |
prompt_ref | string or null | No | Default: null. |
error | ServerError or null | No | Default: null. |
credits | JobCredits or null | No | From the X-Credits-* headers of the API's last answer (its body has no credits); never computed by the CLI. Default: null. |
ExtractionPlan
What extract --dry-run would do; nothing is sent.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "extraction_plan" | No | Default: extraction_plan. |
schema_version | "1" | No | Default: 1. |
dry_run | true | No | Default: true. |
source | SourceRef or null | No | The file to parse first, if any. Default: null. |
job_id | string or null | No | Default: null. |
result_id | string or null | No | Default: null. |
schema_ref | string | Yes | "NAME@VERSION" or "inline:sha256:<12 hex>". |
require_evidence | boolean | No | Default: true. |
planned_requests | array of PlannedRequest | Yes |
Gate
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | |
threshold | number | Yes | |
actual | number | Yes | |
passed | boolean | Yes |
Job
| Property | Type | Required | Description |
|---|---|---|---|
kind | "job" | No | Default: job. |
schema_version | "1" | No | Default: 1. |
id | string | Yes | Server task id. |
file_id | string or null | No | Default: null. |
result_id | string or null | No | Set when the job completed. Default: null. |
status | string, one of pending, processing, completed, failed, cancelled | Yes | |
terminal | boolean | Yes | True for completed, failed and cancelled. |
cache_hit | boolean | No | Default: false. |
retryable | boolean | No | Default: false. |
mode | string or null | No | Default: null. |
pages | string or null | No | Default: null. |
source | SourceRef or null | No | Default: null. |
created_at | string (date-time) or null | No | Default: null. |
updated_at | string (date-time) or null | No | Default: null. |
error | ServerError or null | No | Default: null. |
idempotency_key | string or null | No | Default: null. |
credits | JobCredits or null | No | Credits as the API reports them; never computed by the CLI. Default: null. |
JobCredits
| Property | Type | Required | Description |
|---|---|---|---|
reserved | number or null | No | Default: null. |
charged | number or null | No | Default: null. |
refunded | number or null | No | Default: null. |
max_credits | number or null | No | The guard sent with the job, if any. Default: null. |
JobList
| Property | Type | Required | Description |
|---|---|---|---|
kind | "job_list" | No | Default: job_list. |
schema_version | "1" | No | Default: 1. |
items | array of Job | Yes | |
next_cursor | string or null | No | Opaque; pass to --cursor. Default: null. |
count | integer or null | No | With --all: jobs returned (or streamed as item events). Default: null. |
JsonValue
Type: any.
OutputFile
| Property | Type | Required | Description |
|---|---|---|---|
path | string | Yes | As written; relative to the working directory when under it. |
format | string, one of md, json, html, chunks, zip | Yes | |
media_type | string | Yes | |
bytes | integer | Yes | |
sha256 | string | Yes |
ParseItem
| Property | Type | Required | Description |
|---|---|---|---|
input | string | Yes | |
status | string, one of planned, submitted, completed, failed, skipped | Yes | |
job | Job or null | No | Default: null. |
outputs | array of OutputFile | No | |
error | CliError or null | No | Default: null. |
skipped_reason | string or null | No | Default: null. |
ParseRun
| Property | Type | Required | Description |
|---|---|---|---|
kind | "parse_run" | No | Default: parse_run. |
schema_version | "1" | No | Default: 1. |
dry_run | boolean | Yes | |
waited | boolean | Yes | |
items | array of ParseItem | Yes | |
summary | RunSummary | Yes | |
planned_requests | array of PlannedRequest | No |
PlannedRequest
What --dry-run would send; never contains a credential.
| Property | Type | Required | Description |
|---|---|---|---|
method | string | Yes | |
path | string | Yes | |
idempotency_key | string or null | No | Default: null. |
body_bytes | integer or null | No | Default: null. |
note | string or null | No | Default: null. |
QualityEval
| Property | Type | Required | Description |
|---|---|---|---|
kind | "quality_eval" | No | Default: quality_eval. |
schema_version | "1" | No | Default: 1. |
report | map of JsonValue | Yes | untern_docai QualityReport.to_dict(), verbatim. |
gates | array of Gate | Yes | |
passed | boolean | Yes |
ResultFiles
| Property | Type | Required | Description |
|---|---|---|---|
kind | "result" | No | Default: result. |
schema_version | "1" | No | Default: 1. |
job_id | string or null | Yes | |
result_id | string | Yes | |
files | array of OutputFile | Yes |
ResultWindow
| Property | Type | Required | Description |
|---|---|---|---|
kind | "result_window" | No | Default: result_window. |
schema_version | "1" | No | Default: 1. |
result_id | string | Yes | |
format | string, one of markdown, html | Yes | |
content | string | Yes | |
offset | integer | Yes | |
next_offset | integer or null | Yes | |
total_chars | integer | Yes | |
truncated | boolean | Yes |
RunSummary
| Property | Type | Required | Description |
|---|---|---|---|
total | integer | Yes | |
planned | integer | Yes | |
submitted | integer | Yes | |
completed | integer | Yes | |
failed | integer | Yes | |
skipped | integer | Yes |
SchemaInfo
A server schema from GET /api/schemas (pass ref to extract --schema).
| Property | Type | Required | Description |
|---|---|---|---|
ref | string | Yes | "NAME@VERSION". |
title | string | Yes | |
description | string | Yes | |
json_schema | map of JsonValue | Yes |
SchemaList
| Property | Type | Required | Description |
|---|---|---|---|
kind | "schema_list" | No | Default: schema_list. |
schema_version | "1" | No | Default: 1. |
items | array of SchemaInfo | Yes |
ServerError
Why a job or extraction failed, as the API reports it.
| Property | Type | Required | Description |
|---|---|---|---|
code | string | Yes | |
message | string | Yes | |
retryable | boolean | No | Default: false. |
SetupAction
| Property | Type | Required | Description |
|---|---|---|---|
target | string | Yes | |
kind | string, one of plugin_install, mcp_config, cli_install, shell_profile, keychain, snippet | Yes | |
path | string or null | No | Default: null. |
command | string or null | No | Client command run, credentials redacted. Default: null. |
status | string, one of done, unchanged, planned, manual, failed, skipped | Yes | |
detail | string or null | No | Default: null. |
SetupResult
| Property | Type | Required | Description |
|---|---|---|---|
kind | "setup" | No | Default: setup. |
schema_version | "1" | No | Default: 1. |
targets | array of string | Yes | |
actions | array of SetupAction | Yes | |
doctor | DoctorReport or null | No | Default: null. |
uninstalled | boolean | No | Default: false. |
SourceRef
| Property | Type | Required | Description |
|---|---|---|---|
input | string or null | No | Argument given: path as typed, URL without query. Default: null. |
name | string | Yes | File name sent to the server. |
size_bytes | integer or null | No | Default: null. |
sha256 | string or null | No | Computed locally. Default: null. |
md5 | string or null | No | Content identity reported by the server. Default: null. |
Usage
Plan and credits as GET /api/me/usage reports them (api-evolution #74).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "usage" | No | Default: usage. |
schema_version | "1" | No | Default: 1. |
plan | map of JsonValue | Yes | |
period_start | string (date-time) or null | No | Default: null. |
period_end | string (date-time) or null | No | Default: null. |
credits_included | number or null | No | Default: null. |
credits_used | number | Yes | |
credits_remaining | number or null | No | Default: null. |
credits_topup_remaining | number or null | No | Default: null. |
overage_allowed | boolean or null | No | Default: null. |
overage_used | number or null | No | Default: null. |
overage_cap | number or null | No | Default: null. |
token_budget | Budget or null | No | Default: null. |
pages_included | integer or null | No | Pages per period on page-capped plans (Free), from the API. Default: null. |
pages_used | integer or null | No | Default: null. |
pages_remaining | integer or null | No | Default: null. |
preview | UsagePreview or null | No | Preview state from the API (null when it reports none). Default: null. |
stage | string or null | No | Launch stage, e.g. "Preview": from the API's preview.enabled when it reports one, else this CLI's release. Default: null. |
as_of | string (date-time) | Yes |
UsagePreview
| Property | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | True while the product is in Preview. |
pool | string or null | No | The account's capacity pool (tier). Default: null. |
VersionInfo
| Property | Type | Required | Description |
|---|---|---|---|
kind | "version" | No | Default: version. |
schema_version | "1" | No | Default: 1. |
cli | string | Yes | |
api_contract | string or null | No | Default: null. |
sdk_docai | string or null | No | Default: null. |
python | string | Yes | |
stage | string or null | No | Launch stage, e.g. "Preview". Default: null. |