> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Code Metrics & Tracking

> AI coding stats, rankings, repos, extensions, commit attribution, and detail/export APIs.

## About this document

**AI code metrics** (aggregates) and **AI code tracking** (detail and CSV export). Pagination differs by section. Complete **[Get API Key](/account/teams/openapi/get-api-key)** first, then read **[Conventions](/account/teams/openapi/conventions)**.

### Requirements

* Valid API key (`Authorization: Bearer <api_key>`) for the organization.

## Overview

The AI Code Metrics API provides organization-level AI-assisted coding statistics, including code stats overview, daily trends, member rankings, repository lists, and file extension statistics.

### Key features

* **Stats overview**: Total AI contribution and share in committed code

* **Daily trends**: Daily AI code share, Agent code by language, Tab completion acceptance rate

* **Member ranking**: Rank members by AI code contribution

* **Repository list**: List repositories with AI code activity

* **File extensions**: AI code metrics by file type

* **Commit details**: Get commit-level AI code attribution details (file-level line range annotations)

***

## Common query parameters

The following parameters apply to all AI Code endpoints (required status varies by endpoint):

| Parameter             | Type   | Description                                                        |
| --------------------- | ------ | ------------------------------------------------------------------ |
| `start_date`          | string | Start time; supports RFC 3339 format or Unix millisecond timestamp |
| `end_date`            | string | End time; supports RFC 3339 format or Unix millisecond timestamp   |
| `repo_name`           | string | Filter by repository name                                          |
| `primary_branch_only` | string | Set to `true` to count primary branch only                         |
| `user_id`             | string | Filter by user ID                                                  |
| `file_extensions`     | string | Filter by file extension, comma-separated (e.g., `.go,.ts`)        |

***

## API list

### 1. Get AI code stats overview

`GET /v1/organizations/{organization_id}/ai-code/stats/overview`

Retrieve overall AI code statistics for the organization.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; specifically:

| Parameter    | Required | Description |
| ------------ | -------- | ----------- |
| `start_date` | Yes      | Start time  |
| `end_date`   | Yes      | End time    |

> Both `start_date` and `end_date` are required; the time range must not exceed 90 days.

#### Success response (200 OK)

```json theme={null}
{
  "committedTotalLinesEdit": 50000,
  "committedAiLinesEdit": 15000,
  "acceptedLinesEdit": 18000,
  "aiShareRate": 30.0,
  "agentEditCount": 1200,
  "tabCompletionCount": 5600,
  "messageCount": 3400
}
```

#### Response fields

| Field                     | Type    | Description                                         |
| ------------------------- | ------- | --------------------------------------------------- |
| `committedTotalLinesEdit` | int64   | Total committed lines edited (added + deleted)      |
| `committedAiLinesEdit`    | int64   | AI-edited lines in committed code (added + deleted) |
| `acceptedLinesEdit`       | int64   | Accepted AI-edited lines (added + deleted)          |
| `aiShareRate`             | float64 | AI code share (percentage)                          |
| `agentEditCount`          | int64   | Agent edit count                                    |
| `tabCompletionCount`      | int64   | Tab completion count                                |
| `messageCount`            | int64   | Chat message count                                  |

***

### 2. Get AI code daily trend

`GET /v1/organizations/{organization_id}/ai-code/stats/daily-trend`

Retrieve daily trend data for AI code, including three datasets: AI code share trend, language distribution trend, and Tab completion acceptance rate trend.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; specifically:

| Parameter    | Required | Description |
| ------------ | -------- | ----------- |
| `start_date` | Yes      | Start time  |
| `end_date`   | Yes      | End time    |

> Both `start_date` and `end_date` are required; the time range must not exceed 90 days.

#### Success response (200 OK)

```json theme={null}
{
  "items": [
    {
      "date": "2025-06-01T00:00:00Z",
      "aiLinesAdded": 500,
      "otherLinesAdded": 1500,
      "aiShareRate": 25.0,
      "commitCount": 30
    }
  ],
  "extItems": [
    {
      "date": "2025-06-01T00:00:00Z",
      "fileExtension": ".go",
      "totalLinesAdded": 800,
      "aiLinesAdded": 300
    }
  ],
  "nextItems": [
    {
      "date": "2025-06-01T00:00:00Z",
      "nextSuggestedCount": 200,
      "nextAcceptedCount": 120,
      "nextAcceptRate": 60.0
    }
  ]
}
```

