---
title: How do you track Claude Code usage across a team with the Analytics API?
url: https://opencontroller.lyzr.com/blog/track-claude-code-usage-with-the-analytics-api
published: 2026-11-17
updated: 2026-11-17
author: Lyzr
---

# How do you track Claude Code usage across a team with the Analytics API?

**Call the Claude Code Analytics Admin API at `/v1/organizations/usage_report/claude_code` with an Admin API key. It returns one day of aggregated records per user or API key: sessions, lines added and removed, commits, pull requests, tool accept/reject counts, and tokens and estimated cost per model. It only covers Claude Code usage authenticated against your Claude Console organization, so subscription seats, Bedrock and Vertex usage need a different source.**

Most teams start asking this question when Claude Code spend shows up as one line on an invoice. The Analytics API is the quickest way to turn that line into "who, how much, on which model". It is not a real-time control and it does not see every way developers can run Claude Code. This guide covers what it returns, what it misses, and how to use it for governance.

## What does the Claude Code Analytics API return?

Each call returns metrics for a single UTC day, set by the required `starting_at` parameter (YYYY-MM-DD). Records are paginated with an opaque cursor: `limit` defaults to 20 and goes up to 1,000, and you pass `next_page` back as `page` until `has_more` is false. Data appears with up to a one-hour delay.

| Group | Fields | Governance use |
|---|---|---|
| Dimensions | `date`, `actor` (`user_actor` with `email_address`, or `api_actor` with `api_key_name`), `organization_id`, `customer_type`, `terminal_type`, `subscription_type`, `is_remote` | Attribute usage to a person or a named key; separate local and remote sessions |
| Core metrics | `num_sessions`, `lines_of_code.added`, `lines_of_code.removed`, `commits_by_claude_code`, `pull_requests_by_claude_code` | Adoption and output volume per developer |
| Tool actions | `accepted` / `rejected` for `edit_tool`, `multi_edit_tool`, `write_tool`, `notebook_edit_tool` | How often humans reject proposed file changes |
| Model breakdown | `model`, `tokens.input`, `tokens.output`, `tokens.cache_read`, `tokens.cache_creation`, `estimated_cost.amount` (cents USD) | Cost per person per model; cache efficiency |

One actor can have several records for the same day, one per combination of `terminal_type`, `customer_type`, `subscription_type` and `is_remote`. Sum them to get a daily total. Anthropic's docs define tool acceptance rate as `accepted / (accepted + rejected)`.

Access needs an Admin API key, an OAuth token with the `org:admin` scope, or a key not scoped to a workspace. Workspace API keys do not work. The API is free for organizations with Admin API access.

## What does the Analytics API not cover?

This is the part that trips up governance teams. Per Anthropic's documentation:

1. **Subscription sign-ins are excluded.** When a developer signs in to Claude Code with a Pro, Max, Team or Enterprise plan, usage is attributed to the claude.ai organization and this API does not return it. Claude Enterprise organizations use the separate Enterprise Analytics API with an Analytics API key.
2. **Only the Claude API is covered.** Claude Code routed through Amazon Bedrock or Google Vertex AI is billed and logged in those clouds. Organizations on Claude Platform on AWS are pointed to the Usage page in the Console instead.
3. **It is daily, not real time.** Anthropic recommends the OpenTelemetry integration for real-time monitoring and alerting.
4. **It is not an audit log of commands.** You get counts, not the commands, files or prompts. Anthropic's Compliance API and OpenTelemetry events are the routes for activity-level data.
5. **Cost is estimated.** `estimated_cost` is a per-model estimate in cents, not your invoice.

So the honest answer to "how much Claude Code are we using?" usually needs two or three sources joined on email address.

## How do you build a governance report from it?

A practical weekly job looks like this:

