---
title: "The legal example"
url: https://services.dev/docs/examples/legal
captured: [legal-check.txt, legal-fill.txt, legal-suite.txt]
---
# The legal example

URL: https://services.dev/docs/examples/legal

> A brand shaped like api.lawyer. Six Services a licensed practice sells, one Pool of attorneys and patent practitioners, one rules table, and api.lawyer's own suite passing against what they generate.

*legal's words: matter is a job, asset is a subject, review is a task, signer is a member, network is a pool, outcome is a end (examples/legal/brand.ts).*

The legal example is a brand shaped like api.lawyer, built from one folder: its words, a rules table, a Pool of attorneys and patent practitioners, and six Services. AI does the work on every matter. Each licensed act is a step a credentialed person attests in their own session, so the brand meets licensing by design.

It proves people and the gate, measured against api.lawyer, the hand-built brand it's shaped like.

## The gate

Four counts, each read from the run that produced it. api.lawyer's suite is its front-door probes; its behavior lives in its flow tests and its routes, so those are counted too:

| Measure | Of | Result | Read it |
|---|---|---|---|
| api.lawyer's behavior tests: its four playbook suites and its gate, settle and eligibility suites, at `a6b27b1` | 77 tests | 60 covered by the generated brand · 17 not ported, because a Service names its own steps | [Its behavior tests](https://services.dev/docs/examples/legal/port.md#its-behavior-tests) |
| api.lawyer's routes | 69 routes | 25 served as its clients call them · 17 adapted · 27 decided | [Route by route](https://services.dev/docs/examples/legal/port.md#route-by-route) |
| api.lawyer's own suite: its front-door probes, unchanged | 17 probes | 17 passed · 0 failed | [The suite](https://services.dev/docs/examples/legal/port.md#the-suite) |
| The brand's own suite, generated from its contract | 268 cases from 84 rows | 267 passed · 1 failed · 99 skipped | [Its suite](https://services.dev/docs/examples/legal.md#its-suite) |

When no attorney claims a review, the fill ladder climbs. On a test clock moved two hours, then two more, it raises the fee and then widens to the tier below, where a member claims it:

```txt
→ POST /test_clocks/tc_7Hq3/advance {"to":"2h"}
```

```txt title="magic values: client.email = signs@example.test"
# the record: task.posted → task.raised → task.widened → task.claimed → attested
  14:02 · task.posted · tsk_7Hq2 · $50.00 · dispatch cascade
  16:02 · task.raised · tsk_7Hq2 · $55.00 · raise 10% 2h · funded by the brand
  18:02 · task.widened · tsk_7Hq2 · opened reviewer · widen 4h
  18:02 · task.claimed · tsk_7Hq2 · mbr_7Hq4 · simulated
  ladder  raise 10% 2h: raised to $55.00 · widen 4h: opened reviewer · posted $50.00, now $55.00
```

## The six Services