#### Response fields

**items\[]** — AI code share trend (Chart 1)

| Field             | Type    | Description                |
| ----------------- | ------- | -------------------------- |
| `date`            | string  | Date (ISO 8601)            |
| `aiLinesAdded`    | int64   | AI lines added             |
| `otherLinesAdded` | int64   | Non-AI lines added         |
| `aiShareRate`     | float64 | AI code share (percentage) |
| `commitCount`     | int64   | Commit count               |

**extItems\[]** — Agent code by language trend (Chart 2)

| Field             | Type   | Description       |
| ----------------- | ------ | ----------------- |
| `date`            | string | Date (ISO 8601)   |
| `fileExtension`   | string | File extension    |
| `totalLinesAdded` | int64  | Total lines added |
| `aiLinesAdded`    | int64  | AI lines added    |

**nextItems\[]** — Tab completion acceptance rate trend (Chart 3)

| Field                | Type    | Description                  |
| -------------------- | ------- | ---------------------------- |
| `date`               | string  | Date (ISO 8601)              |
| `nextSuggestedCount` | int64   | Suggestion count             |
| `nextAcceptedCount`  | int64   | Acceptance count             |
| `nextAcceptRate`     | float64 | Acceptance rate (percentage) |

***

### 3. Get member AI code ranking

`GET /v1/organizations/{organization_id}/ai-code/stats/member-ranking`

Retrieve organization member ranking by AI code contribution.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; specifically:

| Parameter    | Required | Description |
| ------------ | -------- | ----------- |
| `start_date` | Yes      | Start time  |
| `end_date`   | Yes      | End time    |

> Both `start_date` and `end_date` are required; the time range must not exceed 90 days.

Additionally supported:

| Parameter | Type    | Required | Default | Description                         |
| --------- | ------- | -------- | ------- | ----------------------------------- |
| `limit`   | integer | No       | 10      | Maximum number of members to return |

#### Success response (200 OK)

```json theme={null}
{
  "items": [
    {
      "userId": "user_abc123",
      "email": "alice@example.com",
      "displayName": "Alice",
      "totalLinesAdded": 5000,
      "aiLinesAdded": 2000,
      "aiShareRate": 40.0,
      "commitCount": 50
    }
  ]
}
```

#### Response fields

| Field                     | Type    | Description                 |
| ------------------------- | ------- | --------------------------- |
| `items`                   | array   | Member ranking list         |
| `items[].userId`          | string  | User ID                     |
| `items[].email`           | string  | Member email (may be empty) |
| `items[].displayName`     | string  | Display name (may be empty) |
| `items[].totalLinesAdded` | int64   | Total lines added           |
| `items[].aiLinesAdded`    | int64   | AI lines added              |
| `items[].aiShareRate`     | float64 | AI code share (percentage)  |
| `items[].commitCount`     | int64   | Commit count                |

***

### 4. List repositories

`GET /v1/organizations/{organization_id}/ai-code/repos`

List repositories in the organization with AI code activity.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

| Parameter    | Type    | Required | Default | Description                   |
| ------------ | ------- | -------- | ------- | ----------------------------- |
| `start_date` | string  | No       | —       | Start time                    |
| `end_date`   | string  | No       | —       | End time                      |
| `query`      | string  | No       | —       | Search by repository name     |
| `page`       | integer | No       | 1       | Page number (starting from 1) |
| `per_page`   | integer | No       | 30      | Items per page, max 100       |

#### Success response (200 OK)

```json theme={null}
{
  "repos": [
    {
      "repoName": "my-project",
      "commitCount": 120,
      "totalLinesAdded": 8000
    }
  ],
  "totalCount": 42,
  "page": 1,
  "perPage": 30
}
```

#### Response fields

