---
title: "Repair legacy run counters from the vault"
method: POST
path: "/v1/admin/backfills/run-counters"
tags: ["runs"]
---

# Repair legacy run counters from the vault

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

## Request

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

For every TERMINAL run in this workspace whose `fetch_attempts` is NULL — the marker of a row written before the counters were unified — rewrites `sources_fetched` and `notes_written` to what the run actually kept, which only the workspace vault knows. Dry run unless `apply=1`. Idempotent: a row already correct is skipped. `fetch_attempts` is deliberately not invented; unknown stays NULL.

## 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 changed, or would change

- BackfillCounterSummary
  - `workspace_id` string, required
  - `scanned` integer, required
  - `found` integer, required
  - `rewritten` integer, required
  - `already_correct` integer, required
  - `vault_unreadable` integer, required
  - `overstated` integer, required
  - `applied` boolean, required: False for a dry run: nothing was written.
  - `rows` BackfillCounterPlan[], required
    - `run_id` string, required
    - `status` string, required
    - `from_sources` integer, nullable, required
    - `from_notes` integer, nullable, required
    - `to_sources` integer, required
    - `to_notes` integer, required
    - `overstated` boolean, required: The stored count was HIGHER than what the run kept — the case a customer saw as "69 sources fetched" over "This run recorded no sources."

## 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)
