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

# Meters

> Transform raw usage events into billable quantities with aggregation and filtering.

Meters convert raw events into billable quantities. They filter events and apply aggregation functions (Count, Sum, Max, Last) to calculate usage per customer.

<Frame>
  <img src="https://mintcdn.com/dodopayments/w9oVTi6CzZMAOQA3/images/usage-based/UBB-2.png?fit=max&auto=format&n=w9oVTi6CzZMAOQA3&q=85&s=f9d85a463fba231437151db3d4a2052a" alt="Meter creation interface showing event name, aggregation type, and filtering options" style={{ maxHeight: '500px', width: 'auto' }} width="2324" height="1600" data-path="images/usage-based/UBB-2.png" />
</Frame>

## API Resources

<AccordionGroup>
  <Accordion title="View Meter API References">
    <CardGroup cols={2}>
      <Card title="Create Meter" icon="plus" href="/api-reference/meters/create-meter">
        Create meters programmatically via API.
      </Card>

      <Card title="List Meters" icon="list" href="/api-reference/meters/get-meters">
        Retrieve all meters in your account.
      </Card>

      <Card title="Get Meter" icon="eye" href="/api-reference/meters/retrieve-meter">
        Fetch details for a specific meter by ID.
      </Card>

      <Card title="Archive Meter" icon="arrow-rotate-right" href="/api-reference/meters/archive-meter">
        Archive a meter to stop tracking usage.
      </Card>

      <Card title="Unarchive Meter" icon="arrow-rotate-left" href="/api-reference/meters/unarchive-meter">
        Restore an archived meter to resume tracking.
      </Card>
    </CardGroup>
  </Accordion>
</AccordionGroup>

## Creating a Meter

<Steps>
  <Step title="Basic Information">
    <ParamField path="Meter Name" type="string" required>
      A descriptive name for the meter (e.g., "API Requests", "Token Usage").
    </ParamField>

    <ParamField path="Event Name" type="string" required>
      The exact event name to match (case-sensitive). Examples: `api.call`, `image.generated`.
    </ParamField>
  </Step>

  <Step title="Aggregation">
    <ParamField path="Aggregation Type" type="string" required>
      Choose how events are aggregated:

      * **Count**: Total number of events (API calls, uploads)
      * **Sum**: Sum of numeric values (tokens, bytes)
      * **Max**: Highest value in the period (peak users)
      * **Last**: Most recent value
    </ParamField>

    <ParamField path="Over Property" type="string">
      The metadata key to aggregate (required for Sum, Max, and Last). Examples: `tokens`, `bytes`, `duration_ms`.
    </ParamField>

    <ParamField path="Measurement Unit" type="string" required>
      The unit label for invoices and reports. Examples: `calls`, `tokens`, `GB`, `hours`.
    </ParamField>
  </Step>

  <Step title="Filtering (Optional)">
    <Frame>
      <img src="https://mintcdn.com/dodopayments/w9oVTi6CzZMAOQA3/images/usage-based/UBB-3.png?fit=max&auto=format&n=w9oVTi6CzZMAOQA3&q=85&s=ce231b0559d31723bc12c22cd9ff9d64" alt="Event filtering interface with AND/OR logic and comparison operators" style={{ maxHeight: '500px', width: 'auto' }} width="1558" height="942" data-path="images/usage-based/UBB-3.png" />
    </Frame>

    Add conditions to filter which events are counted:

    * **AND logic**: All conditions must match
    * **OR logic**: Any condition can match

    Available comparators: equals, not equals, greater than, greater than or equals, less than, less than or equals, contains, does not contain.

    Enable filtering, choose your logic, then add conditions with a property key, comparator, and value.
  </Step>

  <Step title="Create">
    Review your configuration and click **Create Meter**.
  </Step>
</Steps>

## Viewing Analytics

<Frame>
  <img src="https://mintcdn.com/dodopayments/w9oVTi6CzZMAOQA3/images/usage-based/UBB-1.png?fit=max&auto=format&n=w9oVTi6CzZMAOQA3&q=85&s=7fb86a266b5aa84f281b680601bd998e" alt="Meter analytics dashboard showing usage overview, events, and customer data" style={{ maxHeight: '500px', width: 'auto' }} width="1536" height="1252" data-path="images/usage-based/UBB-1.png" />
</Frame>

Your meter dashboard displays:

* **Overview**: Total usage and usage trends over time
* **Events**: Individual events received and their metadata
* **Customers**: Per-customer usage totals and charges

## Billing in Credits Instead of Currency

By default, meters charge customers per-unit in dollars (or your configured currency). You can instead configure a meter to deduct from a customer's credit balance, so usage consumes credits rather than generating a monetary charge.

<Info>
  Credit-based deduction requires a [Credit Entitlement](/features/credit-based-billing) attached to the same product. Create the credit entitlement first, then link it to the meter.
</Info>

### When to Use Credit-Based Deduction

| Scenario | Standard (currency) | Credit-based |
| - | - | - |
| Simple per-unit pricing (\$0.01/call) | ✅ Best fit | Unnecessary overhead |
| Prepaid credit packs (buy 10K tokens, use over time) | ❌ Can't express | ✅ Best fit |
| Bundled usage with subscriptions (Pro plan includes 100K calls) | Possible via free threshold | ✅ Better: credits roll over, expire, and show in portal |
| Multi-meter products sharing a credit pool | ❌ Each meter bills separately | ✅ All meters deduct from one balance |

### Configuring a Meter to Deduct Credits

