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.
- Interactive reference:
https://router.law/v1/docs - OpenAPI spec:
https://router.law/v1/openapi.json
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
- find_form with the person's own words. Confirm the form with the person.
- get_form_spec to get the questions and the schema.
- Ask the person for the answers. Never invent them.
- validate. For each item in
missing_fieldsorissues, ask the person itsquestion, update the profile, and validate again.- Some questions are must ask (
MUST_ASK, markedx-routerlaw-must-askin the schema). The form isn't complete until each is asked. If the person can't answer, record it inno_answer, for example"no_answer": {"accident_benefits.accident.charged": "unknown"}. The value is"unknown"or"not_applicable", and the box stays blank.
- Some questions are must ask (
- fill_form. Show the person the
statusand theoutstanding_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.
- 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). - 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.
- prepare_records_request with
profile(client, incident, optional providers),provider(an object, or the id of one inprofile.providers),request(schemas/records/request.schema.json) andfirm. While anything is missing the status isincomplete,missing_fieldshas a question for each, and no letter is made. - Keep
records_requestfrom the result: prepare_follow_up needs it later, with the follow-ups already sent ([{"number": 1, "date": "2026-12-21"}]). - 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.
- 1 to 40 letters, digits, dots, hyphens, underscores or slashes, with at least one digit.
- A file number that contains a name from the profile is refused.
- Pilot: until Router.law's security review (M9) is passed, only made-up numbers that
start with
TEST-are accepted, for exampleTEST-2026-0147. - Refused file numbers return 400
invalid_matter_ref; nothing is filled. If Files is unavailable, calls with amatter_refreturn 503files_unavailable(calls without one still work).
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 |
- Documents get a reference, not a path. Router.law builds it from approved values
only:
<file number>/<type>/<date received>/<number>, for exampleTEST-2026-0147/police_report/2026-10-18/1. Folder paths are not accepted: a folder name can carry a client's name or health details. Use the reference to name or find the document in your own document system. - Append-only. Every change is recorded with the account, key ID, tool and time. To
correct an entry, send a new one with
"replaces": "<entry_id>"(same kind); to take one back,"withdraw": ["<entry_id>"]. Entry IDs come fromget_file_context. Entries are deleted only by retention and when a firm leaves. - Retention. A file is kept while it is open. Two years after its stage is set to
closed, all its entries are deleted automatically;get_file_contextshows the date underretention. Setting a later stage reopens it. - A firm leaving Router.law gets an export of its Files on request; then everything is deleted within 30 days, including from backups as they rotate, with written confirmation.
- Automatic. Forms checks and fills with a
matter_refrecord the form's outstanding items (Forms' action codes mapped to the list above) and, for a complete fill,form_filled. A later check or fill of the same form replaces Forms' items for it. Resolve an item withresolved_items. - list_files filters:
outstanding(true or false),item,stage,key_date_within_days(0 to 366) andkey_date_type.
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
GET /v1/tools?jurisdiction=CA-ONlists every tool, the provider serving it, the scope it needs, where it applies and whether your key can use it. Leave outjurisdictionfor all of them.GET /v1/usageshows your account's metered calls (kept across restarts once the database is connected;"since"says which): calls and units per day, tool and outcome. Use is free during early access; every call is counted.fill_manycounts one unit per form.
MCP
- Remote server:
https://router.law/mcp(streamable HTTP). - Sign-in: OAuth 2.1. Your MCP client discovers it automatically from
/.well-known/oauth-protected-resource/mcp. When you connect, Router.law opens a page where you sign in once with your console username, password and authenticator code (or your API key, if you have no username yet). The client then gets its own short-lived token, renewed as long as it is used at least once every 30 days (D112). - Claude: add a custom connector with the URL
https://router.law/mcp. - Records letters over MCP come back as one zip behind
download, on the same terms. - Filled PDFs over MCP come back as
pdf_download, a link for the person that works once, for 10 minutes. Chat apps can't pass files from connectors to the person. Give the person the URL exactly as returned. The local stdio server returns the PDF itself.
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).