Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

usage-cost-analytics-api changedmanage-claude/usage-cost-analytics-api

Nearest release: v2.1.328, published 7 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+24added
Lines−7removed
From line 799 where the diff opens
First seen 29 Oct 2026 this site's first read of the page
Recorded edits6to this page, all time

The whole hunk

from line 799, old and new numbered
/
lines
from line 799
799799 
800800## Migrate from the Usage and Cost API
801801 
802This section is for Claude Console organizations that call the legacy [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api) (`/v1/organizations/usage_report/messages` and `/v1/organizations/cost_report`). Your Admin API key, the `anthropic-version` header, `starting_at` and `ending_at`, the bucket width values (`1m`, `1h`, `1d`), bracket notation, the pagination field names, and the token and cost field names carry over. What changes:
802This section is for organizations that call the legacy [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api) (`/v1/organizations/usage_report/messages` and `/v1/organizations/cost_report`). Your credential and the `anthropic-version` header carry over. So do the names `starting_at` and `ending_at`, the `[]` suffix on array parameters, the pagination field names, and the token and cost field names. The usage endpoint’s bucket widths (`1m`, `1h`, `1d`) carry over too. The following table lists what changes:
803803 
804804| Usage and Cost API | Usage and Cost Analytics API |
805805| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
from line 818
818818| Cost `service_tier` is `standard` or `batch`; `amount` such as `"123.45"` | The actual tier; `amount` with six decimal places, such as `"123.450000"`, plus `list_amount`. |
819819| Code execution not in the usage report; no request counts | Code execution appears as usage rows with `model: null`; adds `requests` on both endpoints and `total_tokens` on usage rows |
820820 
821Two things differ for a Claude Enterprise organization:
822 
823* **Workspaces and API keys:** The Usage and Cost Analytics API returns `null` for `workspace_id` and `api_key_id` (see [How results are shaped](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api#how-results-are-shaped)), so the table’s row on the default workspace doesn’t apply.
824* **Usage totals:** The Usage and Cost Analytics API counts usage that the legacy usage report leaves out, so its usage totals can be higher. See [Claude Enterprise organizations](https://platform.claude.com/docs/en/manage-claude/usage-cost-api#claude-enterprise-organizations).
825 
821826To reproduce the legacy daily report, request `time_bucket_width=1d` with the same `group_by[]`, page through with `limit=1000`, then group rows by `starting_at` and fill missing days with zeros. Add `order_by=time&order=asc` to get the days in order. Daily usage by model for 1 week, before:
822827 
823828```bash cURL
from line 1295
12901295 )
12911296 
12921297 for row in rows:
1293 print(f"{row.actor.user_id}: {row.amount}")
1298 if row.actor.type == "user_actor":
1299 print(f"{row.actor.user_id}: {row.amount}")
12941300 ```
12951301 
12961302 ```typescript TypeScript
from line 1309
13031309 });
13041310 
13051311 for await (const row of rows) {
1306 console.log(`${row.actor.user_id}: ${row.amount}`);
1312 if (row.actor.type === "user_actor") {
1313 console.log(`${row.actor.user_id}: ${row.amount}`);
1314 }
13071315 }
13081316 ```
13091317 
from line 1329
13211329 
13221330 await foreach (var row in page.Paginate())
13231331 {
1324 Console.WriteLine($"{row.Actor.UserID}: {row.Amount}");
1332 if (row.Actor.TryPickBetaAnalyticsUser(out var user))
1333 {
1334 Console.WriteLine($"{user.UserID}: {row.Amount}");
1335 }
13251336 }
13261337 ```
13271338 
from line 1347
13361347 
13371348 for rows.Next() {
13381349 row := rows.Current()
1339 fmt.Printf("%s: %s\n", row.Actor.UserID, row.Amount)
1350 if user, ok := row.Actor.AsAny().(anthropic.BetaAnalyticsUserActor); ok {
1351 fmt.Printf("%s: %s\n", user.UserID, row.Amount)
1352 }
13401353 }
13411354 if err := rows.Err(); err != nil {
13421355 log.Fatal(err)
from line 1371
13581371 var rows = client.beta().organization().analytics().userCostReport().list(params);
13591372 
13601373 for (var row : rows.autoPager()) {
1361 IO.println(row.actor().userId() + ": " + row.amount());
1374 row.actor().user().ifPresent(user ->
1375 IO.println(user.userId() + ": " + row.amount())
1376 );
13621377 }
13631378 }
13641379 ```
from line 1402
13871402 )
13881403 
13891404 page.auto_paging_each do |row|
1390 puts "#{row.actor.user_id}: #{row.amount}"
1405 if row.actor.type == :user_actor
1406 puts "#{row.actor.user_id}: #{row.amount}"
1407 end
13911408 end
13921409 ```
13931410</CodeGroup>
Feedback