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

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

> A brand shaped like api.forsale, from three files. One Service works a deal from first touch to the account's payment, one Pool of setters, closers and nurturers works on an existing door, and nothing is charged on effort. The seller pays 5% of the closed value at won, or 15% when a closer takes the deal, the closer's 10% passed through whole.

*sales's words: deal is a job, account is a subject, gig is a task, closer is a member, seller is a client, seller is a buyer (examples/sales/brand.ts).*

The sales example is a brand shaped like api.forsale, built from three files: its words, one Pool and one Service. A seller, or the seller's agent, sends an account and an offer. AI sources, qualifies, books, meets and negotiates. A warm reply sends the booking to a setter, a deal of $50,000 and up sends the meeting and the rest of the deal to a closer, and an account that goes quiet sends it to a nurturer.

| Who | What you get |
|---|---|
| The seller | Nothing on effort. 5% of the closed value when your customer pays your own invoice, or 15% when a closer takes the deal, and the closer's 10% passes through whole. Held 60 days, then final |
| The closer | 10% of every deal you close, charged to the seller and never taken from your share. Your terms freeze at your claim, and a seller's no never counts against you: [Closing on closers.deals](https://services.dev/docs/examples/sales/delivery-portal.md) |

## The gate

The brand ports api.forsale whole: its behavior tests, its routes and its suites, run against the generated brand.

| Measure | Of | Result | Read it |
|---|---|---|---|
| The sales kernel's behavior tests: core, gig-result, gig-lifecycle, sdk and demo, at `52fa49b` | 76 tests | 59 ported as they are · 10 adapted · 7 decided | [Its behavior tests](https://services.dev/docs/examples/sales/port.md#its-behavior-tests) |
| api.forsale's routes, the kernel's and the front door's | 22 routes | 12 served as its clients call them · 6 adapted · 4 decided | [Route by route](https://services.dev/docs/examples/sales/port.md#route-by-route) |
| The kernel's money path, its numbers unchanged | 10 rows | 10 passed · 0 failed | [The suite](https://services.dev/docs/examples/sales/port.md#the-suite) |
| api.forsale's own probe suite | 10 probes | 10 passed · 8 unchanged, 2 rewritten for a door that sells | [The suite](https://services.dev/docs/examples/sales/port.md#the-suite) |

```bash
npx services.dev verify --suite kernel-smoke.json   # the sales kernel's money path, its numbers unchanged
```

```txt title="magic values: metadata.sandbox.proof = "paid", metadata.sandbox.members = {"close":[{"closed_value":50000},{"closed_value":74000}]}"
kernel-smoke@1 · 10 rows · the money path of e2e/tests/00-kernel-smoke.spec.ts and gig-lifecycle's two intermediate steps · against http://localhost:8787
✓ list-80k-escalates      POST /deals {"value":80000}               a closer gig posts: $80,000 is over humans_from
✓ floor-is-64k            GET /gigs/:id                             the brief reads floor $64,000, 80% of list
✓ proposal-commits        POST /gigs/:id/propose                    200 · propose committed · the gig stays claimed
✓ negotiation-commits     POST /gigs/:id/negotiate                  200 · negotiate committed · the gig stays claimed
✓ floor-refuses-50k       POST /gigs/:id/complete 50000             422 guard_refused · the gig stays claimed
✓ close-74k-commits       POST /gigs/:id/complete 74000             200 · the deal is won, and waits on the payment
✓ closer-share-7400       GET /owner/deals/:id                      closer $7,400.00, charged to the seller once the payment lands
✓ five-percent-3700       GET /owner/deals/:id                      api.forsale $3,700.00, and $0.00 before the payment
✓ track-record            GET /closers/me/track                     the closer's track record gains 1 won and $74,000 closed
✓ net-to-seller-62900     GET /deals/:id                            $74,000.00 paid to the seller, $11,100.00 charged: $62,900.00 net

10 passed · 0 failed
```

## What api.forsale sells, and where it lives

