---
referrals: 3
kind: program
payer: domain:api.example
code: example_sla
category: api_usage
status: open
at: 2026-10-30T00:00:00Z
net_of: tax, processor_fee
crit: sla, sla_multiplier
---
# Example API share tied to an SLA

Rates, amounts and names in this file are placeholders, not recommendations or market rates. Each party sets its own terms.

In plain words: a partner earns 13% of net usage. While that partner is in breach of its uptime commitment, its rate is multiplied by 50%. Other partners are not affected.

Change first: `payer`, `code`, the rate, the multiplier and the commitment. Someone has to measure the service and write the `sla_breach` line, naming the `party`. Say who in your contract.

## Rules

### usage_share

- on: usage
- basis: percent
- rate: 13%
- of: net
- recurring.months: 12
- sla_multiplier.sla: uptime
- sla_multiplier.rate: 50%

## Attribution

- model: last_touch
- window_days: 30
- allowed_kinds: co_sell, link

## Settlement

- holdback_days: 30
- clawback_days: 60
- cycle: monthly
- payout_asset: USD
- rails: ach

## SLA

| id | who | metric | target |
|---|---|---|---|
| uptime | partner | uptime_pct | 99 |

## Example

Made-up lines. Alpha and Beta each sent one customer. Alpha breaches in March. Alpha's March usage, reported on April 1, still counts as March because its `period` starts there, so it computes at the lower rate. Beta's does not change.

To run it, save this file as `REFERRALS.md` and these lines as `referrals.jsonl`, then run `node referrals.mjs run REFERRALS.md referrals.jsonl --as-of 2027-06-01T00:00:00Z`.

As of: 2027-06-01T00:00:00Z

```jsonl
{"type":"agreement","code":"alpha","partner":"domain:alpha.example"}
{"type":"agreement","code":"beta","partner":"domain:beta.example"}
{"type":"event","at":"2027-03-01T00:00:00Z","kind":"usage","source":"meter:alpha_02","customer":"cu_b4c5d6e7f8091a2b","amount":"10000.00","net":"10000.00","asset":"USD","period":{"start":"2027-02-01T00:00:00Z","end":"2027-03-01T00:00:00Z"},"token":"rf1.example_sla.alpha.a1b2c.tszs00.dho.n.-"}
{"type":"event","at":"2027-03-20T00:00:00Z","kind":"sla_breach","source":"support:incident_7","sla":"uptime","party":"pt_2ca797935239bd7dc0d8cb7f","period":{"start":"2027-03-01T00:00:00Z","end":"2027-04-01T00:00:00Z"}}
{"type":"event","at":"2027-04-01T00:00:00Z","kind":"usage","source":"meter:alpha_03","customer":"cu_b4c5d6e7f8091a2b","amount":"10000.00","net":"10000.00","asset":"USD","period":{"start":"2027-03-01T00:00:00Z","end":"2027-04-01T00:00:00Z"}}
{"type":"event","at":"2027-04-01T00:00:00Z","kind":"usage","source":"meter:beta_03","customer":"cu_c5d6e7f8091a2b3c","amount":"10000.00","net":"10000.00","asset":"USD","period":{"start":"2027-03-01T00:00:00Z","end":"2027-04-01T00:00:00Z"},"token":"rf1.example_sla.beta.d4e5f.tufmo0.dho.n.-"}
```

## Worked result

Computed by `run_ledger` as of 2027-06-01T00:00:00Z, on the made-up lines above. Computed amounts are arithmetic on the records and terms you sent. They do not say what anyone owes. Your contract decides that.

| Event | Who | Working | Computed | Note |
|---|---|---|---|---|
| usage, 2027-03-01 | alpha | 13% of 10000.00 | 1300.00 |  |
| sla_breach, 2027-03-20 |  | Recorded. No rule fires on this kind of event |  |  |
| usage, 2027-04-01 | alpha | 13% of 10000.00 x 50% while in breach | 650.00 |  |
| usage, 2027-04-01 | beta | 13% of 10000.00 | 1300.00 |  |

| Payee | Asset | Earned | Reversed | Net | Held | Payable |
|---|---|---|---|---|---|---|
| alpha | USD | 1950.00 | 0.00 | 1950.00 | 0.00 | 1950.00 |
| beta | USD | 1300.00 | 0.00 | 1300.00 | 0.00 | 1300.00 |


## Why these settings

Setting `party` on the breach keeps one partner's outage from cutting another's share, and rule time from `period` keeps a late report in the month it covers.
