All guides
Implementation guides

From Product Usage to an Invoice with Tirdad

Define a billable action, configure its meter, make retries safe, apply an allowance and overage price, and trace every invoice quantity back to the product.

Updated 2026-08-14

Noura’s Growth plan includes 100 AI reports. She generates report 87 today and report 101 next week. The first is included; the second creates a SAR 2 charge.

That sounds like arithmetic. The difficult part is deciding exactly when a report counts—and making the answer survive failures, retries, plan limits, and invoice questions.

Define one unit before building the meter

Write the rule in customer language:

One unit is recorded when a financial report completes and is available to the customer. A click, failed report, or internal retry does not count.

The usage contract

Write the rule before you configure the meter.

When does one unit exist?

COUNTA financial report reaches completed status
Do not count

The customer clicks Generate

Do not count

An internal retry starts

Do not count

The report fails

One completed report = one billable unit

This sentence is the contract between product, engineering, finance, and support. It answers the first question when a customer disputes a quantity.

Resolve the edge cases now:

SituationCount it?Reason
Report completesYesThe customer received the result
Generation failsNoNo result was delivered
Internal retry succeedsOnceIt produced one result
Customer downloads againNoIt is the same report
Report is regenerated as a new resultDecide and documentProduct policy must define it

Create the meter in Tirdad

In Product Catalog, create a meter named Completed AI reports.

For this example:

  • event name: report.completed;
  • aggregation: COUNT;
  • filter: count completed reports only;
  • usage reset: billing period.
Meter configuration

The meter turns raw events into the number billing needs.

01 · EVENTreport.completed
02 · AGGREGATIONCOUNT
03 · FILTERstatus = completed
04 · RESETBilling period
SUM · tokens or pages
COUNT UNIQUE · active seats
LATEST · current storage
MAX / AVG · peak or average usage
Noura’s current period usage: 87 reports

Use another aggregation when the customer unit changes. Sum pages, count unique active users, or track the latest storage amount. Do not choose an aggregation because it is technically available; choose it because it matches the promise on the pricing page.

Send the event after the result exists

The customer’s click begins work. It does not prove that billable value exists. Send the usage event after the report reaches the completed state.

Runtime sequence

Report 87 moves from product action to billed usage.

Customer
Your application
Tirdad meter
Subscription
Generate report
Complete report 87
report.completed · event_87
Accepted · usage = 87
Apply allowance + price
13 reports remaining
Report ready · 13 remaining
The stable event ID makes a retry safe: event_87 can be resent without becoming report 88.

The event needs four durable facts:

FactExampleWhy Tirdad needs it
Event namereport.completedFinds the matching meter
CustomerNoura’s customer referenceAttributes usage correctly
Event IDevent_87Makes retries safe
TimestampWhen report 87 completedPlaces usage in the correct period

Build the event ID from the completed business action. If delivery times out, resend event_87. A retry should deliver the same fact, not invent another report.

Make delivery reliable without delaying the customer

The report and its usage event should not be able to disappear independently.

A practical pattern is:

  1. mark the report completed in your database;
  2. save a pending usage-event record in the same transaction;
  3. let a background worker send it to Tirdad;
  4. mark it delivered after Tirdad accepts it;
  5. retry with the same event ID when delivery fails.

The customer does not need to wait for the billing call to finish. Your system does need a durable record that the call remains due.

Attach the meter to the commercial rule

The meter only says Noura used 87 reports. The plan decides what that number means.

For Growth:

  • 100 reports are included each billing period;
  • reports 1–100 add no overage;
  • report 101 starts SAR 2 per report;
  • usage resets with the next billing period.
From allowance to invoice

The meter measures. The plan decides what happens next.

0187 reports

Metered usage

02100 included

Growth allowance

0313 remaining

No overage yet

04Report 101

SAR 2 overage starts

Growth subscriptionSAR 299
34 reports over limitSAR 68
Invoice totalSAR 367
A hard limit, overage, and upgrade prompt are different policies. Choose one deliberately.

Keep the policies separate:

  • the meter calculates usage;
  • the allowance says how much is included;
  • the price calculates overage;
  • the entitlement decides whether use may continue.

This separation lets you raise the allowance without changing how reports are counted, or change the overage price without rebuilding product events.

Use the same meter for cost and revenue

The cost-sheet guide connected supplier costs to report.completed. The plan charge now uses that same meter for revenue.

That gives Cost Analytics a comparable pair:

revenue from completed reports − cost of completed reports = margin

One meter now answers two different questions without mixing them: what the customer owes, and what serving that usage cost you.

Let the customer understand usage before the invoice

Do not make the invoice the first place Noura discovers report 101 was chargeable. The product should make these facts easy to find:

  • current usage: 87 reports;
  • included amount: 100;
  • remaining amount: 13;
  • reset date;
  • what happens after 100.

This is a product principle, not a prescription to place a counter beside every button. Show the commercial context where it helps the customer decide.

Debug the full path, not only the event

When usage looks wrong, trace one report through the chain:

report record → event → matched meter → subscription line → allowance → invoice

Tirdad’s event data and meter usage help answer where attribution stopped. Check rejected events, unmatched meter names, wrong customers, late timestamps, and duplicate IDs before changing the invoice manually.

Test the cases that alter money

Before launch, verify:

  • report 87 succeeds and counts once;
  • the same event ID is sent twice and still counts once;
  • a failed report counts zero;
  • an event delayed across the billing boundary lands in the intended period;
  • report 100 remains included;
  • report 101 receives the overage price;
  • cancellation and plan changes use the correct period;
  • every invoice quantity can be traced back to completed reports.

Your product decides what happened. The meter turns those facts into usage. The plan turns usage into a customer promise and an invoice you can explain.