# Limitr 0.8: Contracts in the Engine, Quote to Cash in Cloud

> Limitr 0.8 puts negotiated terms into the open-source engine as rules, and Limitr Cloud turns a signed contract into what your app enforces and what your customers are billed. Contracts with phases, ramps, and renewals, fees, commitments, and credit packs, recognition schedules, accounts that bill as one with nothing to set up, overdue invoices, credits and refunds, and every bill and contract in your dashboards. And a new plan, Scale, for custom deals, self-serve.

Limitr 0.8 is out. It's about the deals that don't fit a plan.

Every team selling AI features ends up with them: one customer gets 5M tokens a month instead of 2M, audit logs
their plan doesn't include, 20% off tokens, a not-to-exceed amount, and a platform fee, for a year, with a price
step-up in month seven. Until now, that meant a plan per deal, or a spreadsheet next to your billing that someone
has to remember.

0.8 makes a deal two things: a **rule** in your policy that says what changes, and a **contract** in Limitr Cloud
that says who has it, when, and what it bills.

```bash
npm i @formata/limitr
```

{/* truncate */}

## Rules in the engine

A rule is a named set of changes on top of a plan, written once in your policy and given to as many customers as
sign it. It holds the same changes you can make to one customer:

- **Limits:** a limit in place of the plan's, hard, soft (overage is billed), or watch only.
- **Gives:** an entitlement their plan doesn't have, as another plan defines it.
- **Takes:** an entitlement their plan has, turned off.
- **Caps:** a ceiling on a credit that stops calls or only alerts, kept per customer.
- **Prices:** negotiated rates, which Limitr Cloud applies on its invoices.

```stof
rules: {
    acme_2027: {
        label: 'Acme 2027'
        given: { sso: {}, audit_log: { plan: 'business' } }
        taken: { exports: {} }
        overrides: { api: { credit: 'request', value: 250_000, resets: true, reset_sch: 'monthly:1' } }
    }
}
```

```ts
await limitr.setCustomerRules('acme', ['acme_2027']);
await limitr.entitlementSource('acme', 'api'); // { access: 'plan', limit: 'rule:acme_2027', customer: 'acme' }
```

