Get Per-User Token Usage
[Legacy] Get per-user token usage across a date range.
Returns usage per user, ranked by the chosen token metric; group_by[] or bucket_width splits a user across several rows. Use this to see which users consume the most tokens. Only usage attributed to a user account is included, so usage 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/usage in the Usage and Cost Analytics API instead. To move an existing integration, see Migrate from the Claude Enterprise usage and cost reports.
Parameters
Returns
<?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->userUsageReport->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: 'output_tokens',
page: 'page',
products: [AnalyticsProductFilter::CHAT],
rbacGroupIDs: ['rbac_group_012rppKaSVsmTo6NqRDXQXNF'],
slackChannelIDs: ['C0123ABCDEF'],
speeds: ['fast'],
userIDs: ['user_01AbCdEfGhIjKlMnOpQrSt'],
);
var_dump($page);{
"data": [
{
"actor": {
"deleted": true,
"email_address": "jane@example.com",
"name": "Jane Smith",
"type": "user_actor",
"user_id": "user_01AbCdEfGhIjKlMnOpQrSt"
},
"cache_creation": {
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 0
},
"cache_read_input_tokens": 3200000,
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"ending_at": "2019-12-27T18:11:19.117Z",
"inference_geo": "global",
"model": "claude-opus-5-5",
"output_tokens": 891000,
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"requests": 128,
"server_tool_use": {
"web_search_requests": 10
},
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"starting_at": "2019-12-27T18:11:19.117Z",
"total_tokens": 5377000,
"uncached_input_tokens": 1284500
}
],
"data_refreshed_at": "2019-12-27T18:11:19.117Z",
"has_more": true,
"next_page": "next_page",
"organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"
}Returns Examples
{
"data": [
{
"actor": {
"deleted": true,
"email_address": "jane@example.com",
"name": "Jane Smith",
"type": "user_actor",
"user_id": "user_01AbCdEfGhIjKlMnOpQrSt"
},
"cache_creation": {
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 0
},
"cache_read_input_tokens": 3200000,
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"ending_at": "2019-12-27T18:11:19.117Z",
"inference_geo": "global",
"model": "claude-opus-5-5",
"output_tokens": 891000,
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"requests": 128,
"server_tool_use": {
"web_search_requests": 10
},
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"starting_at": "2019-12-27T18:11:19.117Z",
"total_tokens": 5377000,
"uncached_input_tokens": 1284500
}
],
"data_refreshed_at": "2019-12-27T18:11:19.117Z",
"has_more": true,
"next_page": "next_page",
"organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"
}