> This page is for version Preview (default).
> For other versions, use one of these documentation indexes:
> - Preview (default): https://docs.preview.paid.ai/preview/llms.txt
> - Current: https://docs.preview.paid.ai/current/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.preview.paid.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.preview.paid.ai/_mcp/server.

# Auto top-ups

> Buy more credits for customers automatically, so their work never stalls.

When a customer's credits run low, a **credit auto top-up** buys more by adding a top-up to the customer's order and invoicing it. It watches the same `available` balance your customer sees, so the top-up arrives before the work that needs the credits, not after, and usage stays paid from credits rather than running into overage.

## How they work

1. **You set a threshold** on a credit currency: a number of credits, or a percentage of what's been granted.
2. **Paid watches the balance.** When `available` falls to the threshold or below it, the balance has crossed it.
3. **The rule buys once per crossing.** It doesn't buy again until the balance has recovered above the threshold.

Because `available` already leaves out credits reserved by [credit holds](/credits/credit-holds), a hold can cross a threshold before anything is spent.

## Thresholds

An auto top-up's `threshold` takes one of two types:

| `type`             | Crossed when                                                 | Example                                                                 |
| ------------------ | ------------------------------------------------------------ | ----------------------------------------------------------------------- |
| `available`        | `value` credits or fewer are available                       | `{ "type": "available", "available": { "value": "1000" } }`             |
| `percentAvailable` | `value` percent or less of the granted credits are available | `{ "type": "percentAvailable", "percentAvailable": { "value": "10" } }` |

A percentage keeps working as the customer's grants grow.

## Set up an auto top-up

An auto top-up buys a one-time top-up price when a customer's balance falls below a threshold. Adatum first creates a top-up price that grants one credit for each credit bought, at 70¢:

**`POST /v1/prices`**

```json title="POST /v1/prices"
{
  "product": "adatum_platform",
  "name": "Credit top-up",
  "currency": "usd",
  "type": "oneTime",
  "oneTime": {
    "unit": "credit",
    "pricing": { "type": "perUnit", "perUnit": { "unitAmount": "70" } },
    "grants": [
      {
        "creditCurrency": "adatum_credits",
        "amountPerUnit": "1",
        "expiresAfter": { "value": "12", "unit": "month" }
      }
    ]
  }
}
```

Then it sets Brightrail up to buy 5,000 credits whenever 1,000 or fewer are left, at most 3 times a month:

#### API

[Create a credit auto top-up](../api-reference/credits/credit-auto-top-ups/create) with the customer, their order, the top-up price and the quantity to buy.

**`POST /v1/credit-auto-top-ups`**

```json title="POST /v1/credit-auto-top-ups"
{
  "customer": "cus_3Vb9Rk",
  "creditCurrency": "adatum_credits",
  "order": "ord_7Gk3Xs",
  "price": "prc_8Tn4Wd",
  "quantity": 5000,
  "threshold": { "type": "available", "available": { "value": "1000" } },
  "collection": "sendInvoice",
  "limits": { "maxPerMonth": 3 }
}
```

The response is the rule, with a `ctu_` ID, `status: "active"`, and `lastTriggeredAt` and `lastAmendment` set to `null` until its first purchase.

#### Dashboard

> **Draft**
>
> These steps describe the planned v1 dashboard and will change before release.

1. Go to **Operate > Customers**, open **Brightrail**, and open the **Credits** tab.
2. Click **Set up auto top-up** and choose **Adatum credits**.
3. Choose the order and the **Credit top-up** price, and enter a quantity of **5000**.
4. Set the threshold to **1000** credits available and the limit to **3** purchases a month.
5. Choose **Send invoice** and click **Create auto top-up**.

| Field                | What it's for                                                                                                                                                               |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `order`              | The customer's active [order](/orders-and-billing/orders) the top-ups are added to. It must belong to `customer`, or the request fails with `customer_mismatch`.            |
| `price`              | A one-time price whose `grants` include the credit currency.                                                                                                                |
| `quantity`           | How much of the price to buy each time, in the price's `unit`.                                                                                                              |
| `collection`         | `sendInvoice` (the default) sends the top-up invoice on the order's payment terms. `chargeAutomatically` charges `paymentMethod`, or the customer's default payment method. |
| `limits.maxPerMonth` | The most purchases in a calendar month, in UTC. Defaults to 1.                                                                                                              |

> **Note**
>
> `chargeAutomatically` depends on payment methods in the v1 API, which aren't available yet. Use `sendInvoice` until they are.

Each purchase is added to the order by [amendment](/orders-and-billing/amending-orders) and invoiced, so it shows on the order's history and its invoice like anything else your customer buys. When the credits arrive follows the price's `grantedOn`: `activation`, the default, grants them straight away, and `invoicePaid` waits until the invoice is paid.

A customer can have one enabled auto top-up per credit currency: creating or enabling a second fails with `auto_top_up_conflict`. Only one purchase is in progress at a time, and a purchase that still leaves the balance below the threshold doesn't trigger another.

## How it bills

Brightrail has 1,200 credits available when an event spends 250 of them:

| Step                             | Value                                                   |
| -------------------------------- | ------------------------------------------------------- |
| Balance after the event          | 1,200 - 250 = 950 credits, below the threshold of 1,000 |
| Purchase added by amendment      | 5,000 of the **Credit top-up** price                    |
| Invoiced now                     | 5,000 × 70¢ = 350,000¢ = **\$3,500.00**                 |
| Credits granted, on `activation` | +5,000 `adatum_credits`                                 |
| Balance after the top-up         | 950 + 5,000 = 5,950 credits                             |
| Purchases this month             | 1 of the 3 allowed                                      |

The rule records the purchase in `lastTriggeredAt` and `lastAmendment`, and is ready to buy again once the balance has recovered above 1,000 and fallen back to 1,000 or below.

## Change or retire

An auto top-up's `status` is `active`, `paused` with a `pausedReason`, or `ended` when its order ends. Three failed collection attempts in a row pause it with `pausedReason: "paymentFailed"`. [Update the rule](../api-reference/credits/credit-auto-top-ups/update) with only the fields to change, and send `enabled: true` to resume a paused rule. It checks the balance straight away, and buys if the balance is still below the threshold and the monthly limit allows. [Archive it](../api-reference/credits/credit-auto-top-ups/archive) to stop it for good. Purchases it already made stay on the order.

## Related

* [How credits work](/credits/how-credits-work)
* [Credit balances and ledger](/credits/credit-ledger)
* [Credit grants](/credits/credit-grants)
* [Amending orders](/orders-and-billing/amending-orders)
* [Credit auto top-ups API reference](../api-reference/credits/credit-auto-top-ups/create)