---
title: "Get Cost History"
method: GET
path: "/api/v1/costs/history"
---

# Get Cost History

`GET /api/v1/costs/history`

Return cost history for chart visualization.

Two response modes share one endpoint:

* ``GET /costs/history?hours=24&granularity=hour`` (web GUI sparkline) -
  returns a flat ``[{ts, usd}]`` array bucketed from cost-tracker
  usages over the last *hours* window.
* ``GET /costs/history`` *or* ``?envelope=1`` (legacy/CLI) - returns the
  original ``{history, trend, burn_rate_*, history_days}`` envelope
  built from ``.sdd/metrics/cost_history.jsonl`` daily snapshots.

The sparkline branch lets the GUI feed `recharts` directly without
unwrapping a ``.history`` field.

## Query parameters

- `hours` integer, nullable
- `granularity` string
- `envelope` integer

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/sipyourdrink-ltd/apis/bernstein-task-server.md) · [All operations](https://skmtc.net/sipyourdrink-ltd/apis/bernstein-task-server/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sipyourdrink-ltd/bernstein-task-server/revisions/86f514b4e920/schema)
