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

# Usage-Based Billing

> Implementing metered billing models

Usage-based billing (also known as metered billing) charges customers based on how much they consume your service.

## Setup Guide

To set up usage-based billing:

1. **Create a Product**: Define the service (e.g., "Cloud Storage").
2. **Create a Plan**: Select **Usage-based** pricing.
   * **Meter Name**: `storage_gb`
   * **Billing Scheme**: `per_unit`
   * **Price**: \$0.10 per GB.
3. **Subscribe Customer**: Assign the plan.
4. **Report Usage**: Send usage events via API.

## Usage Reporting Models

### 1. Metered (Sum)

Good for events like "API Calls" or "Emails Sent".

* You send: `+1`, `+5`.
* We bill: Sum of all events.
* Reset: Counter resets to 0 at start of next cycle.

### 2. Licensed (Max)

Good for "High water mark" billing, like "Max Concurrent Connections".

* You send: Current usage periodically.
* We bill: The highest value seen during the period.

### 3. Gauge (Last)

Good for "Number of Active Seats" where you want to bill for the count at the exact moment of invoicing.

* You send: Current count.
* We bill: The last value recorded before the cycle closes.

## Handling Overages

You can combine flat fees with usage.

* **Plan**: \$20/month (includes 1000 API calls).
* **Overage**: \$0.01 per call after 1000.

This is configured using **Tiers**:

* Tier 1: 0-1000 units -> \$0 (Flat fee covers this)
* Tier 2: 1001+ units -> \$0.01/unit
