Skip to main content
For plans with usage-based pricing, you must report usage to Credibill so we know how much to charge.

Reporting Usage

Usage is reported via Usage Records. You can report usage as it happens (real-time) or in batches.
await credibill.usage.create({
  subscription: 'sub_...',
  quantity: 1,
  action: 'increment', // or 'set'
  timestamp: Date.now() / 1000
});

Aggregation Types

When configuring a metered component in a Plan, you choose how usage is aggregated over the billing period:
  • Sum: Adds up all reported usage (e.g., API calls).
  • Max: Uses the maximum value recorded (e.g., Peak Storage).
  • Last: Uses the most recent value recorded (e.g., Number of Active Users).

Idempotency

To prevent double-billing due to network retries, you should provide an idempotency_key when reporting usage. This ensures a specific event is counted only once.