# Plan and balance

A brand pays for its work in two places: the plan and the balance. Prices are never written here: read them with `list_billing_plans`, or as Markdown tables at https://otobiz.ai/pricing.md, and the brand's own numbers with `get_billing` `include=meter`.

## How they connect

| Order | What pays | What it needs |
|---|---|---|
| 1 | The plan's included usage for the month | A plan. Replies and sends need a plan. Pick a plan to start again; everything you set up is kept. |
| 2 | The balance, once the included usage ran out ("Now using your balance") | Money added by a top-up or automatic top-up |
| 3 | Nothing: work pauses | One reason and one fix (below) |

- **Included usage pays first, then the balance.** When the included usage runs out, the brand is told once: usage now comes from the balance. It comes back when the month resets.
- **Top-up needs a live plan.** Top-up comes with a paid plan. Pick a plan to add money. A trial has no top-up: subscribing is the one way on.
- **Automatic top-up needs a saved card** and the brand's one monthly spending limit. Automatic top-up needs a saved card. Save one to turn it on.
- **The monthly spending limit caps what the balance pays.** You've reached your monthly limit: everything is paused, your own replies too, until the month resets or you raise it. New messages still arrive.

## When both run out

Work pauses with one reason and one fix. New messages still arrive, and everything set up is kept.

| Reason | Fix | The tool |
|---|---|---|
| No plan, or the trial ended | Pick a plan | `create_billing_checkout` `kind: plan` |
| The trial's usage is used up | Subscribe | `create_billing_checkout` `kind: plan` |
| Usage and balance are used up | Add money | `create_billing_checkout` `kind: topup` |
| Automatic top-up is off for want of a card | Save a card | `create_billing_checkout` `kind: card_setup` |
| The monthly spending limit is reached | Raise it, or wait for the reset | `update_billing_settings` `spendCaps` |
| The plan's payment failed | Update the card | the link in the refusal's `details.paymentUrl` |

A refused call answers `402` with `details.fix` naming the fix and, where money is involved, `details.paymentUrl`. Give the person the link; never try to pay. After a payment link, call `get_billing_checkout` with `wait=true`.

## Top-up refused

| Reason | What the person reads |
|---|---|
| No live plan | Top-up comes with a paid plan. Pick a plan to add money. |
| The plan has no top-up | Your plan doesn't include top-up. A higher plan does. |
| The plan's last payment failed | Your plan's last payment didn't go through, so top-up is paused. Update your payment to turn it back on. |
| No saved card (automatic top-up) | Automatic top-up needs a saved card. Save one to turn it on. |

## How it behaves

- Nothing charges from a chat or an API call: a plan, a top-up and a saved card are each a link a person who manages billing (the owner, a Billing manager or an admin of every brand) opens and pays on the provider's page.
- Changing automatic top-up is for the owner, a Billing manager or an admin of every brand; the spending limits are an owner's or admin's (`update_billing_settings`).
- `get_billing` `include=meter` says where the brand stands in one line: what the plan used this month, then the balance, and whether work is paused with its fix.

## If it fails

| Answer | Cause | Fix |
|---|---|---|
| `402` with `details.fix` | The plan, usage, balance or spending limit refused the work | Follow `details.fix`; give the person `details.paymentUrl` |
| `402 no_plan` | A card link or top-up for a brand with no live plan | `create_billing_checkout` `kind: plan` first |
| `402 no_card_on_file` | Automatic top-up turned on with no saved card | `create_billing_checkout` `kind: card_setup` |
