Router.law for developers: REST API and MCP

Router.law Forms fills official Ontario legal forms (Small Claims Court and FSRA accident benefits) from one client profile and checks them. You get back the filled official PDF and a report. Router.law never files or sends anything, and it does not give legal advice. A person must review every form before it is signed or filed.

Pilot: use fake test data only until Router.law announces that it accepts client information.

Using Router.law means accepting the developer terms (draft).

The fourteen tools

Both interfaces offer the same fourteen tools: seven from Router.law Forms, three from Router.law Files and four from Router.law Records.

Tool REST Scope What it does
list_forms GET /v1/forms?family=scc|ab specs:read Every supported form, with its purpose and who uses it
find_form POST /v1/forms/find specs:read Suggests forms for a situation, with reasons. Never chooses
get_form_spec GET /v1/forms/{id} specs:read The questions to ask, the input JSON Schema, the parts a person completes, and the filing and deadline notes
validate POST /v1/forms/{id}/validate forms:fill Status, issues and missing fields, each with a question. No PDF
fill_form POST /v1/forms/{id}/fill forms:fill The report plus the PDF (base64 over REST, an attached file over MCP)
fill_many POST /v1/fill-many forms:fill Up to 10 forms from one profile
check_form_updates GET /v1/forms/updates?form_id=7A specs:read The official version and SHA-256 that Router.law Forms fills now
get_file_context GET /v1/files/{matter_ref} files:read A file's stage, completed actions, outstanding items, key dates and document index (include_history=true for every change)
update_file POST /v1/files/{matter_ref} files:write Record work on a file. Listed values only; append-only
list_files GET /v1/files files:read This account's files, with filters
list_request_types GET /v1/records/request-types specs:read Record types, claim types, delivery methods, and the saved firm settings this key may use
prepare_records_request POST /v1/records/requests records:prepare Request letter (Word and PDF), General Direction, packet, follow-up schedule, Outlook reminder (.ics) and tracking row (.csv)
prepare_follow_up POST /v1/records/follow-ups records:prepare Follow-up letter (Word and PDF), updated tracking row, next follow-up date
prepare_payment_letter POST /v1/records/payment-letters records:prepare Cheque cover letter (Word and PDF) and a PCLaw disbursement note

Recommended agent flow

  1. find_form with the person's own words. Confirm the form with the person.
  2. get_form_spec to get the questions and the schema.
  3. Ask the person for the answers. Never invent them.
  4. validate. For each item in missing_fields or issues, ask the person its question, update the profile, and validate again.
    • Some questions are must ask (MUST_ASK, marked x-routerlaw-must-ask in the schema). The form isn't complete until each is asked. If the person can't answer, record it in no_answer, for example "no_answer": {"accident_benefits.accident.charged": "unknown"}. The value is "unknown" or "not_applicable", and the box stays blank.
  5. fill_form. Show the person the status and the outstanding_actions (for example: sign page 5). Remind them to review the form before filing.

Router.law Records

Records prepares records requests for personal injury files. It sends nothing and keeps nothing: the clerk reviews, signs and sends.

  1. list_request_types: the record types and the saved firm settings your key may use. Pass the saved id as firm, or send the firm's settings as an object (schemas/records/firm.schema.json).
  2. Ask the person which provider and from what date. Both are the lawyer's or clerk's decisions: never suggest a provider or choose a date.
  3. prepare_records_request with profile (client, incident, optional providers), provider (an object, or the id of one in profile.providers), request (schemas/records/request.schema.json) and firm. While anything is missing the status is incomplete, missing_fields has a question for each, and no letter is made.
  4. Keep records_request from the result: prepare_follow_up needs it later, with the follow-ups already sent ([{"number": 1, "date": "2026-12-21"}]).
  5. prepare_payment_letter when the provider invoices (schemas/records/invoice.schema.json). The amount is copied as invoiced; the cheque goes by mail or courier.

Files come back under files: over REST each as filename, media_type, sha256 and content_base64; over MCP as one zip behind a one-time, 10-minute download link (the local stdio server attaches the files instead, listed in files_attached).

curl -s https://router.law/v1/records/requests \
  -H "Authorization: Bearer $ROUTERLAW_KEY" -H "Content-Type: application/json" \
  -d '{"firm": "example-injury-law",
       "profile": {"client": {"first_name": "Jordan", "last_name": "Fictional",
                              "date_of_birth": "1988-02-14"},
                   "incident": {"type": "motor_vehicle_accident", "date_of_loss": "2026-03-10"}},
       "provider": {"name": "Dr. Pat Xample",
                    "address_lines": ["100 Sample Street, Suite 200", "Toronto, Ontario  M5V 0A0"],
                    "fax": "416-555-0150"},
       "request": {"file_number": "TEST-12345", "request_type": "clinical_notes_and_records",
                   "start_date": "2021-01-01", "delivery_method": "fax"}}'

REST

Authenticate with Authorization: Bearer rlk_.... Router.law issues keys.

curl -s https://router.law/v1/forms/find \
  -H "Authorization: Bearer $ROUTERLAW_KEY" -H "Content-Type: application/json" \
  -d '{"situation": "I was rear-ended last week and need to apply for accident benefits"}'

curl -s https://router.law/v1/forms/OCF-1/fill \
  -H "Authorization: Bearer $ROUTERLAW_KEY" -H "Content-Type: application/json" \
  -d @request.json | jq -r .pdf_base64 | base64 -d > OCF-1.pdf

