Claude Console Integration
Customer Onboarding Guide: Claude Console Usage and Cost Admin API
TL;DR
What this does: Connects OneLens to your Claude Console (Claude Console, platform.claude.com) organization to break down Claude API spend by workspace, API key, model, service tier and cost type, plus per-user Claude Code cost.
Time required: ~10 minutes
Who you need: An organization member with the admin role in Claude Console (only admins can create Admin API keys).
What OneLens reads: Token counts, USD costs, and Claude Code activity counters from Anthropic's Usage and Cost Admin API and Claude Code Analytics API. Your prompts, completions, files and model outputs are never accessed.
What You'll Get Once Connected
Unified AI Cost Explorer
Shows Claude API spend next to your cloud and other AI provider costs in one view.
Workspace Cost Allocation
Splits cost by Claude Console workspace, so each team or product line sees its own bill. Default workspace usage is labeled.
API Key Attribution
Breaks token usage down by API key, so you can trace spend to a specific app, service or environment.
Per-Model Cost Analysis
Separates cost by model (Opus, Sonnet, Haiku) and context window tier.
Service Tier Breakdown
Separates standard, batch and Priority Tier token usage. Shows how much traffic already gets the 50% batch discount.
Prompt Cache Efficiency
Compares cached input, cache creation and uncached input tokens per workspace and model, to show where caching is paying off.
Fast Mode & Data Residency
Tracks fast mode usage and inference_geo (us vs global) as separate cost dimensions.
Web Search & Code Execution
Reports web search and code execution costs as their own line items.
Claude Code Per-User Cost
Shows estimated Claude Code cost and token usage per developer, by model, along with sessions, commits and PRs.
Budget Alerts & Anomalies
Flags spend spikes by workspace, key or model, and tracks spend against thresholds you set in OneLens.
Security at a Glance
Does OneLens read our prompts or model outputs?
No. The endpoints OneLens calls return token counts, dollar amounts, model names, and workspace and API key IDs. They return no prompt or response content.
Is the Admin API key read-only?
No, and you should know this before you create it. Claude Console Admin API keys have no selectable scopes. Every key can call every Admin API endpoint, including ones that manage members, workspaces and API keys. OneLens sends only GET requests to the endpoints listed under "What OneLens Will Access".
How do we limit the risk of a full-access key?
Set an expiration when you create the key, give it a name that identifies OneLens, and revoke it from Settings > Admin keys whenever you want. OneLens stores it encrypted and never displays it after you save it.
Can OneLens see our Claude API keys?
No. The List API Keys endpoint returns key names, IDs and a partially redacted hint, never the secret. The Admin API cannot reveal or recover a usable Claude API key.
What authentication is used?
An Admin API key (sk-ant-admin01-...) sent in the x-api-key header. It expires on the date you choose at creation, or never if you select Never.
How is data transmitted and stored?
All API calls use TLS 1.2+. Credentials and collected data are encrypted at rest with GCP KMS, and access to them inside OneLens is restricted.
Can I restrict by IP?
Anthropic does not document IP allowlisting for Admin API keys. Access control comes from the admin role required to create the key, the key's expiration, and revocation.
Cost of the Integration
OneLens creates nothing in your Claude Console organization. It reads reports from Anthropic's hosted Admin API.
API calls
About 5 calls per day: usage report (1), cost report (1), Claude Code report (1 per 1,000 users), workspace and API key names (2)
$0 (Admin API calls use no tokens)
Data egress
JSON responses, usually well under 5 MB per day
$0
Compute in your account
None. OneLens calls Anthropic's hosted API
$0
Storage in your account
None
$0
Estimated total
$0 + $0 + $0 + $0
$0/month on your Anthropic bill
The first sync makes a few more calls to backfill the current month: usage report (1) + cost report (1) + Claude Code report (1 per day elapsed, up to 31) = 33 calls at most, also $0. Anthropic lists the Claude Code Analytics API as free for all organizations with Admin API access.
How It Works
The Usage and Cost Admin API returns the same data you see on the Usage and Cost pages in Claude Console, at finer detail. OneLens reads three reports:
Usage report (
/v1/organizations/usage_report/messages): token counts in daily buckets, grouped by workspace, API key, model, service tier, context window, inference geography and speed. Priority Tier usage appears only here.Cost report (
/v1/organizations/cost_report): USD cost per day, grouped by workspace and description (model, token type, web search, code execution). Amounts arrive as decimal strings in cents (for example,"41280.000000"is $412.80). OneLens parses them as exact decimals so large totals don't pick up rounding errors.Claude Code report (
/v1/organizations/usage_report/claude_code): one record per developer per day, with estimated cost by model, sessions, lines changed, commits and PRs.
OneLens also reads your workspace and API key lists once a day, only to show names instead of raw IDs in dashboards. Everything is normalized into the same cost model as your other AI providers.
Prerequisites
A Claude Console organization. The Admin API is not available for individual accounts; set up an organization under Console > Settings > Organization first.
A member with the admin role in that organization.
Your Claude API traffic goes to Anthropic directly (api.anthropic.com).
What OneLens Will Access
GET /v1/organizations/usage_report/messages
Daily token usage by workspace, API key, model and tier
GET /v1/organizations/cost_report
Daily USD cost by workspace and cost description
GET /v1/organizations/usage_report/claude_code
Per-user Claude Code cost, tokens and activity
GET /v1/organizations/workspaces
Workspace names for display (IDs only otherwise)
GET /v1/organizations/api_keys
API key names for display (returns a redacted hint, no secret)
What OneLens Will NOT Access
Prompts, completions or any Messages API content
Files, batches or anything stored in your workspaces
The Compliance API Activity Feed, even though a Console Admin API key can reach it
Member, invite, workspace or API key management (no create, update, archive or delete)
Rate limit or spend limit configuration
Any
POST,PUT,PATCHorDELETErequest
Create an Admin API Key
Sign in to Claude Console as an organization admin
Go to Settings > Admin keys
Click Create key and name it OneLens Integration
Choose an expiration. We recommend "Never" or maximum expiration the organization supports, Console limits the choices to that maximum.
Click Create, then copy the secret (it starts with
sk-ant-admin01-). Console shows it only once
Verify the Key Works
Run this from your terminal. Replace the dates with a recent 7-day window:
A JSON response with a data array means the key works. An empty results list for every day means the key is valid but the organization had no billed usage in that window; pick a window when you know traffic ran.
Verify the Connection
After you save the key, OneLens runs three checks:
Calls the cost report for the last 7 days to confirm the key is valid and cost data is readable
Calls the usage report for the same window to confirm token data is readable
Lists workspaces to confirm names resolve
When all three pass, data starts appearing within 24 hours. OneLens backfills from the 1st of the current month (UTC) and collects daily from then on. Earlier months are not imported.
Data Refresh Schedule
Usage report and cost report
Once daily
Usually within 5 minutes of the request; sometimes longer
Claude Code report
Once daily
Up to 1 hour
Workspace and API key names
Once daily
Immediate
Anthropic's data is close to real time, but OneLens polls daily. Daily cost buckets are the finest grain the cost report supports, and polling more often would not change the daily totals. The current day's figures can still move until the day closes in UTC, so OneLens re-reads the previous day on each poll.
Key Lifecycle
Admin API keys expire on the date chosen at creation. Keys created with Never do not expire.
Only organization admins can create Admin API keys, in Settings > Admin keys.
An expired or revoked key stops OneLens polling right away. OneLens alerts you when polling starts failing.
Rotation: Create a new key, update it in OneLens, then revoke the old one. OneLens uses the new key on the next daily poll, so there is no gap in data.
Data Privacy & Security
✅ No prompt or completion content. Only token counts, costs, IDs and names
✅
GETrequests only, to the five endpoints listed above✅ Full-access key risk disclosed up front, with expiration and one-click revocation as the controls
✅ TLS 1.2+ for all data in transit
✅ GCP KMS encryption for credentials and collected data at rest
✅ API key secrets never collected. OneLens sees names and redacted hints only
✅ Claude Code developer emails used only for per-user cost attribution
✅ Data retention: 12 months by default, configurable. Deletion within 30 days of a request, with confirmation
Need Help?
Anthropic Documentation:
OneLens Support: support@astuto.ai · Security: security@astuto.ai
Troubleshooting
401 authentication error
Key is wrong, expired or revoked, or it's a regular sk-ant-api03- key instead of an Admin key
Create a new key in Settings > Admin keys and confirm it starts with sk-ant-admin01-
401 or 403 with a key from claude.ai
A Claude Enterprise Analytics key was used. It can't call the Admin API
Use the Claude Enterprise integration for that key, or create a Console Admin key for this one
Error that the Admin API is unavailable
The Console account is an individual account, not an organization
Set up an organization in Console > Settings > Organization, then create the key
Org runs on Claude Platform on AWS and no data arrives
Anthropic does not offer these endpoints on Claude Platform on AWS
Not supported yet. Use the Console Usage and Cost pages, or contact OneLens support
Workspace shows as "Default" or blank
Usage in the default workspace has a null workspace_id
Expected. Move apps into named workspaces if you want them allocated separately
API key shows as "Console / Playground"
Playground usage in Console has no API key, so api_key_id is null
Expected. No action needed
OneLens total is lower than the Anthropic invoice
Priority Tier costs are not in the cost report
OneLens estimates Priority Tier from usage tokens. Use your invoice for the exact Priority Tier amount
429 rate limit errors
Another tool is polling the Admin API heavily from the same organization
OneLens retries automatically. If it persists, reduce polling from other tools
Connected, but no data after 24 hours
No billed usage since the 1st of the month, or the key expired after setup
Run the Step 2 command with a window you know had traffic. If it fails, rotate the key
Appendix: Other Admin Credentials
The Admin API also accepts an OAuth token with the org:admin scope, or a personal or service account API key that isn't scoped to a workspace. We don't recommend either for OneLens. A non-workspace API key can also call the Messages API, so a leaked key could run up model charges as well as reach admin endpoints. A dedicated Admin API key does the job with nothing extra attached.
Frequently Asked Questions
Reference sources: Usage and Cost API · Create an Admin API key · Claude Code Analytics API · Authentication and key expiration · Get your Claude API key
Last updated