| Field                     | Type   | Description            |
| ------------------------- | ------ | ---------------------- |
| `repos`                   | array  | Repository list        |
| `repos[].repoName`        | string | Repository name        |
| `repos[].commitCount`     | int64  | Commit count           |
| `repos[].totalLinesAdded` | int64  | Total lines added      |
| `totalCount`              | int32  | Total repository count |
| `page`                    | int32  | Current page number    |
| `perPage`                 | int32  | Items per page         |

***

### 5. List file extensions

`GET /v1/organizations/{organization_id}/ai-code/file-extensions`

List file extension statistics for AI code activity in the organization.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

| Parameter    | Type   | Required | Description |
| ------------ | ------ | -------- | ----------- |
| `start_date` | string | No       | Start time  |
| `end_date`   | string | No       | End time    |

#### Success response (200 OK)

```json theme={null}
{
  "fileExtensions": [
    {
      "extension": ".go",
      "changeCount": 500,
      "totalLinesAdded": 12000,
      "aiShareRate": 35.5
    }
  ]
}
```

#### Response fields

| Field                              | Type    | Description                |
| ---------------------------------- | ------- | -------------------------- |
| `fileExtensions`                   | array   | File extension list        |
| `fileExtensions[].extension`       | string  | File extension             |
| `fileExtensions[].changeCount`     | int64   | Change count               |
| `fileExtensions[].totalLinesAdded` | int64   | Total lines added          |
| `fileExtensions[].aiShareRate`     | float64 | AI code share (percentage) |

***

### 6. Get commit AI attribution details

`POST /v1/organizations/{organization_id}/ai-code-tracking/commits/detail`

Batch retrieve commit-level AI code attribution details, including file-level line range annotations.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Request body (JSON)

| Field          | Type      | Required | Description                      |
| -------------- | --------- | -------- | -------------------------------- |
| `commitHashes` | string\[] | Yes      | List of commit hashes (max 50)   |
| `branch`       | string    | No       | Branch name (to scope the query) |

#### Request example

```json theme={null}
{
  "commitHashes": ["abc123def456", "789ghi012jkl"],
  "branch": "main"
}
```

#### Success response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "commits": [
      {
        "commitHash": "abc123def456",
        "rangeAnnotations": [
          {
            "filePath": "src/main.go",
            "groups": [
              {
                "conversationId": "session-001",
                "source": "AGENT",
                "productType": "ide",
                "type": "added",
                "ranges": [
                  { "start": 47, "end": 48 },
                  { "start": 55, "end": 60 }
                ]
              }
            ]
          }
        ]
      },
      {
        "commitHash": "789ghi012jkl",

        "rangeAnnotations": [ ]

      }
    ]
  }
}
```

#### Response fields

| Field                                                       | Type    | Description                                    |
| ----------------------------------------------------------- | ------- | ---------------------------------------------- |
| `success`                                                   | boolean | Whether the request succeeded                  |
| `data.commits`                                              | array   | Commit details list (preserves request order)  |
| `data.commits[].commitHash`                                 | string  | Commit hash                                    |
| `data.commits[].rangeAnnotations`                           | array   | File-level AI attribution annotations          |
| `data.commits[].rangeAnnotations[].filePath`                | string  | File path                                      |
| `data.commits[].rangeAnnotations[].groups`                  | array   | AI session contribution groups                 |
| `data.commits[].rangeAnnotations[].groups[].conversationId` | string  | AI session ID                                  |
| `data.commits[].rangeAnnotations[].groups[].source`         | string  | Source: `AGENT`, `NEXT`, `QUEST`, `INLINECHAT` |
| `data.commits[].rangeAnnotations[].groups[].productType`    | string  | Product type (lowercase, e.g., `ide`)          |
| `data.commits[].rangeAnnotations[].groups[].type`           | string  | Type: `added` (added), `deleted` (deleted)     |
| `data.commits[].rangeAnnotations[].groups[].ranges`         | array   | Line range list                                |
| `data.commits[].rangeAnnotations[].groups[].ranges[].start` | int32   | Start line number                              |
| `data.commits[].rangeAnnotations[].groups[].ranges[].end`   | int32   | End line number                                |

***

## Usage examples

### Get stats overview

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/stats/overview?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z" \
  -H "Authorization: Bearer <api_key>"
```

### Get daily trend (specific repo, primary branch)

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/stats/daily-trend?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z&repo_name=my-project&primary_branch_only=true" \
  -H "Authorization: Bearer <api_key>"