request.json is {"profile": {...}, "flatten": false}. By default the PDF keeps its fillable boxes, so a person can make small corrections in Adobe Acrobat or another PDF editor; every box Router.law or the person fills can be changed. Set "flatten": true for a flattened final copy, with the text fixed on the page and no boxes. The form's own calculation scripts are removed for safety, so after a correction, totals don't update by themselves: correct the total too. You can add a "password" of 12 or more characters to encrypt the PDF with AES-256.

A few official forms exist only as Adobe forms (today, the Licence Appeal Tribunal Certificate of Service, LAT-COS). Router.law fills them, but they open only in Adobe Reader, their built-in checks are removed for safety, and no flattened copy can be made: "flatten": true returns the editable copy with a FLATTEN_UNAVAILABLE warning.

Every response includes api_version, requires_human_review: true, the form's version and hash. Results carry no repeated disclaimers: this page and the tool descriptions state the notice once.

Errors look like {"error": {"code": "...", "message": "..."}}:

Status Codes
401 unauthorized
403 insufficient_scope
400 invalid_matter_ref, invalid_file_update, invalid_filter
404 unknown_form, unknown_file
411 length_required
413 payload_too_large
422 invalid_request (lists the problem locations only)
429 rate_limited (with Retry-After)
503 files_unavailable

Messages never quote what you sent.

File numbers (matter_ref)

validate, fill_form and fill_many take an optional matter_ref: your firm's own file number for the matter, for example "matter_ref": "2026-0147". Never a client's name. Router.law Files then records, for each form, the outstanding items and (when a fill is complete) the completed form. No client details are kept. Your team can follow each file on the console's Files page.

Router.law Files

Files gives an agent context about the work on a file, keyed by the firm's file number. It never holds information about the client: no names, addresses, birthdates, health details, document contents or notes. Every value is a code from a fixed list, a form ID, or a date (YYYY-MM-DD). Anything else is refused with an error that says where the problem is and what is allowed.

Files needs its own scopes: files:read (get_file_context, list_files, the console Files page) and files:write (update_file, and any Forms call that carries a matter_ref). Router.law gives them only to a firm's team keys, on request.

Part Fields Allowed values
stage one code intake, accident_benefits_application, records_gathering, notice_served, application_filed, claim_issued, defence_filed, discoveries, mediation, settlement_conference, hearing_or_trial, settlement, decision, enforcement, appeal, closed
completed_actions action, form_id (optional), date form_filled, form_signed, form_sworn, form_served, form_filed, form_sent_to_insurer, records_requested, records_received, client_meeting, hearing_attended, mediation_attended, settlement_signed
outstanding_items, resolved_items item, form_id (optional) signature_needed, commissioner_needed, attachment_required, person_must_choose, calculation_needed, check_needed, complete_by_hand, service_required, missing_information, filing_required, payment_required, client_instructions_needed, other_step
key_dates type, date limitation_date, next_deadline, follow_up, filing_deadline, service_deadline, hearing_date, mediation_date, settlement_conference_date
documents type, received retainer, identification, filled_form, signed_form, court_or_tribunal_filing, notice, order_or_decision, correspondence, insurer_correspondence, medical_records, treatment_plan, police_report, employment_records, income_records, invoices_receipts, contract_or_lease, photos, expert_report, affidavit, other
curl -s https://router.law/v1/files/TEST-2026-0147 -X POST \
  -H "Authorization: Bearer $ROUTERLAW_KEY" -H "Content-Type: application/json" \
  -d '{"stage": "records_gathering",
       "key_dates": [{"type": "limitation_date", "date": "2028-10-01"}]}'

Tools and usage

MCP

Local (stdio): for development with the repository checked out. It runs the engine on your machine, needs no key, and makes no network calls:

{"mcpServers": {"routerlaw": {"command": "uv", "args": ["run", "python", "-m", "routerlaw.mcp_server"],
  "cwd": "/path/to/routerlaw"}}}

Limits

Limit Value
Tool calls 60 per minute per key
Fills 20 per minute per key
Request body 256 KB
Forms per fill_many 10

Keys (Router.law staff)

uv run python -m routerlaw.auth.keys create --label "pilot: name" --key-file ~/routerlaw-key.txt \
    --account marty-pilot --holder marty --traffic internal
uv run python -m routerlaw.auth.keys assign <key_id> jsmith     # name an older key's holder
uv run python -m routerlaw.auth.keys list marty-pilot            # an account's keys
uv run python -m routerlaw.auth.keys revoke <key_id>

The create command writes the key into a new file that only you can read; it never appears on screen. Move it into a password manager and delete the file. The command also prints a record (with the key's scrypt hash, not the key) to add to the ROUTERLAW_API_KEYS variable in Railway (D43). Revoking a key also ends every MCP connection made with it.

--account names the account the key belongs to (lowercase letters, digits and hyphens); usage is counted per account. --holder names the one person the key is for, as a short handle (jsmith), or an app with --holder-kind app: one key per person, never shared (D100). The console's Keys page shows every key of the account with its holder, what it can do, and the day it was last used. To name the holder of a key made earlier without editing ROUTERLAW_API_KEYS, set ROUTERLAW_KEY_HOLDERS to a list of key IDs and handles, for example {"euin2pxm": "marty"} (D101). --traffic internal marks our own products and testing, such as Claim.ca; leave it out for everyone else (external).