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.
Principals: Search the principals (users and service accounts) you are authorized to view.
Groups: List the groups you are authorized to view, look them up by ID, or get the groups a set of users belong to.
API reference
AI adoption and usage
Get AI adoption metrics by date
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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
Returns 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).
Request parameters
Responses
Principals
Search principals
Returns a cursor-paginated list of principals (users and service accounts) you are authorized to view.
Unauthorized principals are excluded. Principals listed explicitly in the principalIds filter that you are not authorized to view are also excluded from the result. If no principals remain viewable after exclusion, the result is empty.
Multiple filters are combined to match all criteria.
Use the limit field in the request body to set the maximum number of results per page.
Request parameters
Responses
Groups
List groups
Returns a cursor-paginated list of groups you are authorized to view. Groups you are not authorized to view are excluded from the results. Each page includes the number of results defined by limit. Results are always returned in ascending order.
Request parameters
Responses
Get groups by IDs
Returns the groups you are authorized to view. If the request includes groups you are not authorized to view, they are excluded from the result.
Request parameters
Responses
Get groups by user IDs
Returns the groups that the specified users belong to, narrowed to the groups you are authorized to view. The result is returned per requested user.