Skip to content

CLI Commands

On success, every command prints a JSON object to stdout and exits 0. On failure, it prints { "error": { "code", "message", ... } } to stderr and exits non-zero.

Global options:

  • --request-timeout-ms <ms> — per-request HTTP timeout (default 30000).
Terminal window
midlyr browse-document --query "provisional credit" --authority cfpb

Options: --query <text>, --categories <cat> (repeatable), --authority <name> (repeatable), --jurisdiction <code> (repeatable), --limit <n>, --cursor <token>.

Calls GET /api/v1/regulations/ and returns a paginated list of document summaries (id, title, jurisdictions, updatedAt). Does not return body content.

Terminal window
midlyr describe-document cmdoc_01HXZ3K4M7QR9VP2N8WYJF5GTB

Calls GET /api/v1/regulations/:id and returns metadata: title, authorities, jurisdictions, description, table of contents, sourceUrl, totalBytes, updatedAt. Does not return the body text.

Terminal window
midlyr read-document-content cmdoc_01HXZ3K4M7QR9VP2N8WYJF5GTB --offset 0 --limit 40000

Options: --offset <bytes>, --limit <bytes>.

Calls GET /api/v1/regulations/:id/content and returns the document body. Long documents are paged by byte range.

Terminal window
midlyr query-document --query "provisional credit timing" --authority cfpb --limit 5
midlyr query-document "provisional credit timing" # positional form

Required: --query <text> (positional args are also accepted as the query).

Optional: --limit <n> (1–50, default 10), and repeatable filter flags --id <id>, --authority <name>, --jurisdiction <code>.

Calls POST /api/v1/regulations/query and returns the top relevant regulation chunks for a natural-language query. This is a retrieval primitive — no LLM is invoked; the returned text is verbatim regulation source. Compose with your own model to build retrieval-augmented generation.

Terminal window
midlyr regulation-wikis list --domain bsa-aml

Options: --domain <slug>, --query <text>, --updated-since <iso8601>, --limit <n>, --cursor <token>.

Calls GET /api/v1/regulation-wikis and returns a paginated list of wiki summaries (slug, title, domain, description, sourceCount, updatedAt). Use this to discover available playbooks and find the slug for regulation-wikis get.

Terminal window
midlyr regulation-wikis get sar-filing

Required: positional <slug> argument.

Calls GET /api/v1/regulation-wikis/:slug and returns the full wiki object including the synthesized body (markdown) and the sources array of externalId slugs. Each slug in sources resolves to a regulation document via describe-document.

Example — fetch and follow sources:

Terminal window
# Get the SAR filing playbook
midlyr regulation-wikis get sar-filing
# Resolve the first source document
midlyr describe-document 31-cfr-1020-320
# Read its body text
midlyr read-document-content 31-cfr-1020-320 --offset 0 --limit 40000
Terminal window
midlyr screen-analysis \
--scenario dispute \
--text "we can't provide a provisional dispute credit until the investigation is completed"

Required: --scenario <type>, --text <content>. Valid scenarios: marketing_asset, dispute, debt_collection, complaint, generic.

Optional: --timeout-ms <ms> (total poll budget), --poll-interval-ms <ms>, --no-wait (submit only, return the job id without polling).

By default the CLI submits the job (POST /api/v1/analysis/screen) and polls (GET /api/v1/jobs/:id) until it terminates, printing the final job record with status, riskScore, and findings. With --no-wait, it returns the pending job immediately.

Terminal window
midlyr login

Opens a browser, completes an OAuth flow, provisions an API key, and writes credentials to ~/.config/midlyr/credentials.json. No arguments.

Terminal window
midlyr config set api-key <key>

Saves an API key to ~/.config/midlyr/credentials.json so subsequent commands can use it without MIDLYR_API_KEY. Prefer midlyr login for normal use.

  • MIDLYR_API_KEY — API key for authenticated requests. Falls back to the credentials file written by login / config set api-key.