Skip to main content
Who this is for: Organization owners and the teams who need their organization’s usage and estimated cost in their own tools.
The Analytics API is a read-only HTTP API that returns your organization’s token usage and estimated cost, from the same metering as the Analytics page. It can return figures for each member, with the member’s name and email address. It doesn’t return conversation content, files, or anything your users type into Claude.

Get access to the Analytics API

The API is off by default. To start using it:
  1. As an Owner or a Primary Owner, go to Settings > Config in the organization admin portal, expand Analytics API under Admin Console, turn on its switch, and click Save changes.
  2. As a Primary Owner, create an admin API key with Usage and cost reports selected.
A key reads only its own organization, so to cover several organizations, create a key in each. Keys from the tenant admin portal don’t read usage. If Analytics API is marked Locked by your tenant, only a tenant administrator can change it.

Send a request to the Analytics API

Send a GET request to one of these paths on your Claude for Government host, which is the domain name in the address of your organization admin portal:
  • /gateway-api/v1/organizations/analytics/usage for token usage
  • /gateway-api/v1/organizations/analytics/cost for estimated cost
Send your admin API key in the x-api-key header. Every request also needs the anthropic-beta header while the API is in beta. This request returns token usage for each model:
A response can take close to a minute, so set your client’s timeout to at least 60 seconds. To copy your full address and a sample curl command, go to Settings > Admin API keys in the organization admin portal and find Calling the Analytics API.

Query parameters

The /usage and /cost paths accept these parameters. To give a parameter that ends in [] several values, repeat it, as in products[]=desktop&products[]=m365. With curl, add --globoff so that it doesn’t interpret the []. A misspelled model or member ID returns no rows, not an error. Daily rows run from midnight to midnight UTC, whatever offset you send. The API rounds both ends of the range down, to midnight UTC for daily rows and to the hour otherwise. To include today in daily rows, set ending_at to tomorrow’s date at 00:00:00Z.

Read the response

Each row in data covers one period and one combination of the fields you group by. A day, hour, member, product, or model with no usage has no row. Count a missing row as zero if its period ends at or before data_refreshed_at. This is a response to the example request for one week, shortened to one row and three of the group fields:
A row from /cost has cost in place of usage. This one, shortened the same way, is from a request with group_by[]=actor:
amount is in US cents, so "288.678000" is about $2.89. The usage and cost responses have these fields.

What the estimated cost covers

amount covers usage on self-managed tiers. It is an estimate, not your invoice.
Anthropic-managed tiers. If your agency buys seats, usage on those tiers is covered by the seat price, so it adds 0 to amount. The API’s token and request figures still include it, and the Analytics page shows these tiers separately.

When totals differ from the Analytics page

A total can differ from the one on the Analytics page for these reasons:
  • Anthropic-managed tiers: see What the estimated cost covers.
  • Cached input: total_tokens includes input written to or read from the prompt cache, and the page’s token figures don’t. The page’s input tokens are uncached_input_tokens.
  • Time: the page shows times in your browser’s time zone and includes the latest usage.

How current the figures are

The figures are one to two hours behind, and run up to data_refreshed_at. For example, a request sent at 15:30 UTC returns usage up to 14:00. When a row’s ending_at is later than data_refreshed_at, the row covers only part of its period, so read it again later. When data_refreshed_at is null, no usage in the range is available yet. A request to Claude is counted when it ends, in the hour it started, so an hour’s figures can still rise after you read them.

Read every page of results

While has_more is true, send the same request again with page set to the value of next_page. Send the other parameters as they were. You can change limit. To read many rows, set limit to 1000.

Rate limits

An organization can send about 60 requests per minute, across all its keys, and four at the same time. A request over either limit returns a 429 error.

Troubleshoot errors

An error response is JSON. Its error object has a message, and can have a code and a request_id to give your Anthropic representative.