Skip to main content
Backfilling sends usage that happened in the past: history from the billing system you’re migrating from, or events your pipeline failed to deliver during an outage. A backfill uses the same endpoints as live ingestion. Each event’s timestamp places the usage in the right billing period, and there is no limit on how old a timestamp can be.

Backfilling usage events with the bulk endpoint

  • Set timestamp to when the usage happened, not when you send it.
  • Derive event_id from the source record, such as the row ID in your old billing system’s export or the original request ID. A rerun after a failure then collapses with what already arrived instead of counting twice.
  • Send batches of up to 1000 events with POST /v1/events/bulk. See High-Volume Ingestion.
  • Run it in a sandbox environment first. Compare totals per customer and feature with your source data, then run the same backfill in production.
Flexprice stores events for an external ID that has no customer yet and counts them once the customer exists, so customer creation and the backfill can run in either order. Usage is billed only under a subscription whose billing period covers the event’s timestamp.

How backfilled usage reaches invoices

What happens to backfilled usage depends on the state of the invoice for the billing period its timestamp falls in:
Voiding an invoice that was paid, or covered by wallet credits, returns that amount to the customer’s wallet, and recalculating a finalized invoice voids it. Check the invoice’s payment state before you recalculate it.

Correcting usage you already sent

Flexprice has no endpoint to edit or delete a usage event, and a negative property value counts as 0, so a negative event can’t cancel usage.
  • Missing usage: send it as new events with new event_id values. The table above decides how it reaches the invoice.
  • Usage that shouldn’t have been counted: Flexprice keeps the event, so correct the bill instead. Once the invoice is finalized, issue a credit note for the difference.

Send Usage Events with the API and SDKs

Authentication, single and bulk requests, and the responses to handle.

Idempotency and Deduplication

How Flexprice recognizes a copy of an event, and how to make retries and heartbeats safe.