---
title: "Put terminal runs that were never metered back on the ledger"
method: POST
path: "/v1/admin/backfills/run-usage"
tags: ["billing"]
---

# Put terminal runs that were never metered back on the ledger

`POST /v1/admin/backfills/run-usage`

## Request

- Base URL: `https://api.hyperresearch.ai`
- URL: `https://api.hyperresearch.ai/v1/admin/backfills/run-usage`
- Auth: API key in cookie `hr_session`

Writes a $0 `run` usage event for every TERMINAL run in this workspace that has none, so the metered-event count and the run count reconcile (E2E9-06). A run reaches this state when the API closes it because its Workflow is already gone — metering is one of the Workflow’s durable finalize steps, so it never ran. The amount is always ZERO: this is a reconciliation, never a late charge. Dry run unless `apply=1`. Idempotent: the ledger id is the one finalize would have used, so a finalize that arrives afterwards is a no-op rather than a double charge.

## Query parameters

- `apply` '0' | '1': Omit (or `0`) for a DRY RUN: the response lists every row that would change and nothing is written. `1` performs the rewrite.

## Response `200`

What was written, or would be

- BackfillMissingUsageSummary
  - `workspace_id` string, required
  - `scanned` integer, required
  - `found` integer, required
  - `written` integer, required
  - `applied` boolean, required: False for a dry run: nothing was written.
  - `rows` BackfillMissingUsagePlan[], required
    - `run_id` string, required
    - `status` string, required
    - `usage_event_id` string, required
    - `amount_cents` integer, required
    - `channel` string, required

## Other responses

- `400`: Invalid request
- `401`: Authentication failed
- `403`: Insufficient scope or plan
- `404`: Not found
- `429`: Rate limited or over quota
- `500`: Internal error

---

[API](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api.md) · [All operations](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api/revisions/726ef831ebf4?raw)