```

### Get member ranking (top 20)

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/stats/member-ranking?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z&limit=20" \
  -H "Authorization: Bearer <api_key>"
```

### Search repositories

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/repos?query=my-project" \
  -H "Authorization: Bearer <api_key>"
```

### Get file extension statistics

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/file-extensions?start_date=2025-06-01T00:00:00Z" \
  -H "Authorization: Bearer <api_key>"
```

### Get commit AI attribution details

```bash theme={null}
curl -X POST "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/commits/detail" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"commitHashes": ["abc123def456", "789ghi012jkl"], "branch": "main"}'
```

***

## Error codes

| Error code      | HTTP status | Description                                                                                                                          |
| --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `BadRequest`    | 400         | Invalid request parameters (e.g., missing `start_date` / `end_date`, time range exceeds 90 days, `commitHashes` empty or exceeds 50) |
| `Unauthorized`  | 401         | API key missing or invalid                                                                                                           |
| `Forbidden`     | 403         | No permission to access this organization                                                                                            |
| `InternalError` | 500         | Internal server error                                                                                                                |

Error response shape: see **Error responses** in [Conventions](/account/teams/openapi/conventions).

***

## AI Code Tracking API

Beyond **AI code metrics** (aggregate stats), this section provides **commit / change**-level detail queries and **CSV export**. Authentication is the same: `Authorization: Bearer <api_key>`.

Before use, confirm that the organization has enabled the **AI Code Data Analysis** capability consistent with the console; if not enabled or unauthorized, the API may return 403 or similar errors—refer to the actual response. Fields and enums are based on the **live API and OpenAPI definition**; this document is for reference only.

## Tracking capabilities

The AI Code Tracking API provides commit-level and change-level per-record detail queries and CSV export capabilities, supplementing the **AI Code Metrics** (aggregate stats) above.

### Two-layer data model

| Layer      | Meaning                   | Source                                          | Available filter dimensions |
| ---------- | ------------------------- | ----------------------------------------------- | --------------------------- |
| **Commit** | Git commit                | Code repository (pushed to remote)              | Time, user, repository      |
| **Change** | AI code edit event in IDE | Reported from IDE client (not yet a Git commit) | Time, user, source          |

> Changes are **IDE events not yet committed to Git**, so they do not have `repoName` / `branchName` dimensions.

### Product × scenario breakdown (commit level)

Each commit record contains **12 pairs** of `linesAdded / linesDeleted` columns, broken down by "product × scenario":

| Field prefix    | Product          | Scenario                      |
| --------------- | ---------------- | ----------------------------- |
| `ideNext`       | IDE (VS Code)    | Tab completion (next)         |
| `pluginNext`    | JetBrains Plugin | Tab completion (next)         |
| `ideAgent`      | IDE (VS Code)    | Agent                         |
| `pluginAgent`   | JetBrains Plugin | Agent                         |
| `cliAgent`      | CLI              | Agent                         |
| `ideQuest`      | IDE (VS Code)    | Quest                         |
| `ideInlineChat` | IDE (VS Code)    | Inline Chat                   |
| `jbInlineChat`  | JetBrains Plugin | Inline Chat                   |
| `nonAi`         | —                | Non-AI lines (unattributable) |

### Key features

* **Commit detail query**: List commit-level AI code statistics (with product × scenario breakdown)

* **Commit CSV export**: Stream export all commit data

* **Change detail query**: List IDE AI code edit events (filterable by `source`)

* **Change CSV export**: Stream export all change data

* **User email**: Lists and exports populate `userEmail` where available

* **Filter by email**: Supports `userEmail` query parameter to locate users

### Pagination

The Tracking API uses **offset-based pagination** (`page` + `pageSize`), unlike the cursor-based pagination used by other endpoints. Responses include `totalItems` / `totalPages` for pagination display.

***

## Common query parameters

The following parameters apply to all Tracking endpoints:

