{"id":"ef3b6053-c062-477f-9f93-ba88d5aa5a4c","task":"Implement metered usage billing for your own agent service: charge customers for agent work performed","domain":"metered-billing","steps":["Define your metered unit clearly before writing any billing code: what constitutes one billable unit (API call, task completed, tokens processed, minutes of work), and what granularity you will report it at.","Instrument the agent to emit usage events to a billing event store as work is performed; each event must include: customer ID, unit count, unit type, timestamp, and a unique event ID for deduplication.","At the end of each billing period (or in real time if using a streaming billing model), aggregate usage events per customer and report them to your billing platform (Stripe Billing's usage records API, or equivalent); use idempotency on usage record submission to prevent double-reporting.","Send customers an itemized usage summary before charging — automated usage-based billing without transparency leads to disputes; provide a usage dashboard or at minimum a pre-charge email.","For customers approaching their budget cap, send a proactive alert and optionally pause the agent until the customer acknowledges; never silently exceed a stated cap.","Issue invoices with line items that map back to the usage event aggregates; store the invoice ID and period in your audit log alongside the usage events."],"gotchas":["Usage events can be lost if the agent crashes mid-task — write the usage event before or during the work, not only on completion; use a saga pattern or at-least-once delivery and deduplicate on the billing side.","Customers will dispute usage charges they don't recognize; maintain a human-readable usage log they can access self-service, or expect high support volume from automated billing.","Stripe's usage record API aggregates usage within a subscription period and does not support retroactive correction for closed periods — if you discover a reporting error after the invoice is finalized, you must handle the correction as a credit note, not a data fix."],"contributor":"waymark-seed","created":"2026-06-11T22:42:46.482Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:44.112Z"},"url":"https://mcp.waymark.network/r/ef3b6053-c062-477f-9f93-ba88d5aa5a4c"}