1. **Pull every day of the week.** Loop `starting_at` over seven UTC dates and page through each with `limit=1000`.
2. **Roll up per actor.** Sum records per `email_address` or `api_key_name`. Flag `api_actor` rows: a shared API key running Claude Code hides who did the work.
3. **Join to your identity provider.** Map emails to department and cost centre. Emails that do not match an active employee are a finding.
4. **Rank cost by model.** Sum `estimated_cost.amount` by `model`. A spike on the largest model is the usual cost driver.
5. **Watch cache ratios.** Compare `cache_read` with `input` tokens. Low cache reuse on long sessions often signals wasted spend.
6. **Watch rejection rates.** A falling rejection rate on `write_tool` can mean developers are approving changes without reading them, which is a review-quality signal, not just productivity.
7. **Check remote use.** `is_remote = true` means remote Claude Code sessions. Confirm those environments meet your sandbox and secrets rules.
8. **Reconcile with other sources.** Add subscription seats from the Enterprise Analytics API or claude.ai dashboard, and Bedrock or Vertex usage from those clouds.

## Analytics API or OpenTelemetry: which should you use?

Use both, for different jobs. The Analytics API is simple and needs no client configuration: good for monthly chargeback and adoption reviews. OpenTelemetry needs settings pushed to every developer machine (managed settings are the usual route) but gives near-real-time metrics and events, works on any plan, and can feed alerts. Our guide to [monitoring Claude Code with OpenTelemetry](/blog/monitor-claude-code-usage-with-opentelemetry) covers that setup, and [governing Claude Code in the enterprise](/blog/govern-claude-code-in-the-enterprise) covers permissions and policy.

## How Opencontroller does this

Opencontroller connects to Claude Enterprise workspaces and Anthropic Enterprise, where it discovers and manages skills, and puts them in a governed registry alongside your other agents. Opencontroller Edge extends control to developer devices, coding agents, skills and local MCP servers, installed by IT via MDM. For traffic that runs through the Lyzr LLM Gateway, cost is attributed per agent and per version. See [how to govern AI agents across platforms](/blog/how-to-govern-ai-agents-across-platforms), the [AI agent control plane overview](/blog/what-is-an-ai-agent-control-plane), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does the Claude Code Analytics API include Claude Team or Enterprise seat usage?**
No. Usage from developers signed in with a Claude subscription plan is attributed to the claude.ai organization. Enterprise organizations use the Claude Enterprise Analytics API instead.

**How fresh is Claude Code analytics data?**
Data typically appears within one hour, and the API returns daily aggregates only. Use OpenTelemetry for real-time monitoring.

**Can I use a workspace API key to call the Claude Code Analytics API?**
No. You need an Admin API key, an OAuth token with the `org:admin` scope, or a key that is not scoped to a workspace.

## Key facts

Claude Code Analytics Admin API: GET /v1/organizations/usage_report/claude_code; requires Admin API key or OAuth org:admin; starting_at (UTC day, required), limit default 20 max 1000, cursor page. Returns per actor (user email or API key name): num_sessions, lines added/removed, commits_by_claude_code, pull_requests_by_claude_code, edit/multi_edit/write/notebook_edit accepted/rejected, tokens and estimated_cost (cents USD) per model. Up to 1-hour delay; daily only; free. Excludes Claude subscription plan sign-ins (Enterprise uses Enterprise Analytics API) and covers only Claude API usage, not Bedrock/Vertex. Opencontroller connects to Claude Enterprise workspaces, manages skills in Anthropic Enterprise; Opencontroller Edge covers coding agents on devices via MDM. Pricing starts from $250K per deployment per year (annual licence per deployment).

## Related

- [How do you monitor Claude Code usage with OpenTelemetry?](https://opencontroller.lyzr.com/blog/monitor-claude-code-usage-with-opentelemetry.md)
- [How do you govern Claude Code across an enterprise?](https://opencontroller.lyzr.com/blog/govern-claude-code-in-the-enterprise.md)
- [How do you track Claude API spend per agent with Anthropic's usage and cost APIs?](https://opencontroller.lyzr.com/blog/anthropic-usage-and-cost-api-for-agent-spend.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
