Usage & Cost Tracking Best Practices
A checklist for keeping Admin API cost data accurate, current, and actionable.
Search across all documentation pages
A checklist for keeping Admin API cost data accurate, current, and actionable.
api_key_ids or workspace_ids reduces data transferred and aggregation work compared to fetching everything and filtering in Python.group_by=["api_key_id"] call is one round trip against a consistent time window; N separate filtered calls is slower and risks window drift between calls.Keeping token types separate through your pipeline (section A, first item). Nearly every other practice on this page, from accurate pricing to a useful chargeback breakdown, depends on that separation being preserved rather than collapsed early.
A single grouped call returns every identifier's data from the exact same time window in one request, while looping per key risks the window shifting slightly between calls and multiplies API usage for no benefit.
The key-issuance and attribution practices (requiring an owning team at key creation, never sharing keys across teams) are worth adopting early regardless, since retrofitting them onto existing keys later is far more work than starting with them.
For a true one-off, informal question, yes. For anything recurring or presented to a stakeholder who might reasonably ask "why did this change," keep the per-token-type or per-dimension breakdown available at least one level below the total.
Individual spend and engagement figures can reveal performance-adjacent information about specific employees, similar in sensitivity to other individual-level people data your organization already restricts access to.
At minimum whenever your API key or workspace structure changes, such as a team splitting or a new integration being added, and as a baseline practice, at least annually even without a known change.
A new API key gets issued without the key-to-team mapping being updated, so its usage either fails loudly (if the pipeline is built to raise on an unmapped key, as recommended here) or, worse, gets silently dropped or misattributed.
Only at the end. Rounding each intermediate bucket before summing introduces compounding error across many rows; carrying full precision through aggregation and rounding once at display time keeps the final total accurate.
For genuinely one-off questions, or when a non-technical stakeholder needs self-service access. Building a custom pipeline or dashboard for a question the Console already answers well is effort better spent elsewhere.
Keeping them separate means each can be audited independently: you can verify the cost numbers are correct without also having to untangle the business rules for how they're split across teams, and vice versa.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5 - and the official
anthropicPython SDK (latest 0.x release). Model names, pricing, and SDK versions move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 19, 2026