<Steps>
  <Step title="Create a Credit Entitlement">
    First, create a credit entitlement in **Products → Credits**. Define the unit (e.g., "API Calls", "Tokens"), precision, and lifecycle settings (expiry, rollover, overage).

    See the [Credit-Based Billing guide](/features/credit-based-billing) for detailed instructions.
  </Step>

  <Step title="Create or Edit a Usage-Based Product">
    Go to your usage-based product and open the **Meter** configuration section.
  </Step>

  <Step title="Add a Meter">
    Click the **+** button to attach a meter. Configure the event name, aggregation type, and measurement unit as usual.
  </Step>

  <Step title="Enable 'Bill Usage in Credits'">
    Toggle **Bill usage in Credits** on the meter configuration to reveal credit settings:

    <Frame caption="Toggle 'Bill usage in Credits' to switch from currency-based to credit-based deduction.">
      <img src="https://mintcdn.com/dodopayments/ibNfoFRyCIGyt3pO/images/CBB/Desktop%20-%20Attach%20Credit%20-%20UBB-5.jpg?fit=max&auto=format&n=ibNfoFRyCIGyt3pO&q=85&s=b4ef2fe5079cbf3bb39eb3814f101cbd" alt="Meter configuration with Bill usage in Credits toggle enabled" style={{ maxHeight: '500px', width: 'auto' }} width="2880" height="2282" data-path="images/CBB/Desktop - Attach Credit - UBB-5.jpg" />
    </Frame>

    <ParamField path="Credit Entitlement" type="string" required>
      Select which credit entitlement this meter deducts from.
    </ParamField>

    <ParamField path="Meter units per credit" type="number" required>
      The number of usage units required to deduct 1 credit. For example:

      * `1` = each meter event deducts 1 credit
      * `100` = 100 meter events deduct 1 credit
      * `1000` = 1,000 API calls consume 1 credit
    </ParamField>
  </Step>

  <Step title="Free Threshold and Credits">
    The **Free Threshold** applies to meters billed in money, not to meters billed in credits. When a meter bills in credits, every unit counts toward credit deduction.

    **Example**: With meter-units-per-credit of 1, a customer who makes 2,500 API calls has 2,500 credits deducted.
  </Step>
</Steps>

### How Credit Deduction Works

Once configured, the deduction pipeline runs automatically:

1. **Events arrive** — Your application sends usage events via the [Event Ingestion API](/features/usage-based-billing/event-ingestion).
2. **Meter aggregates** — Events are aggregated per your meter configuration (Count, Sum, Max, Last).
3. **Background worker processes** — Every minute, a worker fetches new events since the last checkpoint.
4. **Credits are deducted** — Aggregated usage is converted to credits using the `meter_units_per_credit` rate and deducted using FIFO ordering (earliest-expiring grants consumed first).
5. **Overage tracked** — If the balance hits zero, further usage is recorded as overage and handled according to the configured behavior (forgiven at reset, billed at next invoice, or carried forward as deficit). Dodo Payments doesn't block usage when the balance runs out. To stop access at zero, check the balance in your application.

```mermaid theme={null}
flowchart LR
    A[Usage Event] --> B[Meter Aggregation]
    B --> C{Credits Available?}
    C -->|Yes| D[Deduct from Balance]
    C -->|No| E{Overage Enabled?}
    E -->|Yes| F[Track Overage]
    E -->|No| G[Your App Enforces Limits]
    D --> H[Update Ledger]
    F --> H
```

<Warning>
  Credit deduction runs asynchronously (every \~1 minute). There may be a brief delay between event ingestion and balance deduction. Design your application to handle this delay and don't rely on real-time balance checks for access control on individual requests.
</Warning>

### Multiple Meters, One Credit Pool

You can link multiple meters on the same product to the same credit entitlement. All meters deduct from one shared balance.

**Example**: An AI platform with two meters:

* `text.generation` — 1 credit per 1,000 tokens
* `image.generation` — 10 credits per image

Both deduct from the same "AI Credits" pool. The customer sees a single unified balance in their portal.

<Tip>
  Use different `meter_units_per_credit` rates across meters to express relative costs. Expensive operations (image generation) cost fewer meter units per credit than cheap ones (text completion).
</Tip>

<CardGroup cols={2}>
  <Card title="List Customer Ledger" icon="scroll" href="/api-reference/credit-entitlements/list-customer-ledger">
    View the full credit deduction history for a customer.
  </Card>

  <Card title="Get Customer Balance" icon="wallet" href="/api-reference/credit-entitlements/get-customer-balance">
    Check a customer's current credit balance via API.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Events not appearing">
    * Event name must match exactly (case-sensitive)
    * Check that meter filters aren't excluding events
    * Verify customer IDs exist in your account
    * Temporarily disable filters to test
  </Accordion>

  <Accordion title="Aggregation not working">
    * Verify the Over Property matches the metadata key exactly
    * Use numbers, not strings: `tokens: 150` not `tokens: "150"`
    * Include required properties in all events
  </Accordion>

  <Accordion title="Filters not working">
    * Match case exactly
    * Use correct operators for the data type
    * Ensure events include the filtered properties
  </Accordion>

  <Accordion title="Wrong usage totals">
    * Check the Events tab to count actual events received
    * Verify the aggregation type (Count vs Sum)
    * Ensure values are numeric for Sum and Max
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Send Events" icon="bolt" href="/features/usage-based-billing/event-ingestion">
    Start sending usage events from your application to your meters.
  </Card>

  <Card title="View Blueprints" icon="copy" href="/features/usage-based-billing/ingestion-blueprints">
    Use ready-made meter configurations for common use cases.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.