Claude Platform Docs

Get Per-User Cost

$client->beta->organization->analytics->userCostReport->list(\Datetime startingAt, ?BucketWidth bucketWidth, ?list<AnalyticsClaudeTagCategory> claudeTagCategories, ?list<string> claudeTagUserIDs, ?list<AnalyticsContextWindow> contextWindows, ?\Datetime endingAt, ?bool excludeDeletedUsers, ?list<GroupBy> groupBy, ?list<AnalyticsInferenceGeoFilter> inferenceGeos, ?int limit, ?list<string> models, ?Order order, ?OrderBy orderBy, ?string page, ?list<AnalyticsProductFilter> products, ?list<string> rbacGroupIDs, ?list<string> slackChannelIDs, ?list<Speed> speeds, ?list<string> userIDs): ReportPageCursor<AnalyticsCostUsersItem>
GET/v1/organizations/analytics/user_cost_report

[Legacy] Get per-user cost in USD across a date range.

Returns cost per user, ranked by spend; group_by[] or bucket_width splits a user across several rows. Use this to see which users account for the most cost. Only cost attributed to a user account is included, so cost with no user account, such as Code Review usage and Claude Tag usage in Slack channels, is left out. Claude Tag one-to-one direct messages are included, with product claude-tag, only for members who have connected a Claude account. Available to organizations on a Claude Enterprise plan. Requires an API key with the read:analytics scope.

This endpoint is one of the legacy Claude Enterprise usage and cost reports. For new integrations, use GET /v1/organizations/analytics/cost in the Usage and Cost Analytics API instead. To move an existing integration, see Migrate from the Claude Enterprise usage and cost reports.

Parameters
startingAt: \Datetime⁠Query parameter

Start of range, inclusive. RFC 3339 tz-aware. Must be within the last 365 days and no earlier than 2026-01-01T00:00:00Z.

bucketWidth?: optional BucketWidth⁠Query parameter

Time-bucket granularity. When set, each row's starting_at and ending_at are populated and one actor may span several rows (one per time bucket with usage). The time bucket counts toward limit, so one page can return multiple rows for the same actor. ending_at is required when bucket_width is set, and with bucket_width="1m" the range may span at most 24 hours. When omitted, each row aggregates the full [starting_at, ending_at) range.

claudeTagCategories?: optional list<AnalyticsClaudeTagCategory>⁠Query parameter

Filter to Claude Tag (Claude in Slack) usage in specific spend categories. Usage with no category never matches. Use group_by[]=claude_tag_category to break out per-category values.

claudeTagUserIDs?: optional list<string>⁠Query parameter

Filter to Claude Tag (Claude in Slack) usage attributed to specific Slack users, by Slack user ID (for example U0123ABCDEF), not claude.ai user ID. Usage that is not Claude Tag, and Claude Tag usage not attributed to a single user, never matches. Use group_by[]=claude_tag_user_id to break out per-user values.

contextWindows?: optional list<AnalyticsContextWindow>⁠Query parameter

Filter to specific context-window pricing tiers. Use group_by[]=context_window to break out per-tier values.

endingAt?: optional \Datetime⁠Query parameter

End of range, exclusive. When omitted, defaults to the earlier of now and starting_at + 31 days. The range may span at most 31 days.

excludeDeletedUsers?: optional bool⁠Query parameter

If true, omit rows for users who are deleted (deleted: true). A page may contain fewer than limit rows; use has_more and next_page to paginate as usual.

defaultfalse
groupBy?: optional list<GroupBy>⁠Query parameter

Break each actor's row out by the given dimensions. Accepts the same values as the bucketed /cost_report endpoint. The product, model, context_window, inference_geo, and speed dimensions — and the time bucket, when bucket_width is set — count toward limit. cost_type and token_type do not: cost_type returns one row per cost component (tokens, web search, code execution); token_type returns one row per token type, each with cost_type: "tokens"; combining both returns the per-token-type rows plus the web-search and code-execution rows. A page can therefore contain more rows than limit when cost_type or token_type is requested.

inferenceGeos?: optional list<AnalyticsInferenceGeoFilter>⁠Query parameter

Filter to specific inference regions. not_available matches rows where the region is unset. Use group_by[]=inference_geo to break out per-region values.

