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 (default30000).
Documents
Section titled “Documents”Browse
Section titled “Browse”midlyr browse-document --query "provisional credit" --authority cfpbOptions: --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.
Describe
Section titled “Describe”midlyr describe-document cmdoc_01HXZ3K4M7QR9VP2N8WYJF5GTBCalls GET /api/v1/regulations/:id and returns metadata: title, authorities, jurisdictions, description, table of contents, sourceUrl, totalBytes, updatedAt. Does not return the body text.
Read Content
Section titled “Read Content”midlyr read-document-content cmdoc_01HXZ3K4M7QR9VP2N8WYJF5GTB --offset 0 --limit 40000Options: --offset <bytes>, --limit <bytes>.
Calls GET /api/v1/regulations/:id/content and returns the document body. Long documents are paged by byte range.
midlyr query-document --query "provisional credit timing" --authority cfpb --limit 5midlyr query-document "provisional credit timing" # positional formRequired: --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.
Regulation Wikis
Section titled “Regulation Wikis”List Wikis
Section titled “List Wikis”midlyr regulation-wikis list --domain bsa-amlOptions: --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.
Get Wiki
Section titled “Get Wiki”midlyr regulation-wikis get sar-filingRequired: 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:
# Get the SAR filing playbookmidlyr regulation-wikis get sar-filing
# Resolve the first source documentmidlyr describe-document 31-cfr-1020-320
# Read its body textmidlyr read-document-content 31-cfr-1020-320 --offset 0 --limit 40000Analysis
Section titled “Analysis”Screen
Section titled “Screen”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.
Authentication
Section titled “Authentication”midlyr loginOpens a browser, completes an OAuth flow, provisions an API key, and writes credentials to ~/.config/midlyr/credentials.json. No arguments.
Config
Section titled “Config”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.
Environment
Section titled “Environment”MIDLYR_API_KEY— API key for authenticated requests. Falls back to the credentials file written bylogin/config set api-key.