Anthropic — Claude Code Analytics API (+ Claude Code routine trigger)
Status: DOCUMENTED · ACCOUNT_RESTRICTED (our regular API key → 401 authentication_error "The Admin API requires an Admin API key or an organization-scoped API key." on 2026-09-18; no Admin key in this atlas).
Sources:
- https://platform.claude.com/docs/en/manage-claude/claude-code-analytics-api
- https://platform.claude.com/docs/en/api/admin/usage_report/retrieve_claude_code (reference; twin
api/beta/organization/usage_report/retrieve_claude_code) - https://platform.claude.com/docs/en/manage-claude/analytics-api (which analytics API / key type)
- https://platform.claude.com/docs/en/api/admin/analytics (Claude Enterprise Analytics API reference — 11 endpoints)
- https://platform.claude.com/docs/en/api/claude-code/routines-fire (experimental routine trigger)
Last verified: 2026-09-18
1. Which analytics API?
| API | Endpoint(s) | Key type | Who creates it | Covers |
|---|---|---|---|---|
| Claude Code Analytics API (Admin API, Claude Console orgs) | GET /v1/organizations/usage_report/claude_code |
Admin API key sk-ant-admin01-… (or org:admin OAuth token, or a non-workspace personal/service-account key) |
Console org admin | Daily per-actor Claude Code metrics on the Claude API (not Bedrock/Vertex/Foundry) |
| Claude Enterprise Analytics API (claude.ai Enterprise orgs) | GET /v1/organizations/analytics/* (11 endpoints) |
Analytics API key created in claude.ai (scope read:analytics) |
Primary owner | Org-wide engagement/adoption (chat, projects, skills, connectors, plugins, artifacts, Claude Code, Cowork…) + cost/usage (usage-based plans) |
The two key types are not interchangeable. Free of charge. Not available on Claude Platform on AWS (use the Console Usage page).
2. GET /v1/organizations/usage_report/claude_code
| Query param | Type | Required | Notes |
|---|---|---|---|
starting_at |
YYYY-MM-DD (UTC) |
yes | single day only |
limit |
int 1–1000 | no | default 20 |
page |
string | no | opaque cursor from next_page |
Headers: x-api-key: $ANTHROPIC_ADMIN_KEY, anthropic-version: 2023-06-01 (recommended User-Agent: YourApp/1.0 (url) for integrations).
Response { data: ClaudeCodeUsageRecord[], has_more, next_page } — one record per actor × day (× terminal_type):
| Field | Type | Meaning |
|---|---|---|
date |
RFC 3339 (midnight UTC) | day covered |
actor |
{type:"user_actor", email_address} | {type:"api_actor", api_key_name} |
OAuth user vs API-key user |
organization_id |
uuid | |
customer_type |
api | subscription |
pay-as-you-go vs Pro/Team/Enterprise seats |
subscription_type |
enterprise | team | null |
null for API customers |
terminal_type |
string | vscode, iTerm.app, tmux, … |
is_remote |
bool | remote sessions (Claude Code on the web) |
core_metrics.num_sessions |
int | distinct sessions |
core_metrics.lines_of_code.{added,removed} |
int | |
core_metrics.commits_by_claude_code |
int | commits made via Claude Code |
core_metrics.pull_requests_by_claude_code |
int | |
tool_actions.{edit_tool,multi_edit_tool,write_tool,notebook_edit_tool}.{accepted,rejected} |
map | acceptance rate = accepted/(accepted+rejected) |
model_breakdown[] |
{model, tokens{input,output,cache_read,cache_creation}, estimated_cost{amount (cents), currency}} |
per model |
Example record (docs): {"actor":{"type":"user_actor","email_address":"user@…"},"core_metrics":{"commits_by_claude_code":8,"lines_of_code":{"added":342,"removed":128},"num_sessions":15,"pull_requests_by_claude_code":2},"customer_type":"api","date":"2025-08-08T00:00:00Z","is_remote":false,"model_breakdown":[{"estimated_cost":{"amount":186,"currency":"USD"},"model":"claude-opus-5","tokens":{"cache_creation":2340,"cache_read":8790,"input":45230,"output":12450}}],"terminal_type":"iTerm.app","tool_actions":{"edit_tool":{"accepted":25,"rejected":3},…},"subscription_type":"enterprise"}
Operational facts (documented): data appears within ~1 h and only data older than 1 h is returned (stable pagination); daily aggregates only (use OpenTelemetry for real time); no deletion period; UTC dates; playground/API-key attribution via api_actor.
Live probe: GET /v1/organizations/usage_report/claude_code?starting_at=2026-09-17&limit=1 → 401 (regular key). Endpoint fragment: generated/fragments/endpoints/anthropic-admin.json.
3. Claude Enterprise Analytics API (/v1/organizations/analytics/*)
All GET, Analytics API key, anthropic-version header, 60 req/min per org, data from 2026-01-01, engagement snapshots available ~17:00 UTC the next day, cost/usage within ~4 h (revised up to 30 days; data_refreshed_at in responses), bracket-list params (products[]=chat&products[]=claude_code), amounts = decimal strings in cents, cursors bound to the query (changing filters with an old cursor → 400).
| Path | Title | Key params |
|---|---|---|
/analytics/users |
List User Activity (per-user daily metrics across chat, Claude Code, Cowork, Office agent…) | starting_at (date), limit, page, filters |
/analytics/summaries |
Activity Summaries (DAU/WAU/MAU, seats, pending invites) | starting_at |
/analytics/apps/chat/projects |
Chat Project Usage | starting_at, limit, page |
/analytics/skills |
Skill Usage | starting_at, limit, page |
/analytics/connectors |
Connector Usage (names normalised, e.g. atlassian) |
starting_at … |
/analytics/plugins |
Plugin Usage | starting_at … |
/analytics/artifacts |
Artifact Activity | starting_at … |
/analytics/usage_report |
Token Usage Over Time | starting_at (RFC 3339), ending_at, bucket_width 1m/1h/1d, group_by[] (model, product, inference_geo, context_window, speed, rbac_group_id, claude_tag_*, slack_channel_id), filters products[], models[], user_ids[]… |
/analytics/user_usage_report |
Per-User Token Usage | same + order_by |
/analytics/cost_report |
Cost Over Time | starting_at, ending_at, group_by[] |
/analytics/user_cost_report |
Per-User Cost | same |
products[] enum: chat, claude-tag, claude_code, claude_design, claude_in_chrome, cowork, office_agent. Full parameter list: generated/fragments/parameters/anthropic-admin.json (endpoint GET /v1/organizations/analytics/...). All 3 probed analytics endpoints returned 401 with our key.
4. Claude Code routine trigger (experimental, different product surface)
POST https://api.anthropic.com/v1/claude_code/routines/{routine_id}/fire — starts a run of a saved Claude Code on the web routine. Auth: Authorization: Bearer sk-ant-oat01-… (per-routine token generated at claude.ai/code/routines — not an API key), required header anthropic-beta: experimental-cc-routine-2026-04-01 (missing → 400 invalid_request_error), body {"text": "..."} (context passed to the routine). Returns the session id and URL. Requires a claude.ai Pro/Max/Team/Enterprise plan; billed to the Claude Code subscription, no SDK support. Status: DOCUMENTED · PREVIEW (experimental) — not tested (no routine token).
5. Cookbook (Admin key required — mark your integration ACCOUNT_RESTRICTED until you have one)
# daily Claude Code metrics, paginate
curl -sS "https://api.anthropic.com/v1/organizations/usage_report/claude_code?starting_at=$(date -u -v-1d +%F)&limit=1000" \
-H "x-api-key: $ANTHROPIC_ADMIN_KEY" -H "anthropic-version: 2023-06-01"
# → loop while .has_more == true with &page=<next_page>Acceptance rate per tool: accepted / (accepted + rejected). Cost per user: sum model_breakdown[].estimated_cost.amount (cents). Example scripts: examples/anthropic/admin/ (usage_report.sh|py|ts, status ACCOUNT_RESTRICTED).