limit?: optional int⁠Query parameter

Number of rows per page (1-1000, default 20). One row per actor unless group_by[] or bucket_width splits an actor across rows; cost_type/token_type fan-out rows (cost endpoint only) are the exception — they do not count toward this limit, so data can exceed it.

default20
models?: optional list<string>⁠Query parameter

Models to include. Defaults to all models. Use group_by[]=model to break out per-model values.

order?: optional Order⁠Query parameter

Sort direction. Defaults to desc.

defaultdesc
orderBy?: optional OrderBy⁠Query parameter

Metric to rank actors by. Defaults to amount.

defaultamount
page?: optional string⁠Query parameter

Opaque cursor from a previous response's next_page field.

products?: optional list<AnalyticsProductFilter>⁠Query parameter

Product surfaces to include. Defaults to all products.

rbacGroupIDs?: optional list<string>⁠Query parameter

Filter to usage attributed to specific RBAC groups. Accepts tagged RBAC group IDs (rbac_group_...) or bare group UUIDs. A row matches when the user belonged to any of the listed groups on the (UTC) day the usage occurred; usage with no group attribution never matches.

slackChannelIDs?: optional list<string>⁠Query parameter

Filter to usage originating from specific Slack channels. Use group_by[]=slack_channel_id to break out per-channel values.

speeds?: optional list<Speed>⁠Query parameter

Filter to fast or standard inference mode. Use group_by[]=speed to break out per-mode values.

userIDs?: optional list<string>⁠Query parameter

Filter to specific users by tagged user ID.

Returns
class AnalyticsCostUsersItem { $actor; $amount; $claudeTagCategory; /* 15 more */ }
Get Per-User Cost
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\Organization\Analytics\AnalyticsClaudeTagCategory;
use Anthropic\Beta\Organization\Analytics\AnalyticsContextWindow;
use Anthropic\Beta\Organization\Analytics\AnalyticsInferenceGeoFilter;
use Anthropic\Beta\Organization\Analytics\AnalyticsProductFilter;

$client = new Client(apiKey: 'my-anthropic-api-key');

$page = $client->beta->organization->analytics->userCostReport->list(
  startingAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
  bucketWidth: '1d',
  claudeTagCategories: [AnalyticsClaudeTagCategory::ENGAGED],
  claudeTagUserIDs: ['U0123ABCDEF'],
  contextWindows: [AnalyticsContextWindow::FROM_0_TO_200K],
  endingAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
  excludeDeletedUsers: true,
  groupBy: ['claude_tag_category'],
  inferenceGeos: [AnalyticsInferenceGeoFilter::GLOBAL],
  limit: 1,
  models: ['string'],
  order: 'asc',
  orderBy: 'amount',
  page: 'page',
  products: [AnalyticsProductFilter::CHAT],
  rbacGroupIDs: ['rbac_group_012rppKaSVsmTo6NqRDXQXNF'],
  slackChannelIDs: ['C0123ABCDEF'],
  speeds: ['fast'],
  userIDs: ['user_01AbCdEfGhIjKlMnOpQrSt'],
);

var_dump($page);
Returns Examples
Response 200
{
  "data": [
    {
      "actor": {
        "deleted": true,
        "email_address": "jane@example.com",
        "name": "Jane Smith",
        "type": "user_actor",
        "user_id": "user_01AbCdEfGhIjKlMnOpQrSt"
      },
      "amount": "41280.000000",
      "claude_tag_category": "dm",
      "claude_tag_user_id": "U0123ABCDEF",
      "context_window": "0-200k",
      "cost_type": "code_execution",
      "currency": "USD",
      "ending_at": "2019-12-27T18:11:19.117Z",
      "inference_geo": "global",
      "list_amount": "51600.000000",
      "model": "claude-opus-5-5",
      "product": "chat",
      "rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
      "requests": 128,
      "slack_channel_id": "C0123ABCDEF",
      "speed": "fast",
      "starting_at": "2019-12-27T18:11:19.117Z",
      "token_type": "cache_creation.ephemeral_1h_input_tokens"
    }
  ],
  "data_refreshed_at": "2019-12-27T18:11:19.117Z",
  "has_more": true,
  "next_page": "next_page",
  "organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"
}