Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 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.333, published 4 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+28added
Lines−25removed
From line 5 where the diff opens
First seen 29 Oct 2026 this site's first read of the page
Recorded edits9to this page, all time

## On a cloud platform

The whole hunk

from line 5, old and new numbered
/
lines
from line 5
55---
66 
77<Tip>
8 **The Admin API isn’t available to organizations on the claude.ai Team plan or to individual Claude Console accounts.** If your company also has a Claude Console organization, you can use the API with that organization; see [Create an Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys). An individual Console account must first set up an organization on the [Organization](https://platform.claude.com/settings/organization) page (`platform.claude.com/settings/organization`) in the Claude Console.
8 The Admin API isn’t available to organizations on the claude.ai Team plan, and an individual Claude Console account can’t create an Admin API key.
99</Tip>
1010 
11If your company has a Claude Console organization, you can use the Admin API with that organization; see the [Admin API keys and tokens](https://platform.claude.com/docs/en/manage-claude/admin-api-keys) page. An individual Console account must first set up an organization on the [Organization settings](https://platform.claude.com/settings/organization) page (`platform.claude.com/settings/organization`) in the Claude Console.
12 
1113The Usage and Cost Analytics API reports historical token usage and cost for your organization, broken down by the dimensions you choose, such as model, workspace, API key, or the user or service account behind each request. For Claude Console organizations, this data is similar to what the [Usage](https://platform.claude.com/usage) and [Cost](https://platform.claude.com/cost) pages of the Claude Console show.
1214 
1315The API has two endpoints:
from line 26
2426* **Build time series:** Split results into daily, hourly, or per-minute buckets for dashboards and finance reports.
2527* **Integrate once:** The same endpoints, parameters, and response fields serve Claude Console and Claude Enterprise organizations.
2628 
27<Check>
28 **Authentication**
29The credential you send depends on your organization type. Claude Console organizations use a [Console Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#create-a-key-for-a-claude-console-organization) or another [Admin API credential](https://platform.claude.com/docs/en/manage-claude/admin-api#authentication), such as an OAuth token with the `org:admin` scope. To get such a token, see the Admin API page’s [OAuth bearer token](https://platform.claude.com/docs/en/manage-claude/admin-api#oauth-bearer-token) section.
2930 
30 Claude Console organizations use an [Admin API key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#create-a-key-for-a-claude-console-organization) or another [Admin API credential](https://platform.claude.com/docs/en/manage-claude/admin-api#authentication), such as an OAuth token with the `org:admin` scope. Send an OAuth token in an `authorization: Bearer` header instead of the `x-api-key` header; see [Obtain an OAuth bearer token](https://platform.claude.com/docs/en/manage-claude/admin-api#oauth-bearer-token).
31Claude Enterprise organizations use a key with the `read:analytics` scope. The primary owner turns on the Analytics API in claude.ai, then creates the key there. See the Analytics APIs page’s [Get access to the Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api#get-access-to-the-claude-enterprise-analytics-api) section.
3132 
32 Claude Enterprise organizations use a key with the `read:analytics` scope, created in claude.ai by the primary owner after the Analytics API is enabled for the organization; see [Get access to the Claude Enterprise Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api#get-access-to-the-claude-enterprise-analytics-api).
33On Claude Models on Google Cloud (Anthropic managed) and Claude Platform on AWS, requests use the platform’s own credentials instead. See [On a cloud platform](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api#on-a-cloud-platform).
3334 
34 The examples on this page read a key from the `ANTHROPIC_API_KEY` environment variable, so set it to your key before you run them.
35The examples on this page read a key from the `ANTHROPIC_API_KEY` environment variable, so set it to your key before you run them. With an OAuth token, set `ANTHROPIC_AUTH_TOKEN` instead and unset `ANTHROPIC_API_KEY`, because the SDK and the `ant` CLI use the key when both are set. A direct HTTP request sends the token in an `authorization: Bearer` header in place of the `x-api-key` header.
3536 
36 If you call these endpoints with an Admin API key, give the service that collects this data its own key, store it in a secrets manager, and rotate it regularly; setting a [key expiration](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration) when you create the key enforces the rotation. Where you can, use a [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) rule with the [`org:admin` scope](https://platform.claude.com/docs/en/manage-claude/wif-reference#oauth-scopes) instead, so the service gets short-lived tokens and there’s no long-lived key to leak.
37</Check>
38 
39<Note>
40 **Claude Platform on AWS:** Both endpoints are available. Requests use the Claude Platform on AWS base URL and authentication in place of an Admin API key (see [Making requests](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#making-requests)), and AWS IAM authorizes them through the [`ListAccountUsage` and `ListAccountCost` actions](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#usage-and-cost). Each request covers only the workspaces in the AWS region of the endpoint you call, so call each region’s endpoint to cover your whole organization. `user_profile_id`, `claude_tag_category`, `claude_tag_user_id`, and the Claude Managed Agents dimensions (`agent_id`, `environment_id`, `deployment_id`, and `session_id`) are `null` on every row.
41</Note>
42 
43<Note>
44 **Claude Models on Google Cloud (Anthropic managed):** Both endpoints are available. Call them through the [organization-level base URL](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#making-requests) with Google Cloud credentials instead of an Admin API key. The `/usage` endpoint needs the `usageAnalytics.list` [IAM permission](https://platform.claude.com/docs/en/api/claude-models-on-google-cloud-anthropic-managed-iam-permissions), and the `/cost` endpoint needs `costAnalytics.list`.
45</Note>
46 
4737## Quick start
4838 
4939Get daily token usage for the first week of September, one row for each model and day:
from line 243
253243}
254244```
255245 
246If you call these endpoints with an Admin API key, give the service that collects this data its own key. Store the key in a secrets manager and rotate it regularly. For a Console Admin API key, setting a [key expiration](https://platform.claude.com/docs/en/manage-claude/api-keys#key-expiration) when you create the key enforces the rotation. For a Console organization, you can use a [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) rule with the [`org:admin` scope](https://platform.claude.com/docs/en/manage-claude/wif-reference#oauth-scopes) instead. The service then gets short-lived tokens, and there’s no long-lived key to leak.
247 
256248<Tip>
257249 **Set a User-Agent header for integrations**
258250 
from line 270
278270 
279271The `actor` dimension is who a request is attributed to: a user, a service account, a federated cloud identity (an AWS or Google Cloud principal, for organizations that access Claude through their cloud platform), or, when none of those is behind the request, the API key itself. When you group by `actor`, each row’s `actor` is an object whose `type` says which kind it is. Usage that can’t be attributed to any identity has `actor: null`.
280272 
281[Personal keys and service account keys](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) act as the user or service account they’re linked to, so their requests show that identity as the `actor` and the key in `api_key_id`. Legacy workspace keys aren’t linked to an identity, so the key appears as both the `actor` and the `api_key_id`.
273[Personal keys and service account keys](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) act as the user or service account they’re linked to. Their requests show that identity as the `actor` and the key’s ID in `api_key_id`. Workspace keys (legacy) aren’t linked to an identity, so the `actor` is the key itself, and `api_key_id` holds its ID.
282274 
283275Requests made without an API key, such as from the Claude Console or with a [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) token, have `api_key_id: null`. With a Workload Identity Federation token, the `actor` is the service account the token acts as.
284276 
285Whichever way a member signs in to Claude Code with their Claude Console account, the `actor` is that member. If Claude Code creates an API key at sign-in, `api_key_id` is that key, which lives in the [Claude Code workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#claude-code-workspace). After a [sign-in without an API key](https://code.claude.com/docs/en/authentication#sign-in-without-an-api-key), `api_key_id` is `null`.
277Whichever way a member signs in to Claude Code with their Claude Console account, the `actor` is that member. If Claude Code creates an API key at sign-in, `api_key_id` holds that key’s ID. The key lives in the [Claude Code workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#claude-code-workspace). After a [sign-in without an API key](https://code.claude.com/docs/en/authentication#sign-in-without-an-api-key), `api_key_id` is `null`.
286278 
287279Token usage from some [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview) sessions is attributed to an Anthropic-managed service account (`svac_...`). For this usage, `api_key_id` is `null`. The account isn’t listed with the service accounts that you create. See [Find session usage across your organization](https://platform.claude.com/docs/en/managed-agents/session-observability#find-session-usage-across-your-organization).
288280 
from line 789
797789 
798790Every response includes a `data_refreshed_at` timestamp, and usage after that time is missing or partial. When no data is available yet for any part of the requested range, `data_refreshed_at` is `null` and `data` is empty. Data typically refreshes within 4 hours of the underlying usage and can take up to 24 hours. Values can be revised as late events arrive and reconciliation runs, until about 7 days after the end of the calendar month. For example, values for October 1 can change until about November 7. For stable results across repeated calls, set `ending_at` at or before a `data_refreshed_at` you have already seen; for final totals, query only months that ended at least 7 days ago. Every page of a paginated query reads the same data snapshot, so `data_refreshed_at` is identical across pages.
799791 
792## On a cloud platform
793 
794**Claude Platform on AWS:** Both endpoints are available. Requests use the Claude Platform on AWS base URL and its authentication, not an Admin API key (see [Making requests](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#making-requests)). AWS IAM authorizes the requests through the [`ListAccountUsage` and `ListAccountCost` actions](https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions#usage-and-cost). Each request covers only the workspaces in the AWS region of the endpoint you call, so call each region’s endpoint to cover your whole organization.
795 
796On Claude Platform on AWS, these dimensions are `null` on every row:
797 
798* `user_profile_id`, `claude_tag_category`, and `claude_tag_user_id`
799* The Claude Managed Agents dimensions: `agent_id`, `environment_id`, `deployment_id`, and `session_id`
800 
801**Claude Models on Google Cloud (Anthropic managed):** Both endpoints are available. Call them through the [organization-level base URL](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#making-requests) with Google Cloud credentials instead of an Admin API key. The `/usage` endpoint needs the `usageAnalytics.list` [IAM permission](https://platform.claude.com/docs/en/api/claude-models-on-google-cloud-anthropic-managed-iam-permissions#usage-reports), and the `/cost` endpoint needs `costAnalytics.list`.
802 
800803## Migrate from the Usage and Cost API
801804 
802805This 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:
from line 807
804807| Usage and Cost API | Usage and Cost Analytics API |
805808| ----- | ----- |
806809| No beta header | `anthropic-beta: analytics-usage-cost-2026-08-24` on every request |
807| Data typically appears within 5 minutes | Data typically refreshes within 4 hours and can take up to 24 hours (see [Data freshness](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api#data-freshness)) |
810| Usage data typically appears within about 30 minutes. Cost data is daily. | Data typically refreshes within 4 hours and can take up to 24 hours (see [Data freshness](https://platform.claude.com/docs/en/manage-claude/usage-cost-analytics-api#data-freshness)) |
808811| `data` is a list of time buckets, oldest first, including empty ones, each with a `results` list whose entries hold dimensions and metrics side by side | `data` is a list of rows ranked by `order_by`, each with its own `starting_at` and `ending_at`, dimensions in `group`, and metrics in `usage` or `cost`. Combinations with no usage or cost have no row. |
809812| `bucket_width`, default `1d` | `time_bucket_width`, no default. Pass `time_bucket_width=1d` to keep daily rows; omit it for whole-range totals. The cost endpoint also accepts every filter and `1m` and `1h` buckets. |
810813| `limit` counts time buckets per page | `limit` counts rows per page (1 to 1,000, default 20), so the number of pages depends on how many combinations have data |
from line 821
818821| 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`. |
819822| 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 |
820823 
821Two things differ for a Claude Enterprise organization:
824`/v1/organizations/usage_report/messages` and `/v1/organizations/cost_report` are not available to Claude Enterprise organizations. To move an integration that called them with an [Analytics API key](https://platform.claude.com/docs/en/manage-claude/analytics-api#get-access-to-the-claude-enterprise-analytics-api), follow this section, with these differences:
822825 
823826* **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).
827* **Usage totals:** `/v1/organizations/usage_report/messages` leaves out usage from some Claude products, such as Cowork, text chats in Claude, and Claude Code in the terminal. The Usage and Cost Analytics API counts that usage, so its totals can be higher.
825828 
826829To 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:
827830 
Feedback