File: claude-code-analytics-api.md | Updated: 11/15/2025
Agent Skills are now available! Learn more about extending Claude's capabilities with Agent Skills .
English
Search...
Ctrl K
Search...
Navigation
Administration and monitoring
Claude Code Analytics API
Home Developer Guide API Reference Model Context Protocol (MCP) Resources Release Notes
On this page
The Admin API is unavailable for individual accounts. To collaborate with teammates and add members, set up your organization in Console → Settings → Organization.
The Claude Code Analytics Admin API provides programmatic access to daily aggregated usage metrics for Claude Code users, enabling organizations to analyze developer productivity and build custom dashboards. This API bridges the gap between our basic Analytics dashboard and the complex OpenTelemetry integration. This API enables you to better monitor, analyze, and optimize your Claude Code adoption:
Admin API key requiredThis API is part of the Admin API
. These endpoints require an Admin API key (starting with sk-ant-admin...) that differs from standard API keys. Only organization members with the admin role can provision Admin API keys through the Claude Console
.
Get your organization’s Claude Code analytics for a specific day:
Copy
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?\
starting_at=2025-09-08&\
limit=20" \
--header "anthropic-version: 2023-06-01" \
--header "x-api-key: $ADMIN_API_KEY"
Set a User-Agent header for integrationsIf you’re building an integration, set your User-Agent header to help us understand usage patterns:
Copy
User-Agent: YourApp/1.0.0 (https://yourapp.com)
Track Claude Code usage, productivity metrics, and developer activity across your organization with the /v1/organizations/usage_report/claude_code endpoint.
Key concepts
starting_at parameterFor complete parameter details and response schemas, see the Claude Code Analytics API reference .
Basic examples
Get analytics for a specific day
Copy
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?\
starting_at=2025-09-08" \
--header "anthropic-version: 2023-06-01" \
--header "x-api-key: $ADMIN_API_KEY"
Get analytics with pagination
Copy
# First request
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?\
starting_at=2025-09-08&\
limit=20" \
--header "anthropic-version: 2023-06-01" \
--header "x-api-key: $ADMIN_API_KEY"
# Subsequent request using cursor from response
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?\
starting_at=2025-09-08&\
page=page_MjAyNS0wNS0xNFQwMDowMDowMFo=" \
--header "anthropic-version: 2023-06-01" \
--header "x-api-key: $ADMIN_API_KEY"
Request parameters
| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| starting_at | string | Yes | UTC date in YYYY-MM-DD format. Returns metrics for this single day only |
| limit | integer | No | Number of records per page (default: 20, max: 1000) |
| page | string | No | Opaque cursor token from previous response’s next_page field |
Available metrics
Each response record contains the following metrics for a single user on a single day:
Dimensions
user_actor with email_address or api_actor with api_key_name)api for API customers, subscription for Pro/Team customers)vscode, iTerm.app, tmux)Core metrics
Tool action metrics
Breakdown of tool action acceptance and rejection rates by tool type:
Model breakdown
For each Claude model used:
claude-sonnet-4-5-20250929)USD)Response structure
The API returns data in the following format:
Copy
{
"data": [\
{\
"date": "2025-09-01T00:00:00Z",\
"actor": {\
"type": "user_actor",\
"email_address": "developer@company.com"\
},\
"organization_id": "dc9f6c26-b22c-4831-8d01-0446bada88f1",\
"customer_type": "api",\
"terminal_type": "vscode",\
"core_metrics": {\
"num_sessions": 5,\
"lines_of_code": {\
"added": 1543,\
"removed": 892\
},\
"commits_by_claude_code": 12,\
"pull_requests_by_claude_code": 2\
},\
"tool_actions": {\
"edit_tool": {\
"accepted": 45,\
"rejected": 5\
},\
"multi_edit_tool": {\
"accepted": 12,\
"rejected": 2\
},\
"write_tool": {\
"accepted": 8,\
"rejected": 1\
},\
"notebook_edit_tool": {\
"accepted": 3,\
"rejected": 0\
}\
},\
"model_breakdown": [\
{\
"model": "claude-sonnet-4-5-20250929",\
"tokens": {\
"input": 100000,\
"output": 35000,\
"cache_read": 10000,\
"cache_creation": 5000\
},\
"estimated_cost": {\
"currency": "USD",\
"amount": 1025\
}\
}\
]\
}\
],
"has_more": false,
"next_page": null
}
The API supports cursor-based pagination for organizations with large numbers of users:
limit parameterhas_more is true in the response, use the next_page value in your next requesthas_more is falseThe cursor encodes the position of the last record and ensures stable pagination even as new data arrives. Each pagination session maintains a consistent data boundary to ensure you don’t miss or duplicate records.
How fresh is the analytics data?
Claude Code analytics data typically appears within 1 hour of user activity completion. To ensure consistent pagination results, only data older than 1 hour is included in responses.
Can I get real-time metrics?
No, this API provides daily aggregated metrics only. For real-time monitoring, consider using the OpenTelemetry integration .
How are users identified in the data?
Users are identified through the actor field in two ways:
user_actor: Contains email_address for users who authenticate via OAuth (most common)api_actor: Contains api_key_name for users who authenticate via API keyThe customer_type field indicates whether the usage is from api customers (API PAYG) or subscription customers (Pro/Team plans).
What’s the data retention period?
Historical Claude Code analytics data is retained and accessible through the API. There is no specified deletion period for this data.
Which Claude Code deployments are supported?
This API only tracks Claude Code usage on the Claude API (1st party). Usage on Amazon Bedrock, Google Vertex AI, or other third-party platforms is not included.
What does it cost to use this API?
The Claude Code Analytics API is free to use for all organizations with access to the Admin API.
How do I calculate tool acceptance rates?
Tool acceptance rate = accepted / (accepted + rejected) for each tool type. For example, if the edit tool shows 45 accepted and 5 rejected, the acceptance rate is 90%.
What time zone is used for the date parameter?
All dates are in UTC. The starting_at parameter should be in YYYY-MM-DD format and represents UTC midnight for that day.
The Claude Code Analytics API helps you understand and optimize your team’s development workflow. Learn more about related features:
Monitoring usage with OpenTelemetry for custom metrics and alerting
Was this page helpful?
YesNo
Assistant
Responses are generated using AI and may contain mistakes.