API v2 (Latest)
Version 2 (v2) of the Analytics API provides programmatic access to the AI usage data for your organization. Use it to retrieve metrics on AI adoption, activity, credits consumption, and other metrics that may be relevant across your teams and tools.
The following groups of endpoints are available:
AI adoption and usage: Number of users who have AI enabled and active, quota consumption over time, and data on principals who have hit their usage limits.
AI activity and impact: Suggested and accepted lines of code, as well as the number of invocations of AI tools.
AI credits consumption: AI credits consumption data grouped by AI tool, with an optional per-principal breakdown.
Code provenance: Lines of code generated by humans or AI tools and the time saved by AI, broken down by feature.
AI token usage: Number of tokens used over time, broken down by AI provider, with an optional per-model breakdown.
API reference
AI adoption and usage
Get AI adoption metrics by date
Get AI adoption and usage data for the specified date range, grouped by date. The returned data includes both metrics by day and total numbers for the date range. Filters for principalFilter, principalType, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get quota consumption metrics by date
Get quota consumption data for the specified date range, grouped by date. The consumption information includes both built-in quota and top-up AI credits. Filters for tools, principalFilter, principalType, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get quota consumption metrics by date and tool
Get quota consumption data for the specified date range, grouped by date, with a per-AI tool breakdown for each period and per-AI tool totals for the entire date range. All filters are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get limit hit metrics by date
Get data about the number of principals who hit their AI credit limits in the specified date range, grouped by date. Filters for principalFilter and principalType are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get limit hit metrics by principal and date
Get a cursor-paginated list of limit hits for each date and principal within a specified date range. When sortKey is date (default), sorting is done by date first, then by principal ID. When sortKey is name, sorting is done by principal name first, then by date. Filters for principalFilter and principalType are applied together (the API returns only records that match all criteria).
Request parameters
Responses
AI activity and impact
Get total AI activity and impact metrics
Get total AI activity and impact metrics for the specified date range. The metrics include suggested and accepted lines of code, as well as the number of invocations of AI tools. Filters for tools, principalFilter, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get AI activity and impact metrics by date
Get AI activity and impact metrics for the specified date range, grouped by date. The metrics include suggested and accepted lines of code, as well as the number of invocations of AI tools. Filters for tools, principalFilter, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get AI activity and impact metrics by date and feature
Get AI activity and impact metrics for the specified date range, grouped by date and feature. The metrics include suggested and accepted lines of code, as well as the number of invocations of AI tools. Filters for tools, principalFilter, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
AI credits consumption
Get AI credits consumption by AI tool
Get AI credits consumption data for the specified date range, grouped by AI tool. The consumption information includes both built-in quota and top-up AI credits. Filters for tools, principalFilter, principalType, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get AI credits consumption by principal with a per-tool breakdown
Get a cursor-paginated list of AI credits consumption data per principal, with a per-AI tool breakdown for each principal. When sortKey is usage (default), sorting is done by total AI credits used first, then by principal ID and principal type. When sortKey is name, sorting is done by principal name. Filters for tools, principalFilter, principalType, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Code provenance
Get code provenance metrics by date and feature
Get the number of lines of code generated by humans or AI tools, as well as the time saved by AI within the specified date range, grouped by date and feature. Filters for features, principalFilter, and ides are applied together (the API returns only records that match all criteria).
Request parameters
Responses
AI token usage
Get token usage metrics by date and provider
Get token usage data for the specified date range, grouped by date, with a per-provider breakdown for each period and per-provider totals for the entire date range. Filters for providers, principalFilter, and principalType are applied together (the API returns only records that match all criteria).
Request parameters
Responses
Get token usage metrics by model
Get a cursor-paginated list of token usage per model, with the AI provider each model belongs to. Sorting is done by the sortKey (totalTokens by default). Filters for providers, principalFilter, and principalType are applied together (the API returns only records that match all criteria).