There's one order everywhere: a customer's own change first, then its rules (highest priority first), then its
plan. A rule's gives and takes reach the customers that use its customer's plan through refs (Ex. users on their
org's plan), the same way the plan itself does. `entitlementSource` says where each entitlement and limit comes from, so "why does this customer
have this?" always has an answer.

A rule can't invent an entitlement: a give always uses a plan's definition, and the policy checks every rule like
the rest of it. The engine decides every call in your process, as before, with no network call on the decision
path. The [custom deals how-to](/docs/how-to/custom-deals#one-deal-for-many-customers) walks through it with real
output.

Also in 0.8:

- **Twice-a-year resets:** `reset_sch: 'semiannual:1-1'` resets on January 1 and July 1, for limits, credit packs,
  grants, and caps.
- **A reset that lands on the same value is reported.** A fee of 1 a period used to look unchanged from one period
  to the next. Each period's usage reaches your events and Limitr Cloud now.
- **Meters stay right while Cloud updates a customer.** The SDK numbers the messages that change a meter, and Cloud
  says which it has seen, so a call made while Cloud was sending a customer is never lost from your app's meter.

The [changelog](https://github.com/dev-formata-io/limitr/blob/main/CHANGELOG.md) has every change.

## Contracts in Limitr Cloud

In Limitr Cloud, a contract holds a deal as it was agreed: who it's with, its term, the rules in force, what it
bills, its value, the terms in plain words, and the signed file.

- **Who it reaches.** Customers by ID, a customer and everyone whose refs lead to it, an account, or a
  [segment](/guides/cloud/segments) (a startup program for every customer that matches). Its customers get its rules
  within seconds.
- **Phases and ramps.** A contract moves through rules over its term: months 1 to 6 on one, then the next. Cloud
  switches on time and takes the rules off at the end. Usage is priced at the rules in force when it was recorded,
  so a phase that starts mid-period splits the invoice line at the change.
- **Renewals.** A contract renews by itself at its end, or by hand, and stays one record with its earlier terms
  kept. Cloud reminds your team a month before the notice deadline. A step-up goes in as a new phase with its rule.
- **Hand the Analyst the order form.** Attach the PDF and say who it's with. Limitr Analyst reads the terms, writes
  the rules into your draft, checks them against your customers, and proposes the whole thing on one card: publish
  the rules, save the contract. Nothing changes until you apply it.

## What a contract bills

A contract's money is part of the same system as everything else, not a side ledger:

- **Fees.** A platform fee, a license, an annual subscription, or a setup fee is an entitlement in a priced credit,
  so Limitr meters it, bills it, and counts it in revenue and margin like any usage. It bills each billing period,
  quarterly, twice a year, yearly on a date, or once, in advance or in arrears.
- **Commitments.** A minimum each billing period, trued up on the invoice when usage comes in under it, or a prepaid
  amount for the term that the invoices draw down, with what's left lapsing or rolling over at the end.
- **Credit packs.** A phase can grant packs when it starts (Ex. 1M bonus tokens at the start of each year), free,
  once.
- **How this bills.** Every contract says, in plain lines, what applies to whom, who it bills and how that's
  collected, each fee and its schedule, and whether its fees and commitment add up to the value it states. A
  contract set up differently from what it says is caught before the first invoice, not after.
- **Recognition.** Each contract shows what it billed, earned, and has deferred, month by month: an annual fee
  earned a twelfth a month, true-ups in the period they're for, a prepayment as it's drawn. Export it as CSV for your
  accounting system.

## Accounts and invoices

Who pays is an **account**: a top-level customer and everyone whose refs lead to it, of any type and at any depth.
There's nothing to set up. Once customers ref another, it's billed one invoice a period for all of them, with a line
per member, on its own billing settings. A customer nobody refs is billed its own invoice, as always.

- **Self-serve:** connect the top-level customer to Stripe and ref the rest to it.
- **Sales-led:** put it on a plan billed manually, and mark its invoices paid when the wire lands.
- **The exceptions** get an account record: several companies on one invoice, another payer, a Stripe invoice due
  in 30 days (paid by card, ACH, or bank transfer), or each member paying its own.

The new **Invoices** tab has every bill across your customers, with what's outstanding and overdue. A customer's own
invoice stays on its page, with its usage and margin, and says when it was billed with its account.

- **Overdue invoices:** your team is told once, through a notification. Optionally, an account names a rule its
  customers get while it owes (Ex. one that takes a feature, or sets a hard limit), and it comes off as soon as
  it's paid.
- **Credits:** give an account a credit (an SLA miss, a billing mistake), and it comes off its next bills until it's
  used up, however they're collected. Or credit one open invoice, and what's due on it goes down now.
- **Refunds:** refund a charge or a paid Stripe invoice, in full or in part, from Limitr. A refunded top-up takes back
  what's unused.

## In your dashboards

Ask the Analyst about any of it, and it charts it: revenue by account this quarter, overdue invoices, cash collected
and failed charges, credits and refunds, total contract value and contracted ARR, deferred revenue, and contracts
ending or up for renewal in the next 90 days. It knows which data answers which question, so a customer's invoices
and its account's are never counted twice.

## A new plan: Scale

Custom deals shouldn't need a sales call to set up. **Scale** is $499 a month, with 1,000 active customers
included: everything in Pay as you go, plus rules and per-customer prices, contracts with renewals, fees,
commitments, and recognition, forecasts and replays, saved dashboards, and the Analyst on the largest model for deep
work. It's self-serve, from Settings > Plan. [Enterprise](/pricing) adds usage included by contract, enhanced
forecasting, and our team working with yours.

## Upgrading

Update to `@formata/limitr` 0.8 to enforce rules in your app. On an older SDK, a contract's prices still apply on
Cloud's invoices, but its limits, gives, takes, and caps aren't enforced there. Contracts and rules are on Scale and
Enterprise. Pricing rules from before move over on their own, as a rule and a contract each, so your customers pay
the same.

## Get started

The [Contracts guide](/guides/cloud/contracts) and the [Customers guide](/guides/cloud/customers#accounts) cover
every part of it. [Start free](https://cloud.limitr.dev/?signup), or
[talk to us](https://calendly.com/d/ctjd-5gm-qqc/limitr-demo-with-founders) about putting your contracts in place,
or an Enterprise trial. The engine is open source on [GitHub](https://github.com/dev-formata-io/limitr).
