Search before asking
What happened
When using a Claude Console Admin API key (sk-ant-admin01-...), the connection test passes but data collection fails with:
permission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
The plugin calls these Claude Enterprise endpoints which require read:analytics scope on an sk-ant-api01-... key (only available to Claude Enterprise / claude.ai customers):
v1/organizations/analytics/users
v1/organizations/analytics/summaries
v1/organizations/analytics/connectors
Claude Console organizations (platform.claude.com) use a different API entirely:
v1/organizations/usage_report/claude_code (query param: starting_at instead of date)
Claude Console Admin keys (sk-ant-admin01-...) have full access to the Console endpoint but the plugin never calls it, so Console orgs have no way to collect analytics data.
API differences:
|
Enterprise API |
Console API |
| Endpoint |
v1/organizations/analytics/users |
v1/organizations/usage_report/claude_code |
| Date param |
date |
starting_at |
| User field |
user.id / user.email_address |
actor.type + actor.email_address |
| Sessions |
claude_code_metrics.core_metrics.distinct_session_count |
core_metrics.num_sessions |
| Commits |
claude_code_metrics.core_metrics.commit_count |
core_metrics.commits_by_claude_code |
| Lines added |
claude_code_metrics.core_metrics.lines_of_code.added_count |
core_metrics.lines_of_code.added |
| Tool accepted |
tool_actions.edit_tool.accepted_count |
tool_actions.edit_tool.accepted |
| Chat metrics |
Yes |
No |
| Model cost breakdown |
No |
Yes |
Pagination envelope (data, has_more, next_page) is identical across both APIs.
References:
What do you expect to happen
Organizations using Claude Console (platform.claude.com) with sk-ant-admin01-... Admin API keys should be able to collect Claude Code analytics data via v1/organizations/usage_report/claude_code.
Suggested fix: detect API type from key prefix (sk-ant-admin01- = Console, sk-ant-api01- = Enterprise) or add an explicit ApiType field to the connection model. For Console orgs, the analytics/summaries and analytics/connectors collectors should be skipped gracefully since those endpoints have no Console equivalent. All core Claude Code metrics (sessions, commits, PRs, lines of code, tool actions) are available in the Console API and can map to the existing ClaudeCodeUserActivity model.
How to reproduce
- Create a Claude Console Admin API key at
platform.claude.com/settings/admin-keys (key starts with sk-ant-admin01-)
- In DevLake, go to Connections → Claude Code → create a new connection
- Paste the
sk-ant-admin01-... key and fill in the Organization ID
- Click Test Connection — it succeeds
- Add a scope and trigger a data sync
- Sync fails with:
permission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
Environment:
- DevLake version: v1.0.3-beta13
- Anthropic account type: Claude Console (
platform.claude.com)
- Admin key prefix:
sk-ant-admin01-...
Anything else
No response
Version
v1.0.3-beta13
Are you willing to submit PR?
Code of Conduct
Search before asking
What happened
When using a Claude Console Admin API key (
sk-ant-admin01-...), the connection test passes but data collection fails with:permission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
The plugin calls these Claude Enterprise endpoints which require
read:analyticsscope on ansk-ant-api01-...key (only available to Claude Enterprise /claude.aicustomers):v1/organizations/analytics/usersv1/organizations/analytics/summariesv1/organizations/analytics/connectorsClaude Console organizations (
platform.claude.com) use a different API entirely:v1/organizations/usage_report/claude_code(query param:starting_atinstead ofdate)Claude Console Admin keys (
sk-ant-admin01-...) have full access to the Console endpoint but the plugin never calls it, so Console orgs have no way to collect analytics data.API differences:
v1/organizations/analytics/usersv1/organizations/usage_report/claude_codedatestarting_atuser.id/user.email_addressactor.type+actor.email_addressclaude_code_metrics.core_metrics.distinct_session_countcore_metrics.num_sessionsclaude_code_metrics.core_metrics.commit_countcore_metrics.commits_by_claude_codeclaude_code_metrics.core_metrics.lines_of_code.added_countcore_metrics.lines_of_code.addedtool_actions.edit_tool.accepted_counttool_actions.edit_tool.acceptedPagination envelope (
data,has_more,next_page) is identical across both APIs.References:
What do you expect to happen
Organizations using Claude Console (
platform.claude.com) withsk-ant-admin01-...Admin API keys should be able to collect Claude Code analytics data viav1/organizations/usage_report/claude_code.Suggested fix: detect API type from key prefix (
sk-ant-admin01-= Console,sk-ant-api01-= Enterprise) or add an explicitApiTypefield to the connection model. For Console orgs, theanalytics/summariesandanalytics/connectorscollectors should be skipped gracefully since those endpoints have no Console equivalent. All core Claude Code metrics (sessions, commits, PRs, lines of code, tool actions) are available in the Console API and can map to the existingClaudeCodeUserActivitymodel.How to reproduce
platform.claude.com/settings/admin-keys(key starts withsk-ant-admin01-)sk-ant-admin01-...key and fill in the Organization IDpermission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
Environment:
platform.claude.com)sk-ant-admin01-...Anything else
No response
Version
v1.0.3-beta13
Are you willing to submit PR?
Code of Conduct