> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useunitpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Credits overview

> The credit-billing path end to end — track, resolve, deduct FIFO, and ledger.

UnitPay is the billing engine where **dollars and credits are both first-class**. Most billing tools bolt credits on as an afterthought; here they run on the same catalog, the same subscriptions, and the same APIs as dollar billing — they're just a different way value moves out of the core.

This page is the hub for the credit path: how it works, when to reach for it, and where to go next.

## Two paths, one core

You model **what you sell** once and attach customers to it. From there, usage flows down one of two paths:

```mermaid actions={false} theme={null}
flowchart LR
    USE["**Usage** — you report what happened"]:::core
    USE --> DOLLAR["**Dollar billing** (invoice-time)<br/>aggregate → invoice → collect → PSP"]:::dollar
    USE --> CREDIT["**Credit billing** (track-time)<br/>resolve charge → deduct FIFO → ledger"]:::credit

    classDef core fill:#7c3aed10,stroke:#7c3aed
    classDef dollar fill:#ec489920,stroke:#ec4899
    classDef credit fill:#22c55e20,stroke:#22c55e
```

The difference is **when** money settles:

|                          | Dollar billing                                                           | Credit billing                                                                 |
| ------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| **Settles**              | At invoice time — usage aggregates and is billed at the end of the cycle | At track time — the balance is deducted the moment usage is reported           |
| **Customer holds**       | A running tab that becomes an [invoice](/documentation/billing#invoices) | A prepaid [balance](/documentation/credits/wallets-and-ledger) that draws down |
| **Runs out of money by** | Non-payment of an invoice                                                | Hitting a zero balance                                                         |
| **Real-time gate**       | Entitlement check                                                        | `check` against remaining balance                                              |

A single plan can do both — a dollar price for the subscription and a credit grant that refills every cycle.

## The credit path, step by step

```mermaid actions={false} theme={null}
flowchart LR
    T["**Track** usage"]:::s --> R["**Resolve** the charge<br/>(how many credits this costs)"]:::s
    R --> D["**Deduct** FIFO from open grants"]:::s
    D --> L["**Ledger** the deduction<br/>(append-only)"]:::s
    classDef s fill:#22c55e15,stroke:#22c55e
```

<Steps>
  <Step title="Track">
    Your app reports what happened — a message sent, a token consumed, an API call made — with `track`. This is the same call the dollar path uses; UnitPay routes it by how the plan is priced. See [the two verbs](/documentation/how-it-works#the-two-verbs).
  </Step>

  <Step title="Resolve the charge">
    UnitPay converts the raw usage into a credit cost. In a credit system, each feature has a credit cost per unit — 6 premium messages at 3 credits each resolves to 18 credits.
  </Step>

  <Step title="Deduct FIFO">
    The resolved cost is deducted from the customer's open grants in [priority order, FIFO within a priority](/documentation/credits/grants-and-priority). Expiring grants are spent before permanent ones, so nothing is wasted.
  </Step>

  <Step title="Ledger">
    Every grant and every deduction is written to the append-only [ledger](/documentation/credits/wallets-and-ledger). The customer's balance is always the sum of their open grants — never a number you mutate directly.
  </Step>
</Steps>

## When to reach for credits

Credits fit when the customer pays (or is granted) **before** they use, and value is consumed action-by-action:

* **Recurring allowances** — "1,000 credits/month" that refill each cycle, burned per message or per action (Lovable-style).
* **Prepaid balances** — "\$10 of credit" bought upfront and drawn down per token in dollars (Anthropic-API-style). See [Denominations](/documentation/credits/denominations) for the unit-vs-fiat distinction.
* **Daily free drips** on top of a paid allowance.
* **Metered work with an unknown cost** — reserve a budget, then reconcile. See [Reserving before you spend](/documentation/credits/wallets-and-ledger#reserving-before-you-spend).

Reach for **dollar billing** instead when the customer is invoiced for whatever they use at the end of the cycle — see [Billing](/documentation/billing). You don't have to choose globally: pick per feature, and mix both on one plan.

## Explore the credit path

<CardGroup cols={2}>
  <Card title="Denominations" icon="coins" href="/documentation/credits/denominations">
    Unit credits vs. fiat credits — and the rule never to mix them.
  </Card>

  <Card title="Grants & priority" icon="layer-group" href="/documentation/credits/grants-and-priority">
    What a grant is, the priority convention, and FIFO tie-breaks.
  </Card>

  <Card title="Wallets & the ledger" icon="wallet" href="/documentation/credits/wallets-and-ledger">
    Credit accounts, their lifecycle, and the append-only record.
  </Card>

  <Card title="Top-ups" icon="arrow-up-from-bracket" href="/documentation/credits/top-ups">
    Refill a balance manually, automatically, or by credit package.
  </Card>

  <Card title="Run it end to end" icon="rocket" href="/documentation/getting-started/setup">
    The Quickstart: grant credits, spend them, read the ledger.
  </Card>

  <Card title="React credit hooks" icon="react" href="/react/introduction">
    Render balances, ledger, top-ups, and burn in your app.
  </Card>
</CardGroup>
