Skip to main content
Deleting removes usage events and the metered usage behind them. It is permanent: the events are gone from Flexprice and nothing restores them. Use it when usage was ingested that should never have existed, such as a misconfigured integration sending another customer’s traffic, or a load test that ran against production keys. The endpoint is Delete events (POST /v1/events/delete).
Deleting events does not change a bill that already exists. A finalized invoice keeps its line items whether or not the usage behind them still exists, and Flexprice refuses to delete a period that a finalized invoice covers.

When to use it

  • Wrong data was ingested. A bad integration, a replayed queue, or a test harness sent events that do not represent real usage.
  • A customer’s data must be erased. A request that has to remove the raw usage, not just stop billing for it.
  • Usage landed on the wrong customer. Delete it, then send it again with the correct external_customer_id.

When not to use it

  • To correct an invoice. Issue a credit note instead, or follow Correcting usage you already sent.
  • To reduce a customer’s usage total. Deletion is not an adjustment mechanism. Price the usage correctly instead.
  • For the current period while traffic is live. period_end must already be in the past.

Who can call it

The caller must hold the super_admin role. An API key works when the user who created it holds that role. A key minted for a service account is refused whatever roles it carries, and so is any caller without the role. Both get 403.

Deleting events

A request that matches no events returns 200 with zero counts.

Request fields

Without feature_ids or event_ids, every event for those customers in that period is deleted.
skip_payload controls the audit record, not the deletion. Flexprice keeps an internal record of every deleted event. skip_payload defaults to true, which leaves the event’s properties out of that record, so a deletion made to satisfy an erasure obligation keeps no copy of the usage. Send false to keep the properties.

Rules the request must satisfy

What Flexprice refuses

A refused request deletes nothing and records nothing.

While a deletion runs

The request stays open until the deletion finishes. It takes at least 30 seconds, and longer as the number of events grows.
  • Ingestion is refused for that customer, in that period only. A backdated event whose timestamp falls inside the window gets 409, and a bulk request carrying one is refused. Part of that batch may already have been accepted, so retry the whole batch once the deletion finishes: the events that got through collapse into themselves as long as you set event_id and timestamp. The same customer keeps ingesting everything outside the period, and other customers are unaffected.
  • Invoices overlapping that period are held in draft. Finalizing one, or paying one in full, is refused with 409 until the deletion closes. Scheduled finalization skips the invoice and picks it up afterwards.
  • Draft invoices are recomputed when the deletion completes, so they stop charging for the deleted usage.
Deleted events can be sent again. Flexprice normally collapses a resent event_id into the stored original, but deletion removes that original, so re-sending the same event_id and timestamp counts as new usage.

Delete events API reference

Full request and response schema for POST /v1/events/delete.

Backfill Past Usage

Loading historical usage, and how it reaches draft and finalized invoices.

Idempotency and Deduplication

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