| Parameter   | Type    | Required | Default      | Description                                                                                                                                                                                   |
| ----------- | ------- | -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `startDate` | string  | No       | —            | Start time; supports RFC 3339 format or Unix millisecond timestamp. When omitted, the server constrains the queryable range by product policy (e.g., \~90 days max); actual behavior may vary |
| `endDate`   | string  | No       | Current time | End time; supports RFC 3339 format or Unix millisecond timestamp                                                                                                                              |
| `userId`    | string  | No       | —            | Filter by user UUID                                                                                                                                                                           |
| `userEmail` | string  | No       | —            | Filter by user email (server resolves to the corresponding user identifier)                                                                                                                   |
| `page`      | integer | No       | 1            | Page number (starting from 1)                                                                                                                                                                 |
| `pageSize`  | integer | No       | 100          | Items per page, max 200                                                                                                                                                                       |

> When both `userId` and `userEmail` are provided, `userId` takes precedence.

***

## API list

### 1. List commit details

`GET /v1/organizations/{organization_id}/ai-code-tracking/commits`

List commit-level AI code statistics per record, ordered by commit time descending. Each record includes the product × scenario breakdown.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; additionally:

| Parameter  | Type   | Required | Description               |
| ---------- | ------ | -------- | ------------------------- |
| `repoName` | string | No       | Filter by repository name |

