# Usage-based billing

> Bill customers by use with Anytime Capital Payments: meters, usage events sent from your code, and usage invoiced and charged each billing period.

Source: https://anytime-capital.com/docs/usage-billing · Markdown: https://anytime-capital.com/docs/usage-billing.md · All docs: https://anytime-capital.com/docs/llms-full.txt

A **meter** counts something your customers use (API calls, seats, gigabytes) and bills it each period at a price per unit. Create meters on the **Meters** tab of **Subscriptions** in the dashboard, then send usage from your code. Usage is billed on top of a subscription plan's price (attach the meter to the plan), or to a customer each calendar month without a plan.

- [Meters & usage events API](https://anytime-capital.com/docs/meters.md): Every endpoint and field: record events one at a time or in batches, read usage.
- [Recipe: report usage](https://anytime-capital.com/docs/bill-usage-with-meters.md): A complete usage reporter with safe retries and batching.

## How usage is billed

1. Your code sends an event for each thing used: the meter's `eventName`, the customer, and a `value`.
2. Events add up per customer and meter, the meter's way: `sum` adds values, `count` counts events, `max` takes the highest value, `last` the latest.
3. When a period closes (the subscription renews or ends, or the calendar month ends for a customer billed without a plan), the period's usage less the meter's included units is priced at the unit price.
4. Each closed period becomes an invoice with one line per meter, charged to the customer's saved card. With no saved card, or if the card is declined, the invoice is emailed for them to pay.

> **Rounding:** Unit prices can be fractions of a cent (`unitPriceCents` is a decimal string, so `0.25` is a quarter of a cent). Each meter's line is worked out exactly, (usage − included units) × unit price, and rounded once, half up, to whole cents. Nothing is rounded per event or per day.

Usage is matched to subscriptions and customers by email address, so a customer you name by id needs an email. A customer's usage on a meter is billed once: a period that has been billed is closed, and events stamped inside it are refused.

## Sending usage well

- Give every event its own `idempotencyKey`, such as your request id, so a retry after a timeout never counts twice.
- Send events as they happen, or batch up to 100 a request. Each API key may make a set number of requests a minute ([Rate limits](https://anytime-capital.com/docs/rate-limits.md)), so batching is the way to send a lot.
- Timestamps may be up to five minutes ahead of our clock and at most 400 days old, and never inside a period already billed.
- Refusals come back with a code (`METER_NOT_FOUND`, `PERIOD_CLOSED`, `TIMESTAMP_TOO_OLD`…): see [Error codes](https://anytime-capital.com/docs/error-codes.md).

---

Anytime Capital is a fintech company, not a bank. Payment processing, banking and payout services are provided by Anytime Capital's licensed partners. Rates shown are for US card payments; international cards, currency conversion and disputes may carry additional fees shown in your dashboard before you accept a payment.