| Service | Price | Charged on | The person, and their pay | Who sells that fee |
|---|---|---|---|---|
| [Provisional patent application](https://services.dev/docs/examples/legal/provisional-patent.md) | $199, or $79 when the applicant signs and files | the office's receipt | a patent practitioner signs, $150 | the brand |
| [Contract review](https://services.dev/docs/examples/legal/contract-review.md) | $99 | acceptance | an attorney admitted where the client is advises, $50 | the attorney |
| [Demand letter](https://services.dev/docs/examples/legal/demand-letter.md) | $149 | the delivery receipt | an attorney admitted where the client is signs, $75 | the attorney |
| [Company formation](https://services.dev/docs/examples/legal/formation.md) | $299 | the state's receipt | an attorney advises on the entity, and on the 83(b) when founders vest, $60 each | the attorney |
| [Trademark response](https://services.dev/docs/examples/legal/trademark-response.md) | $349 | the office's receipt | an attorney signs the response, $175 | the attorney |
| [Docket watch](https://services.dev/docs/examples/legal/docket-watch.md) | $12 a month | the start of each month | a watcher acknowledges a date in its last week, $4 an act | the brand |

## Its suite

The brand's own suite, generated from its contract, runs every row by its credentials and the branches its files write, over HTTP and MCP. A skipped case never counts as a pass: on a test run, the live and delegated keys' cases wait for `--live`, and [Every branch](https://services.dev/docs/examples/legal/branches.md) names the rest.

```bash
npx services.dev verify --surface all
```

```txt title="magic values: metadata.sandbox.asks = { settle: accept }, metadata.sandbox.asks = { settle: counter }, metadata.sandbox.asks = { settle: close the file }, metadata.sandbox.outside = { reject: [name_unavailable] }, metadata.sandbox.outside = { reject: [missing_specimen] }, metadata.sandbox.outside = { reject: [fee_deficiency] }, metadata.sandbox.outside = { reject: [a_code_no_route_names] }, metadata.sandbox.review = pass, metadata.sandbox.review = flag_once, party.email = signs@example.test, party.email = declines@example.test, party.email = silent@example.test, metadata.sandbox.outside = ack, metadata.sandbox.outside = reject_once, metadata.sandbox.outside = alerts, metadata.sandbox.talk = open, metadata.sandbox.talk = advice, member = mbr_eligible, member = mbr_lapsed_credential, member = mbr_lapsed_coverage, member = mbr_out_of_region, watch.url = https://fails-once.example.test/suite, watch.url = https://down.example.test/suite, watch.url = https://hooks.example.test/suite"
legal · 235 HTTP cases and 33 MCP cases from 84 rows: each row by its live credentials and magic values, with its auth, audience, replay and next cases · http://localhost:8787/verify/suite.json
✗ subject.withdraw · member session · none                                                        answered 404 EMPTY not_found, expected 200 OK
267 passed · 1 failed · 99 skipped
  live mode only, run with --live: credential sk_live_ · 35 rows
  live mode only, run with --live: credential dlg_ · 31 rows
  live mode only, run with --live: credential tk_ · 17 rows
```

## The files

`check` reads the folder back: each file with its line count, and each Service with what one matter leaves you. [Build it](https://services.dev/docs/examples/legal/build.md) adds them one at a time.

```bash
npx services.dev check
```

```txt title="magic values: none"
brand.ts · 10 lines · legal · api.lawyer · words job → matter, subject → asset, task → review, member → signer, pool → network, end → outcome
rules.ts · 36 lines · rules 2026-10 · 6 Services · 16 rows · 1 shared
pools/attorneys.ts · 20 lines · attorneys · 4 roles: attorney, practitioner, watcher, student · joins in 3 steps · cascade · hold 24h
services/contract-review.ts · 16 lines · $99 per job, within 48 hours, charged on acceptance.
  ledger  +$99.00 · attorney's fee $50.00, sold by the attorney (rail member) · brand $49.00 · AI $1.26 (example) · coverage $4.00 · you $43.74
services/demand-letter.ts · 26 lines · $149 per job, within 48 hours, charged on send's receipt.
  ledger  +$149.00 · attorney's fee $75.00, sold by the attorney (rail member) · brand $74.00 · AI $2.10 (example) · coverage $4.00 · you $67.90
services/docket-watch.ts · 10 lines · $12 per month, charged at the start of each month.
  ledger  +$12.00 · AI $0.84 (example) · watcher $4.00 · coverage $4.00 · you $3.16
services/formation.ts · 30 lines · $299 per job, within 48 hours, charged on form_entity's receipt.
  ledger  +$299.00 · attorney's fee $60.00 at advise_entity, sold by the attorney (rail member) · attorney's fee $60.00 at advise_83b, sold by the attorney (rail member) · brand $179.00 · AI $0.84 (example) · coverage $8.00 · you $170.16
services/provisional-patent.ts · 24 lines · $199 per job, within 5 days, charged on file's receipt.
  ledger  +$199.00 · AI $2.10 (example) · practitioner $150.00 (rail brand) · coverage $4.00 · you $42.90
services/trademark-response.ts · 21 lines · $349 per job, within 48 hours, charged on file's receipt.
  ledger  +$349.00 · attorney's fee $175.00, sold by the attorney (rail member) · brand $174.00 · AI $2.10 (example) · coverage $4.00 · you $167.90
✓ ready to sell · 6 Services · each keeps at least 3% of every job
```

## Run it

`dev` serves the folder on localhost: every surface, the three apps, and a test key. Here it also seeds twelve simulated attorneys in a market that's hard to fill, which is how the ladder above climbed:

```bash
npx services.dev dev --members 12 --market tight --no-try
```

```txt title="magic values: client.email = signs@example.test"
legal
  contract-review     An attorney signs at advise, stamped. The client consents first.
  demand-letter       An attorney signs at sign, stamped. The client consents first and decides at settle.
  docket-watch        A watcher does the ack step.
  formation           An attorney does advise_entity and advise_83b. A founder consents first. Every founder signs at adopt.
  provisional-patent  A practitioner signs at sign, stamped. The applicant consents first and answers at questions.
  trademark-response  An attorney signs at respond, stamped. The client consents first and uploads at evidence.
  domain              https://api.lawyer · agents.json, openapi.json and every doc_url name it; localhost serves them
  site                http://localhost:8787/
  api                 POST http://localhost:8787/matters {"service":"<service>"}
  key                 sk_test_7Hq2 · a call with no key uses it, on localhost only
  mcp                 http://localhost:8787/mcp · stdio: npx services.dev mcp
  cli                 npx services.dev <service> k=v …
  sdk                 connect({ origin: 'http://localhost:8787' }).<service>.order(input)
  docs                http://localhost:8787/llms.txt
  buyers              http://localhost:8787/portal
  attorneys           http://localhost:8787/attorneys · join at /attorneys/join, or npx services.dev signers add attorneys <email>
  verifier            vt_test_7Hq2 · the only writer of verified facts, at POST /<network>/signers/:id/verify
  market              tight · 12 simulated signers in attorneys, each act labeled simulated · the fill ladder climbs before a review is claimed
  you                 http://localhost:8787/console
  AI and money are simulated until you wire them. $0.42 a call is an example.
```

## The pages

| Page | What it shows |
|---|---|
| [Build it](https://services.dev/docs/examples/legal/build.md) | Each file, with `check` after it |
| [One job, every side](https://services.dev/docs/examples/legal/walk.md) | One patent matter, as the buyer, the applicant, the practitioner and the owner see it |
| [Every branch](https://services.dev/docs/examples/legal/branches.md) | Each human and outside branch, and the magic value that produces it |
| [The customer portal](https://services.dev/docs/examples/legal/customer-portal.md) | The applicant's screens, from order to acceptance |
| [The delivery portal](https://services.dev/docs/examples/legal/delivery-portal.md) | A practitioner's screens, from the offer to their pay |
| [The owner console](https://services.dev/docs/examples/legal/console.md) | Three matters at once: one filed, one holding advice, one waiting on the client's direction |
| [The money](https://services.dev/docs/examples/legal/money.md) | Every ledger before you sell and after delivery, on both rails, and what an early end costs |
| [What the brand gets](https://services.dev/docs/examples/legal/surfaces.md) | API, CLI, MCP, SDK, Site, Docs and App, in matter words |
| [The rules table](https://services.dev/docs/examples/legal/rules.md) | Every row, illustrative, with its position |
| [The attorneys' Pool](https://services.dev/docs/examples/legal/pool.md) | Join, verify, offers, conflicts and the fill ladder |
| [Provisional patent application](https://services.dev/docs/examples/legal/provisional-patent.md) | A stamped signature, a receipt that releases the charge, of record, two prices |
| [Contract review](https://services.dev/docs/examples/legal/contract-review.md) | Consent first, held advice, three ratified states, two sellers |
| [Demand letter](https://services.dev/docs/examples/legal/demand-letter.md) | An outbound submission, a floor only the client sets, a decision |
| [Company formation](https://services.dev/docs/examples/legal/formation.md) | An open act, advice an attorney gives, a name the state turns down, three clocks that outlive the matter |
| [Trademark response](https://services.dev/docs/examples/legal/trademark-response.md) | Typed rejections routed to the client's evidence or a fee, and an abandoned end |
| [Docket watch](https://services.dev/docs/examples/legal/docket-watch.md) | A subscription on a patent family that routes an office action to its Service |
| [When the attorney declines](https://services.dev/docs/examples/legal/decline.md) | A paid decline on the merits, the client's direction, a second attorney |
| [Porting api.lawyer](https://services.dev/docs/examples/legal/port.md) | Route by route, test by test, and what was decided |
| [Take your first real matter](https://services.dev/docs/examples/legal/launch.md) | Every outside system a real matter depends on, and the contract it meets |

---

- Up: [Examples](https://services.dev/docs/examples.md)
- Previous: [lingua](https://services.dev/docs/examples/lingua.md)
- Next: [Build it](https://services.dev/docs/examples/legal/build.md)