| api.forsale sells | Where the brand keeps it |
|---|---|
| A deal worked from first touch to the account's payment | [The Deal Service](https://services.dev/docs/examples/sales/deal.md): seven steps, AI on each until its `escalate` names a role |
| A person where one pays off | a setter books on a warm reply, paid when the meeting is held; a closer meets and closes from `humans_from`, a buying committee or the seller's ask |
| A floor no one closes below | `close.guard`, reading the seller's own merits |
| Proof in the close | the closer sends the seller's own invoice, carrying the deal's id: [how the payment finds the deal](https://services.dev/docs/examples/sales/money.md#how-the-payment-finds-the-deal) |
| Every deal shape it really sells | net 30, billed monthly, a consumer's card, an expansion and a referral: [every deal shape](https://services.dev/docs/examples/sales/shapes.md) |
| Setters, closers and nurturers who keep all their pay | [The closers' Pool](https://services.dev/docs/examples/sales/pool.md), on closers.deals |

[Paid on the close](https://services.dev/docs/grow/outcome.md) adds the outcome to a Service in two lines.

## The line that makes it

```bash
cat services/deal.ts
```

```txt title="magic values: none"
  roles: {
    setter: { pool: closers, pay: { usd: 250, on: 'meet.held' } },
    closer: { pool: closers, span: ['meet', 'propose', 'negotiate', 'close'], revive: { first_call: '24h' },
      pay: { share: '10%', of: 'closed_value', on: 'won', from: 'buyer' },
  outcome: { amount: 'closed_value', proof: 'payment', match: { customer: 'account', metadata: 'deal' },
    window: { bank: '60d', card: '120d' }, tail: '90d', due: '90d', collect: job => (job.output.billing === 'monthly' ? 'each' : 'first') },
  price: { usd: 0, share: '5%', of: 'closed_value', on: 'won', ai: 40,
    lines: { referral: { share: '1%', of: 'closed_value', to: 'referrer', on: 'won' } } },
```

## Its plans

```txt title="services.dev check --plan"
# Free · meetings AI books and you hold, $400 a meeting held
#   who: AI books and meets; you and two staff hold each meeting of $50,000 and up, and work the deal
#   sides: $400.00 at each held meeting and nothing on a booking; a no-show costs AI up to $40.00
# Launch · deals AI works to close, with closers listed on closers.deals, paid 5% of the closed value at won
#   who: AI works every deal; a closer takes each one of $50,000 and up, $5,000 at won, charged to the seller
#   sides: a won deal leaves $3,388.66 and a lost one costs $340.00, so it breaks even at 9.1% won; the closer's $5,000.00 is the seller's
# Team · full depth: the closer's share at won, tiers by deal size, firms with a bench
#   who: closers paid a share at won, tiered, and firms enrolling a bench
#   sides: pay that scales with the deal: the closer's $7,400.00 at $74,000 against $5,000.00 flat, tiers by deal size and firms with a bench; your odds stay 9.1%

$ npx services.dev check --fit free services/deal.ts
services/deal.ts · Deal · nothing on effort; 5% of closed_value at won, proven by the account's payment
  fit     Free (services.dev), with 10 changes
          brand.ts:7             − domain: 'api.forsale',  → the brand serves on api-forsale.builder.domains
          services/deal.ts:2     − import { closers } from '../pools/closers.ts'  → no Pool: you and two staff are the only people
          services/deal.ts:28    − setter: { pool: closers, pay: { usd: 250, on: 'meet.held' } },  → no setter: AI books every meeting
          services/deal.ts:29    − pool: closers,  → you hold each meeting of $50,000 and up and work the deal, from the owner console
          services/deal.ts:30    − pay: { share: '10%', of: 'closed_value', on: 'won', from: 'buyer' },  → the close is yours, so nothing passes through
          services/deal.ts:32    − nurturer: { pool: closers, pay: 150 },  + nurturer: {},  → you revive a deal gone quiet yourself
          services/deal.ts:40    − , escalate: { to: 'setter', when: setter }  → AI books on a warm reply too
          services/deal.ts:49-50  − outcome: { … }  → the held meeting is what you sell, so nothing waits on a payment
          services/deal.ts:51    − usd: 0, share: '5%', of: 'closed_value', on: 'won', ai: 40,  + usd: 400, release: 'meet.held', ai: 40,  → $400 a meeting held, charged when the guard accepts it; a no-show charges nothing
          services/deal.ts:52    − lines: { referral: { share: '1%', of: 'closed_value', to: 'referrer', on: 'won' } } },  + },  → a referred deal is priced like any other
  plan    Free (services.dev) · you, two staff and AI work every deal, on api-forsale.builder.domains · the held meeting is the outcome you are paid on
  odds    a held meeting leaves $400.00 less AI · one no one attends charges nothing and costs AI up to $40.00
  sides   $400.00 at each held meeting and nothing on a booking; a no-show costs AI up to $40.00

$ npx services.dev check --fit launch
  fit     Launch (services.dev), with 5 changes
          pools/closers.ts:17  − rank: ['fit', 'track'],  → each gig posts to every eligible closer on the door's feed
          pools/closers.ts:18  − tiers: [{ name: 'SMB' }, { name: 'midmarket', after: 10, on_time: '90%' }, { name: 'enterprise', after: 40, on_time: '95%' }],  → every verified closer is offered every deal they can take
          pools/closers.ts:19  − firms: true,  → each closer joins on their own
          services/deal.ts:30  − pay: { share: '10%', of: 'closed_value', on: 'won', from: 'buyer' }  + pay: { usd: 5_000, on: 'won', from: 'buyer' }  → each close the closer wins pays $5,000, flat, charged to the seller beside the 5%; a lost close pays nothing
          services/deal.ts:52  − lines: { referral: { share: '1%', of: 'closed_value', to: 'referrer', on: 'won' } } }  + }  → a referred deal is priced like any other
  plan    Launch (services.dev) · a Pool listed on closers.deals with its placement line, and 5% of the closed value at won
  odds    lost by a closer −$340.00: the setter's $250.00, placement $50.00 and AI $40.00 · a won deal leaves $3,388.66 · breaks even at 9.1% won
  sides   a won deal leaves $3,388.66 and a lost one costs $340.00, so it breaks even at 9.1% won; the closer's $5,000.00 is the seller's

$ npx services.dev check --plan
api.forsale · 3 files · 1 Service, 1 Pool and the brand
  plan    Team (services.dev) · the highest plan a file needs · each Service runs live on its own
  Launch  brand.ts             Brand.domain at :7
  Team    pools/closers.ts     Pool.rank at :17 · Pool.tiers at :18 · Pool.firms at :19
            also Launch        Pool({...}) at :8 · door: '<existing door>' at :10, closers.deals, a door another account operates · Pool.payouts.schedule at :22
          services/deal.ts     pay: { share } at :30, the closer's 10% at won · the referrer's 1% at :52
            also Launch        roles.setter.pool at :28 · roles.closer.pool at :29 · roles.nurturer.pool at :32 · outcome at :49 · price.share at :51
          every key runs in test on any plan · deploy --live asks for each key's plan once its three sampled jobs release
  sides   pay that scales with the deal: the closer's $7,400.00 at $74,000 against $5,000.00 flat, tiers by deal size and firms with a bench; your odds stay 9.1%
```

## The files

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

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

```txt title="magic values: none"
brand.ts · 2 lines · sales · api.forsale · words job → deal, subject → account, task → gig, member → closer, client and buyer → seller
pools/closers.ts · 14 lines · closers · 3 roles: setter, closer, nurturer · joins in 3 steps on closers.deals · feed, ranked by fit, then track · hold 48h to a first touch, then each touch renews it
services/deal.ts · 42 lines · nothing on effort; 5% of closed_value at won, proven by the account's payment, held 60 days by bank, 120 by card.
✓ ready to sell · 1 Service · AI closes a deal under $50,000 alone · nothing charged before won
```

## The pages

| Page | What it shows |
|---|---|
| [Build it](https://services.dev/docs/examples/sales/build.md) | Each file, with `check` after it |
| [One deal, every side](https://services.dev/docs/examples/sales/walk.md) | Northwind Freight's deal, from the order on 2 November to the closer's payout on 12 March |
| [The agent's order](https://services.dev/docs/examples/sales/agent.md) | A seller's agent orders, pays with a scoped token, sends what it learns and waits |
| [Every branch](https://services.dev/docs/examples/sales/branches.md) | Every way a deal goes, each from the value that picks it |
| [Every deal shape](https://services.dev/docs/examples/sales/shapes.md) | A consumer's card, an expansion and a referral: what proves each, how long it's held and what the share is of |
| [The customer portal](https://services.dev/docs/examples/sales/customer-portal.md) | The seller's deal at the close, then won, paid and held |
| [Closing on closers.deals](https://services.dev/docs/examples/sales/delivery-portal.md) | The closer's path, from joining to Friday's payout, and what protects the pay |
| [The owner console](https://services.dev/docs/examples/sales/console.md) | December, with four deals won and awaiting payment |
| [The money](https://services.dev/docs/examples/sales/money.md) | One deal from its mandate to its payout, how the payment finds it, and every deal on this site |
| [What the brand gets](https://services.dev/docs/examples/sales/surfaces.md) | API, CLI, MCP, SDK, Site, Docs and App, in deal words |
| [The Deal Service](https://services.dev/docs/examples/sales/deal.md) | Each step, the policy, the held meeting, the floor and how a closer reaches the account |
| [The closers' Pool](https://services.dev/docs/examples/sales/pool.md) | Each line, tiers on the record, who may claim, firms, and a licensed closer |
| [Porting api.forsale](https://services.dev/docs/examples/sales/port.md) | Its suites, its 22 routes and its 76 behavior tests |
| [Take your first real deal](https://services.dev/docs/examples/sales/launch.md) | Every outside system a real deal depends on, and the contract it meets |

---

- Up: [Examples](https://services.dev/docs/examples.md)
- Previous: [Take your first real return](https://services.dev/docs/examples/tax/launch.md)
- Next: [Build it](https://services.dev/docs/examples/sales/build.md)
