AddThisFeature

Metered Billing

Charge for measured usage without surprising anyone at invoice time.

involved Monetization

What it adds

Idempotent usage recording, defined aggregation into billable quantities, correction handling, and a running estimate the customer can see.

What your agent is told to do

5
  1. 1

    Record each usage event with a caller-supplied immutable ID and reject repeats. Retried requests and re-delivered queue messages will otherwise be billed twice.

  2. 2

    Define the aggregation window, the unit, the rounding direction and the included allowance in one place, and apply them identically to the estimate and the invoice.

  3. 3

    Show a running cost estimate in the app, labelled as an estimate, with the period it covers and the time it was last updated.

  4. 4

    Handle usage that arrives after its window closed and usage that is later reversed. Decide whether it lands in the closed period or the current one, and be consistent.

  5. 5

    Plan-cap enforcement, race-safe counting against a limit, and the blocked-at-limit upgrade prompt are owned by Usage Limits. Metering measures; it does not gate. Extend Usage Limits rather than adding a second enforcement path.

Edge cases it handles

6
  • Clock skew between reporting services will place events in the wrong window. Bill by the event's own timestamp, not arrival time, and define how late an event may be.
  • A reversed or refunded unit of usage needs a negative entry, not the deletion of the original event.
  • Rounding per event and rounding per period give different totals. Pick one, state it, and never apply both.
  • The estimate will not exactly match the final invoice once tax, discounts and provider rounding are applied. Say so next to the number rather than being caught out by it.
  • Usage recorded against a subscription that changed plan mid-period must be priced against the plan in force when it occurred.
  • A burst of events must not be dropped silently under load. Queue them durably; unbilled usage is lost revenue and over-billed usage is a refund.

Definition of done

8
  • Replaying the same usage event ID does not increase the billed quantity.
  • Window, unit, rounding and allowance definitions are shared by the estimate and the invoice calculation.
  • The customer can see current-period usage and an estimated cost, explicitly labelled as an estimate.
  • Late and reversed usage are represented as entries, and the rule for which period they affect is documented.
  • Usage is priced against the plan in force at the moment it occurred.
  • Event ingestion is durable under bursts, with no silent drops.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.