---
title: "Every deal shape"
url: https://services.dev/docs/examples/sales/shapes
captured: [money-outcomes.txt, sales-branches.txt, sales-build.txt]
---
# Every deal shape

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

> Every deal api.forsale sells from one deal.ts, each run in the sandbox from the value that picks it, with the line that handles it and what you keep.

*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).*

One `deal.ts` sells every shape. The value in a row picks it in the sandbox, and the last column names the line of the file that handles it:

| Value | The shape | [Held](https://services.dev/docs/service/time.md#every-kind-of-time) | The share is of | You keep | The line in deal.ts |
|---|---|---|---|---|---|
| `output.billing = 'annual'`, the default | a business pays its first year on the seller's invoice, net 30 | 60 days from the bank debit's collection | the first 12 months the contract commits: [the walk](https://services.dev/docs/examples/sales/walk.md) | $3,388.66 | `:19` `output.billing`, `:50` `outcome.collect` |
| `output.billing = 'monthly'` | billed monthly, each invoice its own proof | 60 days, each invoice | each month as it is paid | $308.33 an invoice, $3,388.66 over the 12 | `:19` `output.billing`, `:50` `outcome.collect` |
| `input.motion = 'B2C'` | a consumer close on closers.sale, paid by card | 120 days, by card | what the consumer paid | $368.80 | `:25` `policy.stall_days`, `:50` `outcome.window` |
| `account.email = customer@example.test` | an expansion of an account that already pays the seller | 60 days | the increase, never what they already pay | $1,191.60 | `:17` `input.expansion`, `:19` `output.closed_value` |
| `input.referrer` | a referred deal | the deal's own window | the same base, 1% to the referrer beside the 5% | $3,064.20 | `:17` `input.referrer`, `:52` `lines.referral` |
| `input.motion = 'B2D'` | a developer on a Stripe subscription, its first paid invoice the proof | 120 days, by card, each invoice | each month as it is paid | $235.90 over the 12 | `:16` `input.motion`, `:50` `outcome.collect` |
| `input.motion = 'B2A'` | an agent buying for its principal, with no meeting | 120 days, by card | what the principal paid | $594.70 | `:41` `meet.when`, `:50` `outcome.window` |

Years two and three are a renewal through `again`, a new outcome on its own payment: [what the share is of](https://services.dev/docs/examples/sales/money.md#what-the-share-is-of).

## Billed monthly

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

```txt title="magic values: none"
    held: 'meeting', closed_value: 'money: the first 12 months the contract commits, over what the account already pays', billing: ['annual', 'monthly'], term: 'months?',
    window: { bank: '60d', card: '120d' }, tail: '90d', due: '90d', collect: job => (job.output.billing === 'monthly' ? 'each' : 'first') },
```

`billing: 'monthly'` makes each invoice its own proof, held from its own payment. Trey Research pays a $74,000 contract by the month:

```txt
→ GET /owner/deals/job_7Ht1   # collect 'each': a $74,000.00 contract paid monthly
```

```txt title="200 · job_7Ht1 · deal · won · 3 of 12 invoices paid · $2,775.00 charged · magic values: none"
  proof     payment · in_…T101 to in_…T112 on the seller's Stripe account, matched on the subscription
  each      $6,166.67 paid → $925.00 charged: the 5% $308.33 and the closer's $616.67, each held 60 days from its own payment
  held      $2,775.00 · final 11 Jan, 10 Feb and 12 Mar 2027 · 9 invoices to come
  ledger    each invoice +$925.00 · closer $616.67 · you $308.33 before the take · the first also carries the setter's $250.00, placement $50.00 and AI $11.34 · you $3,388.66 over the 12
```

## A consumer close, on closers.sale

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

```txt title="magic values: none"
    stall_days: { word: 'number', default: job => (job.input.motion === 'B2C' ? 7 : 14), min: 3, max: 90 },
    window: { bank: '60d', card: '120d' }, tail: '90d', due: '90d', collect: job => (job.output.billing === 'monthly' ? 'each' : 'first') },
```

A consumer program waits 7 days before a deal goes dark. The closer sends the seller's own Checkout, and a card can be disputed longer than a bank payment, so the share is held 120 days:

```txt
→ POST /deals {"account":{"name":"Jordan Lee","email":"replies@example.test"},"value":8000,"motion":"B2C","policy":{"humans_from":5000},"offer":"https://summit.example/founder-program","max_usd":1200,"payment_method":"pm_…","key":"jordan"}
```

```txt title="captured/sales-branches.txt · 201 · job_7Hu5 · deal · working · mandated · up to $1,200.00, charged at won · stall_days 7, for B2C · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  18 Nov    meet · escalated · closer · tsk_7Hu5 on closers.sale · 10% at won
  20 Nov    close · person · closer · committed · closed_value $8,000 · pay_link cs_…7Hu5, Summit Coaching's own Checkout
  20 Nov    outcome.verified · cs_…7Hu5 paid by card · $8,000.00 · charge.collected +$1,200.00 held to 20 Mar 2027 · window 120d, by card
  ledger    +$1,200.00 · closer $800.00 (share, from the seller) · placement $25.00 · AI $6.20 · you $368.80 before the take
```

## An expansion

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

```txt title="magic values: none"
    referrer: 'party?', expansion: 'boolean?' },
    held: 'meeting', closed_value: 'money: the first 12 months the contract commits, over what the account already pays', billing: ['annual', 'monthly'], term: 'months?',
```

An order on an account that already pays the seller answers `account_is_customer`, and its `next` offers the expansion. `closed_value` is only what the account adds, and the floor holds on it: $24,000 is exactly 0.8 × $30,000:

```txt
→ POST /deals {"account":{"name":"Proseware","email":"customer@example.test"},"value":30000,"offer":"https://harbor.example/route-planner","max_usd":4500,"payment_method":"pm_…","key":"proseware"}
```

```txt title="captured/sales-branches.txt · 409 · account_is_customer · Proseware is Harbor Labs' customer on its Stripe account, paying $48,000.00 a year · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  next      POST /deals {…,"expansion":true,"key":"proseware"} · the share is taken on the increase over $48,000.00, never on what they already pay
```

```txt
→ POST /deals {"account":{"name":"Proseware","email":"customer@example.test"},"value":30000,"expansion":true,"offer":"https://harbor.example/route-planner","max_usd":4500,"payment_method":"pm_…","key":"proseware"}
```

```txt title="201 · job_7Hu1 · deal · working · expansion · mandated · up to $4,500.00, charged at won · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  3 Dec     close · ai · committed · $72,000 a year from $48,000 · closed_value $24,000, the increase, exactly the floor: 0.8 × $30,000
  ledger    at the payment: +$1,200.00 · AI $8.40 · you $1,191.60 before the take
```

## Referred

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

```txt title="magic values: none"
    referrer: 'party?', expansion: 'boolean?' },
    lines: { referral: { share: '1%', of: 'closed_value', to: 'referrer', on: 'won' } } },
```

The referrer's 1% is a line on the same charge, from the seller. It is paid at `outcome.final`, never from the closer's pay, and a refund reverses it with the 5% and the 10%:

```txt
→ POST /deals {"account":{"name":"Alpine Freight","email":"replies@example.test"},"value":62000,"referrer":{"name":"Kai Moreno","email":"kai@moreno.example"},"offer":"https://harbor.example/route-planner","max_usd":9920,"payment_method":"pm_…","key":"alpine"}
```

```txt title="captured/sales-branches.txt · 201 · job_7Hr4 · deal · working · mandated · up to $9,920.00, charged at won · referred by Kai Moreno · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  27 Oct    meet · escalated · closer · tsk_7Hr4 claimed by mbr_7Hq4 · held 34 minutes · meet.held
  6 Nov     close · person · closer · mbr_7Hq4 · committed · closed_value $62,000 · won
  9 Nov     outcome.verified · in_…7704 · $62,000.00 paid · charge.pending $9,920.00: the 5% $3,100.00, the closer's 10% $6,200.00 and the referrer's 1% $620.00, one charge from the seller
  13 Nov    charge.collected · held to 12 Jan 2027 · a refund before then reverses all three, pro rata if partial
  12 Jan    outcome.final · pay.accrued closer $6,200.00 · referrer $620.00, paid at outcome.final, never from the closer's pay
  ledger    +$9,920.00 · closer $6,200.00 · referrer $620.00 · placement $25.00 · AI $10.80 · you $3,064.20 before the take
```

## A developer

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

```txt title="magic values: none"
    account: 'party', value: 'money: list value', motion: ['B2B', 'B2C', 'B2D', 'B2A'], offer: 'url',
    window: { bank: '60d', card: '120d' }, tail: '90d', due: '90d', collect: job => (job.output.billing === 'monthly' ? 'each' : 'first') },
```

A developer tool closes on a Stripe subscription. Its first paid invoice proves the deal, and each later one collects on its own:

```txt
→ POST /deals {"account":{"name":"Rin Takahashi","email":"replies@example.test"},"value":4800,"motion":"B2D","offer":"https://harbor.example/api","max_usd":240,"payment_method":"pm_…","key":"rin"}
```

```txt title="captured/sales-branches.txt · 201 · job_7Hv6 · deal · working · mandated · up to $240.00, charged at won · under humans_from, so AI alone · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  2 Dec     book · ai · committed · meet · ai · held: Rin attended 18 minutes of a demo of the API
  4 Dec     close · ai · committed · closed_value $4,800 · billing monthly · a Stripe subscription at $400.00 a month
  4 Dec     outcome.verified · in_…V601, the subscription's first paid invoice · $400.00 by card · charge.collected $20.00, held to 3 Apr 2027 · window 120d, by card
  ledger    each invoice +$20.00 · AI $4.10 off the first · you $235.90 over the 12 before the take
```

## An agent buyer

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

```txt title="magic values: none"
    meet: { by: 'ai', escalate: { to: 'closer', when: person }, when: job => job.input.motion !== 'B2A',
```

An agent buying for its principal skips `meet`: the deal goes from `book` to `propose`, and the agent pays with its scoped token at the seller's Checkout:

```txt
→ POST /deals {"account":{"name":"Woodgrove Bank","email":"agent@woodgrove.example"},"value":12000,"motion":"B2A","offer":"https://harbor.example/route-planner","max_usd":600,"payment_method":"pm_…","key":"woodgrove"}
```

```txt title="captured/sales-branches.txt · 201 · job_7Hv8 · deal · working · mandated · up to $600.00, charged at won · B2A: no meeting · magic values: account.email picks how the account answers; metadata.sandbox.members picks what each person proposes; metadata.sandbox.proof picks how the payment goes; the deal's value and signals pick who closes"
  1 Dec     book · ai · committed · the agent's quote request, answered with the offer's terms · meet skipped, its when false for B2A
  1 Dec     propose · ai · committed · negotiate · ai · committed · the agent asks for annual terms
  2 Dec     close · ai · committed · closed_value $12,000 · pay_link cs_…7Hv8, Harbor Labs' own Checkout
  2 Dec     outcome.verified · cs_…7Hv8 paid by card with the agent's scoped token · $12,000.00 · charge.collected $600.00, held to 1 Apr 2027 · window 120d, by card
  ledger    +$600.00 · AI $5.30 · no person, no placement · you $594.70 before the take
```

[Every branch](https://services.dev/docs/examples/sales/branches.md) runs every way a deal goes. [Magic values](https://services.dev/docs/reference/magic-values.md) lists every value the sandbox reads.

---

- Up: [The sales example](https://services.dev/docs/examples/sales.md)
- Previous: [Every branch](https://services.dev/docs/examples/sales/branches.md)
- Next: [The customer portal](https://services.dev/docs/examples/sales/customer-portal.md)
