Skip to main content
Read and write token cost records, the 30-day summary the Tokens Used panel shows, and the fleet overview the Fleet panel shows. Use this page when you build your own spend report or health dashboard. Examples use the default port 18790 and no access token. With STUDIO_ACCESS_TOKEN set, add -b 'clawboo_access=<token>' to each curl. All four routes are on the general rate limit described in the REST API overview. Errors use { "error": "<message>" }.

Routes

Cost records

A cost record is one run’s token counts plus a price. The server records each OpenClaw Gateway turn itself, and those rows carry a sessionKey. Rows posted through POST /api/cost-records (by your own script, or by the dashboard for a Gateway turn of an agent it does not list as OpenClaw) have sessionKey: null. The server also writes one record for each Clawboo Native, Claude Code, Codex or Hermes run when it settles the run’s cost, on the task runner (agent routines and API runs) and in team chat. Those rows carry a sessionKey too, and runId is the run’s execution id when it has one. When the run reported no token counts, they are guessed from the text at about 4 characters per token. One-to-one chats with these agents write no records, and runs from before these records were added are not backfilled. A cost record is a report only. Writing one does not charge a budget; budget spend is tracked separately (see the Governance API). Deleting an agent deletes its cost records.
On rows the server records for OpenClaw turns, and on rows posted through POST /api/cost-records, costUsd is an estimate from a built-in price list, never a figure a provider reported. The list covers Anthropic Claude models plus gpt-4o and gpt-4o-mini. A model your own Ollama serves is priced at $0: an ollama/ model id, or an OpenClaw turn the Gateway says Ollama served, unless its tag marks one of Ollama’s cloud models (-cloud or :cloud). Any other model is priced at $3 per million input tokens and $15 per million output tokens. A row for another runtime’s run carries the cost that run recorded: Claude Code’s reported figure, or Clawboo’s estimate. For which runtimes report real provider cost, see Budgets and spend.
The record shape, returned by both cost-record routes:

GET /api/cost-records

Lists cost records, newest first, at most 500.
  • Query params:
Any other period value applies no time filter.

Responses

200 OK:
500 Internal Server Error: a database failure, { "error": "<message>" }.

Example

POST /api/cost-records

Records one run’s token usage. The server prices it with the built-in list and stores the result. An agentId with no agent row gets a placeholder row (named after the id) so the record can be stored.
  • Request body:
Model ids match the price list exactly first, then by substring with dots read as dashes, so anthropic/claude-haiku-4.5 is priced as claude-haiku-4-5.

Responses

200 OK: the stored record:
400 Bad Request: the body is not a JSON object:
400 Bad Request: agentId or model is empty, or a token count is missing:
500 Internal Server Error: a database failure, { "error": "<message>" }.

Example

GET /api/cost-records/summary

Totals for the Tokens Used panel, built from the records of the last 30 days. Every window starts at midnight in the server’s time zone: today, 7 days ago, and 30 days ago. Takes no parameters.

Responses

200 OK:
500 Internal Server Error: a database failure, { "error": "<message>" }.

Example

Fleet summary

GET /api/fleet/summary

A read-only overview built from data Clawboo already stores: agents per runtime, board tasks and verification verdicts from the last 24 hours, recorded task cost, and budgets. It backs the Fleet panel in Settings. Takes no parameters.

Responses

200 OK:
500 Internal Server Error: building the summary failed, { "error": "<message>" }.

Example

Source of truth: apps/web/server/api/costRecords.ts, costRecordsSummary.ts, fleet.ts, and the price list in apps/web/server/lib/costUtils.ts.
Last modified on October 31, 2026