#### Success response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "items": [
      {
        "commitHash": "a1b2c3d4e5f6",
        "userId": "550e8400-e29b-41d4-a716-446655440000",
        "userEmail": "alice@example.com",
        "repoName": "my-project",
        "branchName": "main",
        "isPrimaryBranch": true,
        "totalLinesAdded": 120,
        "totalLinesDeleted": 30,
        "ideNextLinesAdded": 40,
        "ideNextLinesDeleted": 10,
        "pluginNextLinesAdded": 0,
        "pluginNextLinesDeleted": 0,
        "ideAgentLinesAdded": 50,
        "ideAgentLinesDeleted": 15,
        "pluginAgentLinesAdded": 0,
        "pluginAgentLinesDeleted": 0,
        "cliAgentLinesAdded": 0,
        "cliAgentLinesDeleted": 0,
        "ideQuestLinesAdded": 10,
        "ideQuestLinesDeleted": 0,
        "ideInlineChatLinesAdded": 5,
        "ideInlineChatLinesDeleted": 2,
        "jbInlineChatLinesAdded": 0,
        "jbInlineChatLinesDeleted": 0,
        "nonAiLinesAdded": 15,
        "nonAiLinesDeleted": 3,
        "message": "feat: add user login",
        "commitTs": "2025-06-15T10:30:00Z",
        "createdAt": "2025-06-15T10:35:00Z"
      }
    ],
    "pagination": {
      "currentPage": 1,
      "pageSize": 100,
      "totalItems": 256,
      "totalPages": 3
    }
  }
}
```

#### Response fields

**success** — `true` indicates the request succeeded

**data.items\[]** — Commit detail list

| Field                       | Type    | Description                                   |
| --------------------------- | ------- | --------------------------------------------- |
| `commitHash`                | string  | Git commit SHA                                |
| `userId`                    | string  | User UUID                                     |
| `userEmail`                 | string  | User email (may be empty)                     |
| `repoName`                  | string  | Repository name                               |
| `branchName`                | string  | Branch name                                   |
| `isPrimaryBranch`           | boolean | Whether it is the primary branch              |
| `totalLinesAdded`           | integer | Total lines added                             |
| `totalLinesDeleted`         | integer | Total lines deleted                           |
| `ideNextLinesAdded`         | integer | IDE Tab completion lines added                |
| `ideNextLinesDeleted`       | integer | IDE Tab completion lines deleted              |
| `pluginNextLinesAdded`      | integer | JetBrains Plugin Tab completion lines added   |
| `pluginNextLinesDeleted`    | integer | JetBrains Plugin Tab completion lines deleted |
| `ideAgentLinesAdded`        | integer | IDE Agent lines added                         |
| `ideAgentLinesDeleted`      | integer | IDE Agent lines deleted                       |
| `pluginAgentLinesAdded`     | integer | JetBrains Plugin Agent lines added            |
| `pluginAgentLinesDeleted`   | integer | JetBrains Plugin Agent lines deleted          |
| `cliAgentLinesAdded`        | integer | CLI Agent lines added                         |
| `cliAgentLinesDeleted`      | integer | CLI Agent lines deleted                       |
| `ideQuestLinesAdded`        | integer | IDE Quest lines added                         |
| `ideQuestLinesDeleted`      | integer | IDE Quest lines deleted                       |
| `ideInlineChatLinesAdded`   | integer | IDE Inline Chat lines added                   |
| `ideInlineChatLinesDeleted` | integer | IDE Inline Chat lines deleted                 |
| `jbInlineChatLinesAdded`    | integer | JetBrains Inline Chat lines added             |
| `jbInlineChatLinesDeleted`  | integer | JetBrains Inline Chat lines deleted           |
| `nonAiLinesAdded`           | integer | Non-AI lines added                            |
| `nonAiLinesDeleted`         | integer | Non-AI lines deleted                          |
| `message`                   | string  | Commit message (may be empty)                 |
| `commitTs`                  | string  | Commit time (ISO 8601)                        |
| `createdAt`                 | string  | Record creation time (ISO 8601)               |

**data.pagination** — Pagination info

| Field         | Type    | Description         |
| ------------- | ------- | ------------------- |
| `currentPage` | integer | Current page number |
| `pageSize`    | integer | Items per page      |
| `totalItems`  | integer | Total record count  |
| `totalPages`  | integer | Total page count    |

***

### 2. Export commit CSV

`GET /v1/organizations/{organization_id}/ai-code-tracking/commits/export`

Export commit data in streaming CSV format. The server automatically handles pagination aggregation—**callers do not need to paginate manually**.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; additionally:

| Parameter  | Type   | Required | Description               |
| ---------- | ------ | -------- | ------------------------- |
| `repoName` | string | No       | Filter by repository name |

#### Success response (200 OK)

* **Content-Type**: `text/csv; charset=utf-8`

* **Content-Disposition**: `attachment; filename="ai-code-commits.csv"`

CSV column headers (note: CSV retains `userName`; JSON responses have removed it):

```plaintext theme={null}
commitHash,userId,userEmail,userName,repoName,branchName,isPrimaryBranch,
totalLinesAdded,totalLinesDeleted,
ideNextLinesAdded,ideNextLinesDeleted,pluginNextLinesAdded,pluginNextLinesDeleted,
ideAgentLinesAdded,ideAgentLinesDeleted,pluginAgentLinesAdded,pluginAgentLinesDeleted,
cliAgentLinesAdded,cliAgentLinesDeleted,ideQuestLinesAdded,ideQuestLinesDeleted,
ideInlineChatLinesAdded,ideInlineChatLinesDeleted,jbInlineChatLinesAdded,jbInlineChatLinesDeleted,
nonAiLinesAdded,nonAiLinesDeleted,message,commitTs,createdAt
```

***

### 3. List change details

`GET /v1/organizations/{organization_id}/ai-code-tracking/changes`

List IDE AI code edit events (only `action=suggested` records), ordered by event time descending.

> Changes are IDE events not yet committed to Git, so `repoName` filtering is **not supported**.

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; additionally:

| Parameter | Type   | Required | Description                                                              |
| --------- | ------ | -------- | ------------------------------------------------------------------------ |
| `source`  | string | No       | Filter by usage scenario. Values: `AGENT`, `NEXT`, `QUEST`, `INLINECHAT` |

#### Success response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "items": [
      {
        "changeId": "chg_abc123",
        "userId": "550e8400-e29b-41d4-a716-446655440000",
        "userEmail": "alice@example.com",
        "source": "AGENT",
        "model": "efficient",
        "totalLinesAdded": 45,
        "totalLinesDeleted": 12,
        "metadata": [
          {
            "fileName": "main.go",
            "fileExtension": ".go",
            "linesAdded": 30,
            "linesDeleted": 8
          },
          {
            "fileName": "utils.go",
            "fileExtension": ".go",
            "linesAdded": 15,
            "linesDeleted": 4
          }
        ],
        "createdAt": "2025-06-15T10:28:00Z"
      }
    ],
    "pagination": {
      "currentPage": 1,
      "pageSize": 100,
      "totalItems": 1024,
      "totalPages": 11
    }
  }
}
```

