# API v2 (Latest)

> **Note:**
> This feature is currently in preview and available for all organizations participating in the [Early Access Program (EAP)](ai-settings.html#eap). It may change and become a paid feature later. For more information, see [Plans and pricing](plans-and-pricing.html).

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.

> **Note:**
> Only a subset of endpoints has been migrated to v2 so far. Endpoints that are not yet available in v2 continue to be served from [API version 1 (v1)](analytics-api-v1.html).

> **Note:**
> To access the Analytics API, make sure that at least one role assigned to the service account you are using to access the API includes the [View AI analytics](roles.html#permissions_view_ai_analytics) permission. The data returned by the API is limited to the scope of the role: an organization-wide role returns data for the whole organization, while a group-scoped role returns data only for members of the groups that the role provides permissions for, including their subgroups.
>
>
>
> For more information on how permissions affect the returned data, see [Data visibility](ai-analytics.html#data-visibility). Note that the [View AI analytics (self)](roles.html#permissions_view_ai_analytics_self) and [Manage organization](roles.html#permissions_manage_org) permissions don't apply to service accounts and are thus not relevant for Analytics API access.

The following groups of endpoints are available:

* [Adoption and usage](#ai-adoption-and-usage-v2): Number of users who have AI enabled and active, quota consumption over time, and data on [principals](ai-governance.html#principal) who have hit their usage limits.

* [Activity and impact](#ai-activity-and-impact-v2): Suggested and accepted lines of code, as well as the number of invocations of AI tools.

* [Credit consumption](#ai-credits-consumption-v2): AI credit consumption data grouped by AI tool, with an optional per-principal breakdown.

* [Code provenance](#code-provenance-v2): Lines of code generated by humans or AI tools and the time saved by AI, broken down by feature.

* [Token usage](#ai-token-usage-v2): Number of tokens used over time, broken down by AI provider, with an optional per-model breakdown.

* [Session Explorer](#session-explorer-v2): List AI agent sessions along with their owner, timing, agent, IDE, AI provider, models, token usage, and spent AI credits.

* [Principals](#principals-v2): Search the [principals](ai-governance.html#principal) (users and service accounts) you are authorized to view.

* [Groups](#groups-v2): 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

### Adoption and usage

#### Get AI adoption metrics by date

OpenAPI endpoint: POST /api/v2/adoption/users-adoption/group-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (UsersAdoptionByDateRequest, required): The request body for getting AI adoption and usage metrics.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/adoption/users-adoption/group-by/date
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "principalType": "user",
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/adoption/users-adoption/group-by/date" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "principalType": "user",
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

AI adoption and usage data for the specified date range.

- **application/json** (UsersAdoptionCollection): A collection of AI adoption and usage data points per period.
- **items** (Array of UsersAdoptionData, required)
- **enabled** (integer, required): The number of users who have JetBrains AI enabled for the specific date.
- **active** (integer, required): The number of users who have made at least one request to JetBrains AI on the specific date.
- **date** (string date, required): The date for the AI adoption and usage metrics.
- **totalEnabled** (integer, required): The total number of users with JetBrains AI enabled within the specified date range.
- **totalActive** (integer, required): The total number of users who made at least one request to JetBrains AI within the specified date range.

**200**

```JSON
{
  "items": [
    {
      "enabled": 15,
      "active": 15,
      "date": "2026-02-01"
    },
    {
      "enabled": 15,
      "active": 15,
      "date": "2026-03-01"
    }
  ],
  "totalEnabled": 15,
  "totalActive": 15
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get quota consumption metrics by date

OpenAPI endpoint: POST /api/v2/adoption/quota-consumption/group-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (QuotaConsumptionByDateRequest, required): The request body for getting quota consumption metrics grouped by date.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **tools** (Array of BilledAiProduct): A list of AI tools to filter by.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/adoption/quota-consumption/group-by/date
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "tools": ["aia", "junie", "claude_agent"],
  "principalType": "user",
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/adoption/quota-consumption/group-by/date" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "tools": ["aia", "junie", "claude_agent"],
    "principalType": "user",
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

Quota consumption data for the specified date range.

- **application/json** (QuotaConsumptionCollection): A collection of quota consumption data points per period.
- **items** (Array of QuotaConsumptionData, required)
- **limit** (number double, required): The consumption of AI credits from the built-in quota.
- **topup** (number double, required): The consumption of AI credits from the top-up balance.
- **date** (string date, required): The date for the quota consumption metrics.
- **totalLimit** (number double, required): The total consumption of built-in quota limit for the entire date range.
- **totalTopup** (number double, required): The total consumption of top-up AI credits for the entire date range.

**200**

```JSON
{
  "items": [
    {
      "limit": 618.30,
      "topup": 673.09,
      "date": "2026-02-01"
    },
    {
      "limit": 561.88,
      "topup": 730.10,
      "date": "2026-03-01"
    }
  ],
  "totalLimit": 1180.18,
  "totalTopup": 1403.19
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get quota consumption metrics by date and tool

OpenAPI endpoint: POST /api/v2/adoption/quota-consumption/group-by/date-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (QuotaConsumptionByDateToolRequest, required): The request body for getting quota consumption metrics grouped by date and tool.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **tools** (Array of BilledAiProduct): A list of AI tools to filter by.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/adoption/quota-consumption/group-by/date-tool
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "tools": ["aia", "junie", "claude_agent"],
  "principalType": "user",
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/adoption/quota-consumption/group-by/date-tool" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "tools": ["aia", "junie", "claude_agent"],
    "principalType": "user",
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

Quota consumption data for the specified date range, grouped by date and tool.

- **application/json** (QuotaConsumptionByDateToolCollection): A collection of quota consumption data points per period, with a per-AI tool breakdown and per-AI tool totals for the entire date range.
- **items** (Array of QuotaConsumptionByDateToolDataPoint, required): Quota consumption data points for the specified date range.
- **date** (string date, required): The date for the quota consumption metrics.
- **tools** (Array of QuotaConsumptionByToolData, required): Quota consumption metrics per AI tool for the specified date.
- **tool** (BilledAiProduct, required): The AI tool the consumption data is reported for.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **consumption** (number double, required): The total quota consumption for the AI tool, including both the built-in quota limit and top-up AI credits.
- **totals** (Array of QuotaConsumptionByToolData, required): Total quota consumption per AI tool for the entire date range.
- **tool** (BilledAiProduct, required): The AI tool the consumption data is reported for.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **consumption** (number double, required): The total quota consumption for the AI tool, including both the built-in quota limit and top-up AI credits.

**200**

```JSON
{
  "items": [
    {
      "date": "2026-02-01",
      "tools": [
        {
          "tool": "aia",
          "consumption": 669.75
        },
        {
          "tool": "claude_agent",
          "consumption": 1538.91
        },
        {
          "tool": "junie",
          "consumption": 374.71
        }
      ]
    },
    {
      "date": "2026-03-01",
      "tools": [
        {
          "tool": "aia",
          "consumption": 723.18
        },
        {
          "tool": "claude_agent",
          "consumption": 1492.30
        },
        {
          "tool": "junie",
          "consumption": 401.05
        }
      ]
    }
  ],
  "totals": [
    {
      "tool": "aia",
      "consumption": 1392.93
    },
    {
      "tool": "claude_agent",
      "consumption": 3031.21
    },
    {
      "tool": "junie",
      "consumption": 775.76
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get limit hit metrics by date

OpenAPI endpoint: POST /api/v2/adoption/limit-hits/group-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (LimitHitsByDateRequest, required): The request body for getting limit hit metrics grouped by date.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/adoption/limit-hits/group-by/date
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-03-01",
  "toDate": "2026-04-20",
  "groupBy": "month",
  "principalType": "user"
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/adoption/limit-hits/group-by/date" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-03-01",
    "toDate": "2026-04-20",
    "groupBy": "month",
    "principalType": "user"
  }'
```

##### Responses

**Response 200**

Content type: application/json

The data about principals who hit their limits in the specified date range.

- **application/json** (LimitHitsCollection): A collection of data points showing the number of principals who hit their limits per period.
- **items** (Array of LimitHit, required)
- **count** (integer, required): The number of principals who hit their limit on the specified date.
- **date** (string date, required): The date for the limit hit data.
- **maximumDaily** (integer, required): The maximum number of unique principals who hit their limits during a single day in the specified date range.
- **totalHits** (integer, required): Total count of unique principals who hit their limits for the given time period.

**200**

```JSON
{
  "items": [
    {
      "count": 15,
      "date": "2026-03-01"
    },
    {
      "count": 15,
      "date": "2026-04-01"
    }
  ],
  "maximumDaily": 15,
  "totalHits": 15
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get limit hit metrics by principal and date

> **Note:**
> To learn more about types of entities that are classified as principals, see [Principal](ai-governance.html#principal).

OpenAPI endpoint: POST /api/v2/adoption/limit-hits/group-by/date-principal.cursor

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (PrincipalLimitHitsByCreditsUsedRequest, required): The request body for getting limit hits by principal and date.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **cursor** (LimitHitsByDatePrincipalCursor): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **date** (string date, required): The date of the last item from the previous page.
- **principalId** (string uuid, required): The principal ID of the last item from the previous page.
- **principalType** (PrincipalType, required): The principal type of the last item from the previous page.
- **user**
- **serviceAccount**
- **cursor** (string): The internal pagination state. Populated by the server when sorting by name, and must be passed back unchanged.
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.
- **sortOrder** (SortOrder): The sorting order for the results. The default sorting order is descending.
- **asc**
- **desc**
- **sortKey** (PrincipalSortKey): The key to sort the results by. The default value is date.
- **date**
- **principalName**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/adoption/limit-hits/group-by/date-principal.cursor
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-03-01",
  "toDate": "2026-04-20",
  "principalType": "user",
  "sortKey": "date",
  "sortOrder": "desc",
  "limit": 50
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/adoption/limit-hits/group-by/date-principal.cursor" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-03-01",
    "toDate": "2026-04-20",
    "principalType": "user",
    "sortKey": "date",
    "sortOrder": "desc",
    "limit": 50
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated limit hits per date per principal.

- **application/json** (LimitHitsByDatePrincipalCollection): A cursor-paginated collection of limit hits per date per principal.
- **nextCursor** (LimitHitsByDatePrincipalCursor): The anchor for retrieving the next page. If null, there are no more pages.
- **date** (string date, required): The date of the last item from the previous page.
- **principalId** (string uuid, required): The principal ID of the last item from the previous page.
- **principalType** (PrincipalType, required): The principal type of the last item from the previous page.
- **user**
- **serviceAccount**
- **cursor** (string): The internal pagination state. Populated by the server when sorting by name, and must be passed back unchanged.
- **items** (Array of LimitHitByDatePrincipal, required)
- **date** (string date, required): The date of the limit hit.
- **principal** (Principal, required): The information about the principal.
- **id** (string uuid, required): The unique identifier of the principal.
- **name** (string, required): The principal's display name.
- **typeDiscriminator** (Enum, required): The value identifying the principal subtype. Same values as PrincipalType.
- **user**
- **serviceAccount**

**200**

```JSON
{
  "items": [
    {
      "date": "2026-04-16",
      "principal": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "name": "John Doe",
        "typeDiscriminator": "user",
        "email": "john.doe@jetbrains.com"
      }
    },
    {
      "date": "2026-04-05",
      "principal": {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "name": "Jane Smith",
        "typeDiscriminator": "user",
        "email": "jane.smith@jetbrains.com"
      }
    }
  ],
  "nextCursor": {
    "date": "2026-04-05",
    "principalId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "principalType": "user",
    "cursor": null
  }
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Activity and impact

#### Get total AI activity and impact metrics

OpenAPI endpoint: POST /api/v2/effectiveness/totals

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (EffectivenessTotalsRequest, required): The request body for getting total AI activity and impact metrics.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **tools** (Array of ObservableAITool): A list of AI tools to filter by.
- **aia**
- **junie**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **pi**
- **copilot**
- **code_completion**
- **nes**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/effectiveness/totals
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "tools": ["aia", "junie", "claude_agent"],
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/effectiveness/totals" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "tools": ["aia", "junie", "claude_agent"],
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

Total AI activity and impact metrics for the specified date range.

- **application/json** (EffectivenessMetricsData): AI activity and impact metrics for a single bucket (a date period or the entire date range).
- **suggested** (integer, required): The number of suggested lines of code.
- **accepted** (integer, required): The number of accepted lines of code.
- **invocations** (integer, required): The number of AI tool invocations. For AI tools, invocations are measured as the number of messages sent through AI chat. For in-editor features, invocations are measured as the number of suggestions shown to the user.

**200**

```JSON
{
  "suggested": 152653,
  "accepted": 68422,
  "invocations": 19410
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get AI activity and impact metrics by date

OpenAPI endpoint: POST /api/v2/effectiveness/group-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (EffectivenessMetricsByDateRequest, required): The request body for getting AI activity and impact metrics grouped by date.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **tools** (Array of ObservableAITool): A list of AI tools to filter by.
- **aia**
- **junie**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **pi**
- **copilot**
- **code_completion**
- **nes**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/effectiveness/group-by/date
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "tools": ["aia", "junie", "claude_agent"],
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/effectiveness/group-by/date" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "tools": ["aia", "junie", "claude_agent"],
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

AI activity and impact metrics for the specified date range, grouped by date.

- **application/json** (EffectivenessMetricsCollection): A collection of AI activity and impact data points per period, with totals for the entire date range.
- **totals** (EffectivenessMetricsData, required): Total AI activity and impact metrics for the entire date range.
- **suggested** (integer, required): The number of suggested lines of code.
- **accepted** (integer, required): The number of accepted lines of code.
- **invocations** (integer, required): The number of AI tool invocations. For AI tools, invocations are measured as the number of messages sent through AI chat. For in-editor features, invocations are measured as the number of suggestions shown to the user.
- **items** (Array of EffectivenessMetricsDataPoint, required): AI activity and impact data points for the specified date range.
- **date** (string date, required): The date for the AI activity and impact metrics.
- **metrics** (EffectivenessMetricsData, required): AI activity and impact metrics for the specified date.
- **suggested** (integer, required): The number of suggested lines of code.
- **accepted** (integer, required): The number of accepted lines of code.
- **invocations** (integer, required): The number of AI tool invocations. For AI tools, invocations are measured as the number of messages sent through AI chat. For in-editor features, invocations are measured as the number of suggestions shown to the user.

**200**

```JSON
{
  "items": [
    {
      "date": "2026-02-01",
      "metrics": {
        "suggested": 9807,
        "accepted": 4094,
        "invocations": 1261
      }
    },
    {
      "date": "2026-03-01",
      "metrics": {
        "suggested": 142846,
        "accepted": 64328,
        "invocations": 18149
      }
    }
  ],
  "totals": {
    "suggested": 152653,
    "accepted": 68422,
    "invocations": 19410
  }
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get AI activity and impact metrics by date and feature

OpenAPI endpoint: POST /api/v2/effectiveness/group-by/date-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (EffectivenessMetricsByDateAndFeatureRequest, required): The request body for getting AI activity and impact metrics grouped by date and feature.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **tools** (Array of ObservableAITool): A list of AI tools to filter by.
- **aia**
- **junie**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **pi**
- **copilot**
- **code_completion**
- **nes**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/effectiveness/group-by/date-feature
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "tools": ["aia", "junie", "claude_agent"],
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/effectiveness/group-by/date-feature" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "tools": ["aia", "junie", "claude_agent"],
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

AI activity and impact metrics for the specified date range, grouped by date and feature.

- **application/json** (EffectivenessMetricsByFeatureCollection): A collection of AI activity and impact data points per period, with per-feature totals for the entire date range.
- **items** (Array of EffectivenessMetricsByFeatureDataPoint, required): AI activity and impact data points for the specified date range, broken down by feature.
- **date** (string date, required): The date for the AI activity and impact metrics.
- **tools** (Array of FeatureEffectivenessMetricsData, required): AI activity and impact metrics per feature for the specified date.
- **feature** (ObservableAITool, required): The AI tool the metrics are reported for.
- **aia**
- **junie**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **pi**
- **copilot**
- **code_completion**
- **nes**
- **metrics** (EffectivenessMetricsData, required): AI activity and impact metrics for the specified AI tool.
- **suggested** (integer, required): The number of suggested lines of code.
- **accepted** (integer, required): The number of accepted lines of code.
- **invocations** (integer, required): The number of AI tool invocations. For AI tools, invocations are measured as the number of messages sent through AI chat. For in-editor features, invocations are measured as the number of suggestions shown to the user.
- **totals** (Array of FeatureEffectivenessMetricsData, required): Total AI activity and impact metrics per feature for the entire date range.
- **feature** (ObservableAITool, required): The AI tool the metrics are reported for.
- **aia**
- **junie**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **pi**
- **copilot**
- **code_completion**
- **nes**
- **metrics** (EffectivenessMetricsData, required): AI activity and impact metrics for the specified AI tool.
- **suggested** (integer, required): The number of suggested lines of code.
- **accepted** (integer, required): The number of accepted lines of code.
- **invocations** (integer, required): The number of AI tool invocations. For AI tools, invocations are measured as the number of messages sent through AI chat. For in-editor features, invocations are measured as the number of suggestions shown to the user.

**200**

```JSON
{
  "items": [
    {
      "date": "2026-02-01",
      "tools": [
        {
          "feature": "aia",
          "metrics": {
            "suggested": 3434,
            "accepted": 1573,
            "invocations": 427
          }
        },
        {
          "feature": "claude_agent",
          "metrics": {
            "suggested": 3148,
            "accepted": 1137,
            "invocations": 419
          }
        },
        {
          "feature": "junie",
          "metrics": {
            "suggested": 3225,
            "accepted": 1384,
            "invocations": 415
          }
        }
      ]
    },
    {
      "date": "2026-03-01",
      "tools": [
        {
          "feature": "aia",
          "metrics": {
            "suggested": 49057,
            "accepted": 22248,
            "invocations": 6068
          }
        },
        {
          "feature": "claude_agent",
          "metrics": {
            "suggested": 46021,
            "accepted": 19984,
            "invocations": 6021
          }
        },
        {
          "feature": "junie",
          "metrics": {
            "suggested": 47768,
            "accepted": 22096,
            "invocations": 6060
          }
        }
      ]
    }
  ],
  "totals": [
    {
      "feature": "aia",
      "metrics": {
        "suggested": 52491,
        "accepted": 23821,
        "invocations": 6495
      }
    },
    {
      "feature": "claude_agent",
      "metrics": {
        "suggested": 49169,
        "accepted": 21121,
        "invocations": 6440
      }
    },
    {
      "feature": "junie",
      "metrics": {
        "suggested": 50993,
        "accepted": 23480,
        "invocations": 6475
      }
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Credit consumption

#### Get AI credit consumption by AI tool

OpenAPI endpoint: POST /api/v2/credits-usage/group-by/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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (CreditsUsageByToolRequest, required): The request body for getting AI credits consumption grouped by AI tool.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **tools** (Array of BilledAiProduct): A list of AI tools to filter by.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/credits-usage/group-by/tool
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "tools": ["aia", "junie", "claude_agent"],
  "principalType": "user",
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/credits-usage/group-by/tool" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "tools": ["aia", "junie", "claude_agent"],
    "principalType": "user",
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

AI credits consumption data grouped by AI tool.

- **application/json** (CreditsUsageByToolCollection): A collection of AI credits consumption data grouped by AI tool.
- **items** (Array of ToolUsageData, required)
- **tool** (BilledAiProduct, required): The AI tool the consumption data is reported for.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **tariff** (number double, required): The consumption of AI credits from the built-in quota.
- **topup** (number double, required): The consumption of AI credits from the top-up balance.

**200**

```JSON
{
  "items": [
    {
      "tool": "aia",
      "tariff": 288.47,
      "topup": 381.28
    },
    {
      "tool": "claude_agent",
      "tariff": 748.72,
      "topup": 790.19
    },
    {
      "tool": "junie",
      "tariff": 142.99,
      "topup": 231.72
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get AI credit consumption by principal with a per-tool breakdown

OpenAPI endpoint: POST /api/v2/credits-usage/group-by/date-principal-tool.cursor

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (CreditsUsageByDatePrincipalToolRequest, required): The request body for getting AI credits consumption per principal, with a per-AI tool breakdown.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **tools** (Array of BilledAiProduct): A list of AI tools to filter by.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**
- **cursor** (CreditsUsageByDatePrincipalToolCursor): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **orgServiceCursor** (string): The internal pagination state. Populated by the server when sorting by name, and must be passed back unchanged.
- **creditsUsed** (number double): The total AI credits used by the last item from the previous page.
- **principalId** (string uuid): The principal ID of the last item from the previous page.
- **principalType** (PrincipalType): The principal type of the last item from the previous page.
- **user**
- **serviceAccount**
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.
- **sortOrder** (SortOrder): The sorting order for the results. The default sorting order is ascending.
- **asc**
- **desc**
- **sortKey** (CreditsUsageByUserSortKey): The key to sort the results by. The default value is usage.
- **name**
- **usage**
- **NAME**
- **USAGE**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/credits-usage/group-by/date-principal-tool.cursor
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "tools": ["aia", "junie", "claude_agent"],
  "principalType": "user",
  "ides": ["idea"],
  "sortKey": "usage",
  "sortOrder": "desc",
  "limit": 50
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/credits-usage/group-by/date-principal-tool.cursor" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "tools": ["aia", "junie", "claude_agent"],
    "principalType": "user",
    "ides": ["idea"],
    "sortKey": "usage",
    "sortOrder": "desc",
    "limit": 50
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated AI credits consumption per principal, with a per-AI tool breakdown.

- **application/json** (CreditsUsageByDatePrincipalToolCollection): A cursor-paginated collection of AI credits consumption data per principal, with a per-AI tool breakdown.
- **nextCursor** (CreditsUsageByDatePrincipalToolCursor): The anchor for retrieving the next page. If null, there are no more pages.
- **orgServiceCursor** (string): The internal pagination state. Populated by the server when sorting by name, and must be passed back unchanged.
- **creditsUsed** (number double): The total AI credits used by the last item from the previous page.
- **principalId** (string uuid): The principal ID of the last item from the previous page.
- **principalType** (PrincipalType): The principal type of the last item from the previous page.
- **user**
- **serviceAccount**
- **items** (Array of CreditsUsageByDatePrincipalToolData, required)
- **principal** (Principal, required): The information about the principal.
- **id** (string uuid, required): The unique identifier of the principal.
- **name** (string, required): The principal's display name.
- **typeDiscriminator** (Enum, required): The value identifying the principal subtype. Same values as PrincipalType.
- **user**
- **serviceAccount**
- **items** (Array of ToolUsageData, required): AI credits consumption data per AI tool for the principal.
- **tool** (BilledAiProduct, required): The AI tool the consumption data is reported for.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **tariff** (number double, required): The consumption of AI credits from the built-in quota.
- **topup** (number double, required): The consumption of AI credits from the top-up balance.

**200**

```JSON
{
  "items": [
    {
      "principal": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "name": "Jane Smith",
        "typeDiscriminator": "user",
        "email": "jane.smith@jetbrains.com"
      },
      "items": [
        {
          "tool": "junie",
          "tariff": 15.75,
          "topup": 53.12
        },
        {
          "tool": "aia",
          "tariff": 44.08,
          "topup": 81.04
        },
        {
          "tool": "claude_agent",
          "tariff": 43.71,
          "topup": 59.61
        }
      ]
    },
    {
      "principal": {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "name": "John Doe",
        "typeDiscriminator": "user",
        "email": "john.doe@jetbrains.com"
      },
      "items": [
        {
          "tool": "aia",
          "tariff": 7.98,
          "topup": 19.48
        },
        {
          "tool": "claude_agent",
          "tariff": 67.66,
          "topup": 43.85
        },
        {
          "tool": "junie",
          "tariff": 66.30,
          "topup": 76.68
        }
      ]
    }
  ],
  "nextCursor": null
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Code provenance

#### Get code provenance metrics by date and feature

OpenAPI endpoint: POST /api/v2/code-provenance/group-by/date-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (CodeProvenanceByDateAndFeatureRequest, required): The request body for getting code provenance metrics grouped by date and feature.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **features** (Array of CodeProvenanceFeature): A list of code provenance features to filter by.
- **human**
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **copilot**
- **code_completion**
- **nes**
- **other**
- **uncategorized**
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/code-provenance/group-by/date-feature
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "features": ["human", "aia", "junie", "claude_agent"],
  "ides": ["idea"]
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/code-provenance/group-by/date-feature" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "features": ["human", "aia", "junie", "claude_agent"],
    "ides": ["idea"]
  }'
```

##### Responses

**Response 200**

Content type: application/json

Code provenance metrics for the specified date range, grouped by date and feature.

- **application/json** (CodeProvenanceByFeatureCollection): A collection of code provenance data points per period, with per-feature totals for the entire date range.
- **items** (Array of CodeProvenanceByFeatureDataPoint, required): Code provenance data points for the specified date range.
- **date** (string date, required): The date for the code provenance metrics.
- **features** (Array of CodeProvenanceFeatureData, required): Code provenance metrics per feature for the specified date.
- **feature** (CodeProvenanceFeature, required): The feature the metrics are reported for.
- **human**
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **copilot**
- **code_completion**
- **nes**
- **other**
- **uncategorized**
- **loc** (integer, required): The number of lines of code attributed to the feature.
- **timeSavedS** (integer, required): Time saved in seconds compared to writing code manually. Applies only to AI features.
- **totals** (Array of CodeProvenanceFeatureData, required): Total number of generated lines of code and time saved per feature for the entire date range.
- **feature** (CodeProvenanceFeature, required): The feature the metrics are reported for.
- **human**
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **copilot**
- **code_completion**
- **nes**
- **other**
- **uncategorized**
- **loc** (integer, required): The number of lines of code attributed to the feature.
- **timeSavedS** (integer, required): Time saved in seconds compared to writing code manually. Applies only to AI features.

**200**

```JSON
{
  "items": [
    {
      "date": "2026-02-01",
      "features": [
        {
          "feature": "human",
          "loc": 0,
          "timeSavedS": 0
        },
        {
          "feature": "junie",
          "loc": 0,
          "timeSavedS": 0
        },
        {
          "feature": "claude_agent",
          "loc": 0,
          "timeSavedS": 0
        },
        {
          "feature": "aia",
          "loc": 0,
          "timeSavedS": 0
        }
      ]
    },
    {
      "date": "2026-03-01",
      "features": [
        {
          "feature": "human",
          "loc": 204648,
          "timeSavedS": 0
        },
        {
          "feature": "junie",
          "loc": 102954,
          "timeSavedS": 261729
        },
        {
          "feature": "claude_agent",
          "loc": 103215,
          "timeSavedS": 246206
        },
        {
          "feature": "aia",
          "loc": 103729,
          "timeSavedS": 243284
        }
      ]
    }
  ],
  "totals": [
    {
      "feature": "human",
      "loc": 204648,
      "timeSavedS": 0
    },
    {
      "feature": "junie",
      "loc": 102954,
      "timeSavedS": 261729
    },
    {
      "feature": "claude_agent",
      "loc": 103215,
      "timeSavedS": 246206
    },
    {
      "feature": "aia",
      "loc": 103729,
      "timeSavedS": 243284
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Token usage

#### Get token usage metrics by date and provider

OpenAPI endpoint: POST /api/v2/token-usage/group-by/date-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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (TokenUsageByProviderRequest, required): The request body for getting token usage metrics grouped by date and provider.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **groupBy** (GroupBy): The time period to group by. The default value is day.
- **day**
- **week**
- **month**
- **year**
- **providers** (Array of AIProvider): A list of AI providers to filter by. Providers are distinguished by their type, which can be either jetbrains for JetBrains AI or byok for other AI providers. In the case of byok, the id field is required to specify the unique identifier of the provider.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/token-usage/group-by/date-provider
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "groupBy": "month",
  "providers": [{"type": "jetbrains"}],
  "principalType": "user"
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/token-usage/group-by/date-provider" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "groupBy": "month",
    "providers": [{"type": "jetbrains"}],
    "principalType": "user"
  }'
```

##### Responses

**Response 200**

Content type: application/json

Token usage data for the specified date range, grouped by date and provider.

- **application/json** (TokenUsageByProviderCollection): A collection of token usage data points per period, with per-provider totals for the entire date range.
- **items** (Array of TokenUsageByProviderDataPoint, required): Token usage data points for the specified date range.
- **date** (string date, required): The date for the token usage metrics.
- **providers** (Array of TokenUsageByProviderData, required): Token usage metrics per provider for the specified date.
- **provider** (AIProvider, required): The AI provider the token usage is reported for.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **tokens** (integer int64, required): The number of tokens used through the provider.
- **totals** (Array of TokenUsageByProviderTotal, required): Total token usage per provider for the entire date range.
- **provider** (AIProvider, required): The AI provider the token usage is reported for.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **tokens** (integer int64, required): The total number of tokens used through the provider.
- **trend** (number double | null, required): The trend in token usage compared to the immediately preceding time range of the same length, expressed as a percentage. It is null when there is no usage for the preceding period (the previous total was zero).

**200**

```JSON
{
  "items": [
    {
      "date": "2026-02-01",
      "providers": [
        {
          "provider": {
            "type": "jetbrains"
          },
          "tokens": 39572841
        }
      ]
    },
    {
      "date": "2026-03-01",
      "providers": [
        {
          "provider": {
            "type": "jetbrains"
          },
          "tokens": 42554342
        }
      ]
    }
  ],
  "totals": [
    {
      "provider": {
        "type": "jetbrains"
      },
      "tokens": 82127183,
      "trend": 7.53
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get token usage metrics by model

OpenAPI endpoint: POST /api/v2/token-usage/group-by/model.cursor

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (ModelTokenUsageRequest, required): The request body for getting token usage grouped by model.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes data for the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes data for the specified date.
- **providers** (Array of AIProvider): A list of AI providers to filter by. Providers are distinguished by their type, which can be either jetbrains for JetBrains AI or byok for other AI providers. In the case of byok, the id field is required to specify the unique identifier of the provider.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **cursor** (string | null): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.
- **sortOrder** (SortOrder): The sorting order for the results. The default sorting order is descending.
- **asc**
- **desc**
- **sortKey** (ModelTokenUsageSortKey): The key to sort the results by. The default value is totalTokens.
- **totalTokens**

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/token-usage/group-by/model.cursor
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "providers": [{"type": "jetbrains"}],
  "principalType": "user",
  "sortKey": "totalTokens",
  "sortOrder": "desc",
  "limit": 50
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/token-usage/group-by/model.cursor" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "providers": [{"type": "jetbrains"}],
    "principalType": "user",
    "sortKey": "totalTokens",
    "sortOrder": "desc",
    "limit": 50
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated token usage per model.

- **application/json** (ModelTokenUsageCollection): A cursor-paginated collection of token usage data per model.
- **nextCursor** (string | null): The pagination cursor for retrieving the next page. Pass it back unchanged in the cursor field of the next request. If null, there are no more pages.
- **items** (Array of ModelTokenUsageData, required)
- **model** (string, required): The model identifier.
- **provider** (AIProvider, required): The AI provider the model belongs to.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **tokens** (integer int64, required): The number of tokens used by the model.

**200**

```JSON
{
  "items": [
    {
      "model": "anthropic-claude-4-6-sonnet",
      "provider": {
        "type": "jetbrains"
      },
      "tokens": 28215071
    },
    {
      "model": "openai-gpt-5-5",
      "provider": {
        "type": "jetbrains"
      },
      "tokens": 18297355
    },
    {
      "model": "anthropic-claude-4-6-opus",
      "provider": {
        "type": "jetbrains"
      },
      "tokens": 15286203
    }
  ],
  "nextCursor": null
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Session Explorer

#### List AI agent sessions

OpenAPI endpoint: POST /api/v2/sessions/list.cursor

Returns a cursor-paginated list of AI agent sessions. Each item represents a single session and includes the session owner, timing, agent, IDE, AI provider, models, token usage, and spent AI credits. A session is included when its last activity falls within the specified date range.

Sorting is done by the `sortKey` (`lastActivity` by default). If two or more entries have equal values in the field used as `sortKey`, session ID is used for secondary sorting. This keeps pagination stable as it ensures exact positions of the entries in the ordering.

Filters for `principalFilter`, `principalType`, `tools`, `ides`, `models`, and `providers` are applied together (the API returns only records that match all criteria).

##### Request parameters

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (SessionsListRequest, required): The request body for listing AI agent sessions.
- **fromDate** (string date, required): The starting date to filter the data from. The returned result includes sessions that were last active on the specified date.
- **toDate** (string date, required): The end date to filter the data to. The returned result includes sessions that were last active on the specified date.
- **principalFilter** (PrincipalFilter): A container filter that includes sub-filters. The API returns results that match any of the provided conditions (sub-filters are combined using the OR logic).
- **principalIds** (PrincipalIds | null): A list of principal IDs to filter by.
- **groupIds** (GroupIds | null): A list of unique group identifiers whose members are included in the filter. This includes members of the group and its subgroups.
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **tools** (Array of BilledAiProduct): A list of agents (AI tools) to filter by. A session matches when it was run by any of the listed agents.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **ides** (Array of IdeType): A list of IDEs to filter by.
- **air**
- **air_cloud**
- **air_automations**
- **clion**
- **datagrip**
- **dataspell**
- **goland**
- **idea**
- **phpstorm**
- **pycharm**
- **rider**
- **rubymine**
- **rustrover**
- **webstorm**
- **wire**
- **unknown**
- **models** (Array of AIModel): A list of models to filter by. Each entry pairs a model identifier with the AI provider that served it.
- **id** (string, required): The model identifier.
- **provider** (AIProvider, required): The AI provider the model belongs to.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **providers** (Array of AIProvider): A list of AI providers to filter by. A session matches when it was served by any of the listed providers. Providers are distinguished by their type, which can be either jetbrains for JetBrains AI or byok for other AI providers. In the case of byok, the id field is required to specify the unique identifier of the provider.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.
- **sortKey** (SessionsSortKey): The key to sort the results by. The default value is lastActivity.
- **lastActivity**
- **creditsSpent**
- **totalTokens**
- **sortOrder** (SortOrder): The sorting order for the results.
- **asc**
- **desc**
- **cursor** (string | null): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/sessions/list.cursor
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "fromDate": "2026-02-01",
  "toDate": "2026-03-31",
  "tools": ["junie", "claude_agent"],
  "principalType": "user",
  "ides": ["idea"],
  "models": [{"id": "anthropic-claude-4-6-sonnet", "provider": {"type": "jetbrains"}}],
  "providers": [{"type": "jetbrains"}],
  "sortKey": "lastActivity",
  "sortOrder": "desc",
  "limit": 50
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/sessions/list.cursor" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "fromDate": "2026-02-01",
    "toDate": "2026-03-31",
    "tools": ["junie", "claude_agent"],
    "principalType": "user",
    "ides": ["idea"],
    "models": [{"id": "anthropic-claude-4-6-sonnet", "provider": {"type": "jetbrains"}}],
    "providers": [{"type": "jetbrains"}],
    "sortKey": "lastActivity",
    "sortOrder": "desc",
    "limit": 50
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated list of AI agent sessions.

- **application/json** (SessionsCollection): A cursor-paginated collection of AI agent sessions.
- **nextCursor** (string | null): The pagination cursor for retrieving the next page. Pass it back unchanged in the cursor field of the next request. If null, there are no more pages.
- **items** (Array of SessionData, required)
- **sessionId** (string, required): The unique identifier of the session.
- **owner** (Principal, required): The principal who started the session.
- **id** (string uuid, required): The unique identifier of the principal.
- **name** (string, required): The principal's display name.
- **typeDiscriminator** (Enum, required): The value identifying the principal subtype. Same values as PrincipalType.
- **user**
- **serviceAccount**
- **timestamp** (string date-time, required): The date and time when the session started.
- **lastActivity** (string date-time, required): The date and time of the last activity in the session.
- **durationSeconds** (integer int64, required): The duration of the session in seconds.
- **creditsSpent** (number double, required): The number of AI credits spent in the session. The value is 0 when AI credits do not apply, for example, when a bring-your-own-key (BYOK) provider is used.
- **totalTokens** (integer int64, required): The total number of tokens used in the session.
- **agent** (BilledAiProduct, required): The agent (AI tool) that ran the session.
- **junie**
- **aia**
- **claude_agent**
- **codex_agent**
- **gemini_agent**
- **opencode_agent**
- **pi**
- **copilot**
- **other**
- **ide** (string, required): The IDE the session ran in.
- **models** (Array of string, required): The models used during the session.
- **provider** (AIProvider, required): The AI provider that served the session.
- (JetbrainsProvider): The JetBrains AI provider.
- **type** (Enum, required): Always jetbrains for the JetBrains AI provider.
- **jetbrains**
- (BYOKProvider): A bring-your-own-key (BYOK) AI provider configured for the organization.
- **type** (Enum, required): Always byok for a third-party AI provider connected through the bring-your-own-key (BYOK) approach.
- **byok**
- **id** (string uuid, required): The unique identifier of the BYOK provider.

**200**

```JSON
{
  "items": [
    {
      "sessionId": "e1f2a3b4-c5d6-7890-efab-1234567890cd",
      "owner": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "name": "Jane Smith",
        "typeDiscriminator": "user",
        "email": "jane.smith@jetbrains.com"
      },
      "timestamp": "2026-03-30T09:14:22Z",
      "lastActivity": "2026-03-30T11:02:47Z",
      "durationSeconds": 6505,
      "creditsSpent": 48.63,
      "totalTokens": 1284502,
      "agent": "junie",
      "ide": "idea",
      "models": [
        "anthropic-claude-4-6-sonnet"
      ],
      "provider": {
        "type": "jetbrains"
      }
    },
    {
      "sessionId": "f2a3b4c5-d6e7-8901-fabc-234567890def",
      "owner": {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "name": "John Doe",
        "typeDiscriminator": "user",
        "email": "john.doe@jetbrains.com"
      },
      "timestamp": "2026-03-29T13:41:08Z",
      "lastActivity": "2026-03-29T14:26:55Z",
      "durationSeconds": 2747,
      "creditsSpent": 21.04,
      "totalTokens": 612938,
      "agent": "claude_agent",
      "ide": "idea",
      "models": [
        "anthropic-claude-4-6-sonnet",
        "anthropic-claude-4-6-opus"
      ],
      "provider": {
        "type": "jetbrains"
      }
    }
  ],
  "nextCursor": null
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Principals

#### Search principals

> **Note:**
> Principals include users, service accounts, and groups. To learn more, see [Principal](ai-governance.html#principal). This endpoint searches only users and service accounts. To look up groups, use the [Groups](#groups-v2) endpoints.

OpenAPI endpoint: POST /api/v2/principals/search

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (SearchPrincipalsRequest, required): The request body for searching principals. All filters are applied together (the API returns only records that match all criteria).
- **principalType** (PrincipalType): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **principalIds** (SearchPrincipalIds | null): A list of principal IDs to filter by using an exact match. Can contain a maximum of 100 entries. A larger list is rejected with a 400 Bad Request error.
- **includeDeleted** (boolean): Whether to include soft-deleted principals. The default value is false.
- **nameContains** (string | null): A case-insensitive substring to match against the principal name.
- **nameOrEmailContains** (string | null): A case-insensitive substring to match against the principal name or email (for users).
- **sortKey** (PrincipalListSortKey): The key to sort the results by. The default value is name.
- **name**
- **id**
- **sortOrder** (SortOrder): The sorting order for the results. The default sorting order is ascending.
- **asc**
- **desc**
- **cursor** (string | null): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/principals/search
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "principalType": "user",
  "nameOrEmailContains": "smith",
  "sortKey": "name",
  "sortOrder": "asc",
  "limit": 50
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/principals/search" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "principalType": "user",
    "nameOrEmailContains": "smith",
    "sortKey": "name",
    "sortOrder": "asc",
    "limit": 50
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated list of principals that you are authorized to view.

- **application/json** (SearchPrincipalsCollection): A cursor-paginated collection of principals.
- **nextCursor** (string | null): The pagination cursor for retrieving the next page. Pass it back unchanged in the cursor field of the next request. If null, there are no more pages.
- **items** (Array of OrgPrincipalDto, required)
- **principalType** (PrincipalType, required): The type of principal. Available values:

user

serviceAccount
- **user**
- **serviceAccount**
- **user** (UserDto): A principal representing a user.
- **id** (string uuid, required): The unique identifier of the user.
- **orgId** (string uuid, required): The unique identifier of the organization the user belongs to.
- **deleted** (boolean, required): Whether the user is soft-deleted.
- **type** (UserDtoType, required): The type of user. Available values:

member

jetbrains_user: An internal JetBrains user.
- **member**
- **jetbrains_user**
- **name** (string, required): The user's display name.
- **email** (string): The user's email address.
- **jbaAccountId** (integer int64): The user's JetBrains Account ID.
- **jbaLogin** (string): The user's JetBrains Account login.
- **serviceAccount** (OrgServiceAccountDto): A principal representing a service account.
- **id** (string uuid, required): The unique identifier of the service account.
- **orgId** (string uuid, required): The unique identifier of the organization the service account belongs to.
- **type** (OrgServiceAccountDtoType, required): The management type of the service account. Available values:

USER_MANAGED: Managed by a human user.

SERVICE_MANAGED: Managed by a service that integrates with JetBrains Central.

ORG_SERVICE_ACCOUNT_MANAGED: Managed by another service account.
- **USER_MANAGED**
- **SERVICE_MANAGED**
- **ORG_SERVICE_ACCOUNT_MANAGED**
- **deleted** (boolean, required): Whether the service account is soft-deleted.
- **name** (string, required): The service account's display name.
- **description** (string, required): The service account's description.
- **clientId** (string, required): The client ID of the service account.
- **createdAt** (string date-time, required): The date and time when the service account was created.
- **creatorType** (OrgServiceAccountCreatorTypeDto): The type of entity that created the service account. Available values:

USER: Created by a human user.

SERVICE: Created by a service that integrates with JetBrains Central.

ORG_SERVICE_ACCOUNT: Created by another service account.
- **USER**
- **SERVICE**
- **ORG_SERVICE_ACCOUNT**
- **creatorId** (string | null): The unique identifier of the entity that created the service account.

**200**

```JSON
{
  "items": [
    {
      "principalType": "user",
      "user": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
        "deleted": false,
        "type": "member",
        "name": "Jane Smith",
        "email": "jane.smith@jetbrains.com",
        "jbaAccountId": 12345678,
        "jbaLogin": "jane.smith@jetbrains.com"
      },
      "serviceAccount": null
    },
    {
      "principalType": "user",
      "user": {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
        "deleted": false,
        "type": "member",
        "name": "John Smith",
        "email": "john.smith@jetbrains.com",
        "jbaAccountId": 23456789,
        "jbaLogin": "john.smith@jetbrains.com"
      },
      "serviceAccount": null
    }
  ],
  "nextCursor": null
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

### Groups

#### List groups

OpenAPI endpoint: POST /api/v2/groups/list

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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (ListGroupsRequest, required): The request body for listing groups. Results are always returned in ascending order.
- **sortKey** (GroupSortKey): The key to sort the results by. The default value is name.
- **name**
- **id**
- **cursor** (string | null): The pagination cursor. Use the nextCursor value from the previous response. When nextCursor is null, there are no more pages.
- **limit** (integer): The number of items to show. The default value is 50. The minimum is 1 and the maximum is 1000.
- **withMembersCount** (boolean): Whether to include member counts for each group. The default value is false.
- **withParentGroups** (boolean): Whether to include the parent-group chain for each group. The default value is false.
- **withHasChildren** (boolean): Whether to include whether each group has child groups. The default value is false.

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/groups/list
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "sortKey": "name",
  "limit": 50,
  "withMembersCount": true,
  "withParentGroups": true,
  "withHasChildren": true
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/groups/list" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "sortKey": "name",
    "limit": 50,
    "withMembersCount": true,
    "withParentGroups": true,
    "withHasChildren": true
  }'
```

##### Responses

**Response 200**

Content type: application/json

Cursor-paginated list of groups that you are authorized to view.

- **application/json** (ListGroupsCollection): A cursor-paginated collection of groups.
- **nextCursor** (string | null): The pagination cursor for retrieving the next page. Pass it back unchanged in the cursor field of the next request. If null, there are no more pages.
- **items** (Array of GroupExtendedDto, required)
- **id** (string uuid, required): The unique identifier of the group.
- **orgId** (string uuid, required): The unique identifier of the organization the group belongs to.
- **parentId** (string uuid | null): The unique identifier of the parent group, or null if the group has no parent.
- **type** (GroupDtoType, required): The type of group. Available values:

local: A group created and managed entirely in JetBrains Central Console.

managed: A group that is linked to and synchronized from an external identity provider.
- **local**
- **managed**
- **name** (string, required): The group's display name.
- **description** (string, required): The group's description.
- **membersCount** (GroupMembersCountDto): The member counts for the group. Included only when withMembersCount is true.
- **directMembersCount** (integer int64, required): The number of direct members of the group.
- **transitiveMembersCount** (integer int64, required): The number of members of the group, including members of its sub-groups.
- **parentGroups** (Array of GroupDto | null): The parent-group chain for the group. Included only when withParentGroups is true.
- **id** (string uuid, required): The unique identifier of the group.
- **orgId** (string uuid, required): The unique identifier of the organization the group belongs to.
- **parentId** (string uuid | null): The unique identifier of the parent group, or null if the group has no parent.
- **type** (GroupDtoType, required): The type of group. Available values:

local: A group created and managed entirely in JetBrains Central Console.

managed: A group that is linked to and synchronized from an external identity provider.
- **local**
- **managed**
- **name** (string, required): The group's display name.
- **description** (string, required): The group's description.
- **hasChildren** (boolean | null): Whether the group has child groups. Included only when withHasChildren is true.

**200**

```JSON
{
  "items": [
    {
      "id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
      "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
      "type": "local",
      "name": "Backend Engineers",
      "description": "Backend engineering team",
      "parentId": null,
      "membersCount": {
        "directMembersCount": 12,
        "transitiveMembersCount": 18
      },
      "parentGroups": [],
      "hasChildren": true
    },
    {
      "id": "d2e3f4a5-b6c7-8901-defa-234567890abc",
      "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
      "type": "local",
      "name": "Backend Engineers - Payments",
      "description": "Payments squad",
      "parentId": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
      "membersCount": {
        "directMembersCount": 6,
        "transitiveMembersCount": 6
      },
      "parentGroups": [
        {
          "id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
          "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
          "type": "local",
          "name": "Backend Engineers",
          "description": "Backend engineering team",
          "parentId": null
        }
      ],
      "hasChildren": false
    }
  ],
  "nextCursor": null
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get groups by IDs

OpenAPI endpoint: POST /api/v2/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

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (GetGroupsByIdsRequest, required): The request body for getting groups by their IDs.
- **groupIds** (Array of string uuid, required): A list of group IDs to fetch. Can contain a maximum of 100 entries. IDs of groups that you are not authorized to view are excluded from the result.
- **withMembersCount** (boolean): Whether to include member counts for each group. The default value is false.
- **withParentGroups** (boolean): Whether to include the parent-group chain for each group. The default value is false.
- **withHasChildren** (boolean): Whether to include whether each group has child groups. The default value is false.

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/groups/by-ids
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "groupIds": [
    "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
    "d2e3f4a5-b6c7-8901-defa-234567890abc"
  ],
  "withMembersCount": true,
  "withParentGroups": true,
  "withHasChildren": true
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/groups/by-ids" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "groupIds": [
      "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
      "d2e3f4a5-b6c7-8901-defa-234567890abc"
    ],
    "withMembersCount": true,
    "withParentGroups": true,
    "withHasChildren": true
  }'
```

##### Responses

**Response 200**

Content type: application/json

The requested groups that you are authorized to view.

- **application/json** (GroupsByIdsCollection): A collection of groups returned by their IDs.
- **items** (Array of GroupExtendedDto, required)
- **id** (string uuid, required): The unique identifier of the group.
- **orgId** (string uuid, required): The unique identifier of the organization the group belongs to.
- **parentId** (string uuid | null): The unique identifier of the parent group, or null if the group has no parent.
- **type** (GroupDtoType, required): The type of group. Available values:

local: A group created and managed entirely in JetBrains Central Console.

managed: A group that is linked to and synchronized from an external identity provider.
- **local**
- **managed**
- **name** (string, required): The group's display name.
- **description** (string, required): The group's description.
- **membersCount** (GroupMembersCountDto): The member counts for the group. Included only when withMembersCount is true.
- **directMembersCount** (integer int64, required): The number of direct members of the group.
- **transitiveMembersCount** (integer int64, required): The number of members of the group, including members of its sub-groups.
- **parentGroups** (Array of GroupDto | null): The parent-group chain for the group. Included only when withParentGroups is true.
- **id** (string uuid, required): The unique identifier of the group.
- **orgId** (string uuid, required): The unique identifier of the organization the group belongs to.
- **parentId** (string uuid | null): The unique identifier of the parent group, or null if the group has no parent.
- **type** (GroupDtoType, required): The type of group. Available values:

local: A group created and managed entirely in JetBrains Central Console.

managed: A group that is linked to and synchronized from an external identity provider.
- **local**
- **managed**
- **name** (string, required): The group's display name.
- **description** (string, required): The group's description.
- **hasChildren** (boolean | null): Whether the group has child groups. Included only when withHasChildren is true.

**200**

```JSON
{
  "items": [
    {
      "id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
      "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
      "type": "local",
      "name": "Backend Engineers",
      "description": "Backend engineering team",
      "parentId": null,
      "membersCount": {
        "directMembersCount": 12,
        "transitiveMembersCount": 18
      },
      "parentGroups": [],
      "hasChildren": true
    },
    {
      "id": "d2e3f4a5-b6c7-8901-defa-234567890abc",
      "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
      "type": "local",
      "name": "Backend Engineers - Payments",
      "description": "Payments squad",
      "parentId": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
      "membersCount": {
        "directMembersCount": 6,
        "transitiveMembersCount": 6
      },
      "parentGroups": [
        {
          "id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
          "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
          "type": "local",
          "name": "Backend Engineers",
          "description": "Backend engineering team",
          "parentId": null
        }
      ],
      "hasChildren": false
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

#### Get groups by user IDs

OpenAPI endpoint: POST /api/v2/groups/by-user

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.

##### Request parameters

**Request**

Security

- **HTTP** (Bearer): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Header

- **Authorization** (string, required): Bearer token used for authentication. Provide as Bearer <ACCESS_TOKEN> in the Authorization header.

Body

Content type: application/json

- **application/json** (GetGroupsByUserIdsRequest, required): The request body for getting the groups that the specified users belong to.
- **userIds** (Array of string uuid, required): A list of user IDs whose groups to fetch. Can contain a maximum of 100 entries.
- **transitive** (boolean): Whether to include groups inherited through sub-group membership. The default value is false.

**HTTP**

```HTTP_REQUEST
POST https://api.jetbrains.cloud/metrics/api/v2/groups/by-user
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>

{
  "userIds": [
    "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  ],
  "transitive": true
}
```

**cURL**

```BASH
curl -X POST "https://api.jetbrains.cloud/metrics/api/v2/groups/by-user" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "userIds": [
      "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
    ],
    "transitive": true
  }'
```

##### Responses

**Response 200**

Content type: application/json

Per-user group memberships that you are authorized to view.

- **application/json** (GroupsByUserIdsCollection): A collection of per-user group memberships.
- **items** (Array of OrgUserGroupsDto, required)
- **userId** (string uuid, required): The unique identifier of the user.
- **groups** (Array of GroupDto, required): The groups the user belongs to, narrowed to the groups you are authorized to view.
- **id** (string uuid, required): The unique identifier of the group.
- **orgId** (string uuid, required): The unique identifier of the organization the group belongs to.
- **parentId** (string uuid | null): The unique identifier of the parent group, or null if the group has no parent.
- **type** (GroupDtoType, required): The type of group. Available values:

local: A group created and managed entirely in JetBrains Central Console.

managed: A group that is linked to and synchronized from an external identity provider.
- **local**
- **managed**
- **name** (string, required): The group's display name.
- **description** (string, required): The group's description.

**200**

```JSON
{
  "items": [
    {
      "userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "groups": [
        {
          "id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
          "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
          "type": "local",
          "name": "Backend Engineers",
          "description": "Backend engineering team",
          "parentId": null
        },
        {
          "id": "d2e3f4a5-b6c7-8901-defa-234567890abc",
          "orgId": "0fedcba9-8765-4321-fedc-ba9876543210",
          "type": "local",
          "name": "Backend Engineers - Payments",
          "description": "Payments squad",
          "parentId": "c1d2e3f4-a5b6-7890-cdef-1234567890ab"
        }
      ]
    }
  ]
}
```

**Response 401**

Unauthorized. Missing or invalid authentication token.

**Response 403**

Forbidden. You are not authorized to perform this action.

**Response 400**

Bad Request. Invalid request body.

