---
title: "Backfill token usage from AgentsView payloads"
method: POST
path: "/api/tokens/backfill"
tags: ["jobs"]
---

# Backfill token usage from AgentsView payloads

`POST /api/tokens/backfill`

## Request body

- BackfillTokensRequest
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `dry_run` boolean
  - `sessions` SessionUsagePayload[], nullable, required
    - `agent` string
    - `cached_input_tokens` integer
    - `cost` CostEnvelope
      - `microdollars` integer
    - `cost_usd` number, double
    - `has_cost` boolean, nullable, required
    - `has_token_data` boolean, nullable, required
    - `input_tokens` integer
    - `peak_context_tokens` integer
    - `project` string
    - `session_id` string, required
    - `total_output_tokens` integer

## Response `200`

OK

- TokenSummary
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `failed` integer, required
  - `results` TokenResult[], nullable, required
    - `agent` string
    - `job_id` integer
    - `reason` string
    - `session_id` string, required
    - `status` string, required
    - `summary` string
  - `skipped` integer, required
  - `total` integer, required
  - `updated` integer, required

## Other responses

- `400`
- `500`

## Changes

- **2026-07-30** `54a65a0ebf15` — 1 info
  - added the new optional request property `sessions/items/cost`
- **2026-06-22** `5b911260736f` — 2 info
  - added the new optional request property `sessions/items/cached_input_tokens`
  - added the new optional request property `sessions/items/input_tokens`
- **2026-06-09** `538b457f849b` — 2 warning
  - removed the request property `sessions/items/cached_input_tokens`
  - removed the request property `sessions/items/input_tokens`

[Change history](https://skmtc.dev/kenn-io/apis/roborev/changes/api/tokens/backfill/post.md)

---

[API](https://skmtc.dev/kenn-io/apis/roborev.md) · [All operations](https://skmtc.dev/kenn-io/apis/roborev/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/kenn-io/roborev/revisions/0dfdca81e88d/schema)