#### Response fields

**success** — `true` indicates the request succeeded

**data.items\[]** — Change detail list

| Field                      | Type    | Description                                                        |
| -------------------------- | ------- | ------------------------------------------------------------------ |
| `changeId`                 | string  | Unique change event identifier                                     |
| `userId`                   | string  | User UUID                                                          |
| `userEmail`                | string  | User email (may be empty)                                          |
| `source`                   | string  | Usage scenario (uppercase): `NEXT`, `AGENT`, `QUEST`, `INLINECHAT` |
| `model`                    | string  | Model tier: `lite`, `efficient`, `auto` (may be empty)             |
| `totalLinesAdded`          | integer | Total lines added                                                  |
| `totalLinesDeleted`        | integer | Total lines deleted                                                |
| `metadata`                 | array   | File-level change details (may be empty)                           |
| `metadata[].fileName`      | string  | File name                                                          |
| `metadata[].fileExtension` | string  | File extension                                                     |
| `metadata[].linesAdded`    | integer | File lines added                                                   |
| `metadata[].linesDeleted`  | integer | File lines deleted                                                 |
| `createdAt`                | string  | Event time (ISO 8601)                                              |

**data.pagination** — Pagination info

| Field         | Type    | Description         |
| ------------- | ------- | ------------------- |
| `currentPage` | integer | Current page number |
| `pageSize`    | integer | Items per page      |
| `totalItems`  | integer | Total record count  |
| `totalPages`  | integer | Total page count    |

***

### 4. Export change CSV

`GET /v1/organizations/{organization_id}/ai-code-tracking/changes/export`

Export change data in streaming CSV format. The server automatically handles pagination aggregation—**callers do not need to paginate manually**.

> CSV export uses a flat format and does not include `metadata` (file-level details).

#### Path parameters

| Parameter         | Type   | Required | Description     |
| ----------------- | ------ | -------- | --------------- |
| `organization_id` | string | Yes      | Organization ID |

#### Query parameters

See "Common query parameters"; additionally:

| Parameter | Type   | Required | Description                                                              |
| --------- | ------ | -------- | ------------------------------------------------------------------------ |
| `source`  | string | No       | Filter by usage scenario. Values: `AGENT`, `NEXT`, `QUEST`, `INLINECHAT` |

#### Success response (200 OK)

* **Content-Type**: `text/csv; charset=utf-8`

* **Content-Disposition**: `attachment; filename="ai-code-changes.csv"`

CSV column headers:

```plaintext theme={null}
changeId,userId,userEmail,source,model,totalLinesAdded,totalLinesDeleted,createdAt
```

***

## Usage examples

### Query commit details (filter by repo)

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/commits?startDate=2025-06-01T00:00:00Z&endDate=2025-06-30T23:59:59Z&repoName=my-project&pageSize=50" \
  -H "Authorization: Bearer <api_key>"
```

### Query user commits by email

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/commits?startDate=2025-06-01T00:00:00Z&userEmail=alice@example.com" \
  -H "Authorization: Bearer <api_key>"
```

### Export commit CSV

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/commits/export?startDate=2025-06-01T00:00:00Z" \
  -H "Authorization: Bearer <api_key>" \
  -o ai-code-commits.csv
```

### Query change details (filter by source)

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/changes?startDate=2025-06-01T00:00:00Z&source=QUEST&pageSize=50" \
  -H "Authorization: Bearer <api_key>"
```

### Export change CSV

```bash theme={null}
curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/changes/export?startDate=2025-06-01T00:00:00Z" \
  -H "Authorization: Bearer <api_key>" \
  -o ai-code-changes.csv
```

***

## Error codes

| Error code      | HTTP status | Description                                                                         |
| --------------- | ----------- | ----------------------------------------------------------------------------------- |
| `Unauthorized`  | 401         | API key missing or invalid                                                          |
| `Forbidden`     | 403         | No permission to access this organization                                           |
| `BadRequest`    | 400         | Invalid request parameters (e.g., `organization_id` / `userId` is not a valid UUID) |
| `InternalError` | 500         | Internal server error                                                               |

Error response shape: see **Error responses** in [Conventions](/account/teams/openapi/conventions).
