Skip to main content

Command Palette

Search for a command to run...

API

AI Code Tracking API

The AI Code Tracking API lets you track AI-generated code contributions across your team's repositories, including per-commit AI usage and granular accepted AI changes.

  • The AI Code Tracking API uses Basic Authentication with your API key as the username, the same method as the Admin API.
  • For details on creating API keys, authentication methods, rate limits, and best practices, see the API Overview.
  • Availability: Enterprise only, contact sales to get access
  • Status: Alpha (response shapes and fields may change)
  • Workspace limitation: Metrics are only calculated for the git repository at the top level of the workspace root. Multi-root workspaces are not currently supported.

Endpoints

Get AI Commit Metrics (JSON, paginated)

GET/analytics/ai-code/commits

Retrieve aggregated per-commit metrics that attribute lines to TAB, COMPOSER, and non-AI.

Parameters

startDate string | date

ISO date string, the literal "now", or relative days like "7d" (means now - 7 days). Default: now - 7 days

endDate string | date

ISO date string, the literal "now", or relative days like "0d". Default: now

page number

Page number (1-based). Default: 1

pageSize number

Results per page. Default: 100, Max: 1000

user string

Optional filter by a single user. Accepts email (e.g., developer@company.com), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42)

Response Fields

FieldTypeDescription
commitHashstringGit commit hash
userIdstringEncoded user ID (e.g., user_abc123)
userEmailstringUser's email address
repoNamestring | nullRepository name
branchNamestring | nullBranch name
isPrimaryBranchboolean | nullWhether this is the primary branch
commitSource"ide" | "cli" | "cloud"Where the commit originated.
totalLinesAddednumberTotal lines added in commit
totalLinesDeletednumberTotal lines deleted in commit
tabLinesAddednumberLines added via TAB completions
tabLinesDeletednumberLines deleted via TAB completions
composerLinesAddednumberLines added via Composer
composerLinesDeletednumberLines deleted via Composer
nonAiLinesAddednumber | nullNon-AI lines added
nonAiLinesDeletednumber | nullNon-AI lines deleted
messagestring | nullCommit message
commitTsstring | nullCommit timestamp (ISO format)
createdAtstringIngestion timestamp (ISO format)
curl -X GET "https://api.cursor.com/analytics/ai-code/commits?startDate=7d&endDate=now&page=1&pageSize=100" \  -u YOUR_API_KEY:

Response:

{  "items": [    {      "commitHash": "a1b2c3d4",      "userId": "user_3k9x8q...",      "userEmail": "developer@company.com",      "repoName": "company/repo",      "branchName": "main",      "isPrimaryBranch": true,      "commitSource": "ide",      "totalLinesAdded": 120,      "totalLinesDeleted": 30,      "tabLinesAdded": 50,      "tabLinesDeleted": 10,      "composerLinesAdded": 40,      "composerLinesDeleted": 5,      "nonAiLinesAdded": 30,      "nonAiLinesDeleted": 15,      "message": "Refactor: extract analytics client",      "commitTs": "2025-07-30T14:12:03.000Z",      "createdAt": "2025-07-30T14:12:30.000Z"    }  ],  "totalCount": 42,  "page": 1,  "pageSize": 100}

Download AI Commit Metrics (CSV, streaming)

GET/analytics/ai-code/commits.csv

Download commit metrics data in CSV format for large data extractions.

Parameters

startDate string | date

ISO date string, the literal "now", or relative days like "7d" (means now - 7 days). Default: now - 7 days

endDate string | date

ISO date string, the literal "now", or relative days like "0d". Default: now

user string

Optional filter by a single user. Accepts email (e.g., developer@company.com), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42)

Response Headers

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

CSV Columns

ColumnTypeDescription
commit_hashstringGit commit hash
user_idstringEncoded user ID
user_emailstringUser's email address
repo_namestringRepository name
branch_namestringBranch name
is_primary_branchbooleanWhether this is the primary branch
commit_sourcestringWhere the commit originated (ide, cli, or cloud)
total_lines_addednumberTotal lines added in commit
total_lines_deletednumberTotal lines deleted in commit
tab_lines_addednumberLines added via TAB completions
tab_lines_deletednumberLines deleted via TAB completions
composer_lines_addednumberLines added via Composer
composer_lines_deletednumberLines deleted via Composer
non_ai_lines_addednumberNon-AI lines added
non_ai_lines_deletednumberNon-AI lines deleted
messagestringCommit message
commit_tsstringCommit timestamp (ISO format)
created_atstringIngestion timestamp (ISO format)
curl -L "https://api.cursor.com/analytics/ai-code/commits.csv?startDate=2025-07-01T00:00:00Z&endDate=now&user=user_3k9x8q..." \  -u YOUR_API_KEY: \  -o commits.csv

Sample CSV Output:

commit_hash,commit_source,user_id,user_email,repo_name,branch_name,is_primary_branch,total_lines_added,total_lines_deleted,tab_lines_added,tab_lines_deleted,composer_lines_added,composer_lines_deleted,non_ai_lines_added,non_ai_lines_deleted,message,commit_ts,created_ata1b2c3d4,ide,user_3k9x8q...,developer@company.com,company/repo,main,true,120,30,50,10,40,5,30,15,"Refactor: extract analytics client",2025-07-30T14:12:03.000Z,2025-07-30T14:12:30.000Ze5f6g7h8,cloud,user_3k9x8q...,developer@company.com,company/repo,feature-branch,false,85,15,30,5,25,3,30,7,"Add error handling",2025-07-30T13:45:21.000Z,2025-07-30T13:45:45.000Z

Get AI Code Change Metrics (JSON, paginated)

GET/analytics/ai-code/changes

Retrieve granular accepted AI changes, grouped by deterministic changeId. Useful to analyze accepted AI events independent of commits.

Parameters

startDate string | date

ISO date string, the literal "now", or relative days like "7d" (means now - 7 days). Default: now - 7 days

endDate string | date

ISO date string, the literal "now", or relative days like "0d". Default: now

page number

Page number (1-based). Default: 1

pageSize number

Results per page. Default: 100, Max: 1000

user string

Optional filter by a single user. Accepts email (e.g., developer@company.com), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42)

Response Fields

FieldTypeDescription
changeIdstringDeterministic ID for the change
userIdstringEncoded user ID (e.g., user_abc123)
userEmailstringUser's email address
source"TAB" | "COMPOSER"Source of the AI change
modelstring | nullAI model used
totalLinesAddednumberTotal lines added
totalLinesDeletednumberTotal lines deleted
createdAtstringIngestion timestamp (ISO format)
metadataArrayFile metadata (fileName may be omitted in privacy mode)
curl -X GET "https://api.cursor.com/analytics/ai-code/changes?startDate=14d&endDate=now&page=1&pageSize=200" \  -u YOUR_API_KEY:

Response:

{  "items": [    {      "changeId": "749356201",      "userId": "user_3k9x8q...",      "userEmail": "developer@company.com",      "source": "COMPOSER",      "model": null,      "totalLinesAdded": 18,      "totalLinesDeleted": 4,      "createdAt": "2025-07-30T15:10:12.000Z",      "metadata": [        {          "fileName": "src/analytics/report.ts",          "fileExtension": "ts",          "linesAdded": 12,          "linesDeleted": 3        },        {          "fileName": "src/analytics/ui.tsx",          "fileExtension": "tsx",          "linesAdded": 6,          "linesDeleted": 1        }      ]    }  ],  "totalCount": 128,  "page": 1,  "pageSize": 200}

Download AI Code Change Metrics (CSV, streaming)

GET/analytics/ai-code/changes.csv

Download change metrics data in CSV format for large data extractions.

Parameters

startDate string | date

ISO date string, the literal "now", or relative days like "7d" (means now - 7 days). Default: now - 7 days

endDate string | date

ISO date string, the literal "now", or relative days like "0d". Default: now

user string

Optional filter by a single user. Accepts email (e.g., developer@company.com), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42)

Response Headers

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

CSV Columns

ColumnTypeDescription
change_idstringDeterministic ID for the change
user_idstringEncoded user ID
user_emailstringUser's email address
sourcestringSource of the AI change (TAB or COMPOSER)
modelstringAI model used
total_lines_addednumberTotal lines added
total_lines_deletednumberTotal lines deleted
created_atstringIngestion timestamp (ISO format)
metadata_jsonstringJSON stringified array of metadata entries
curl -L "https://api.cursor.com/analytics/ai-code/changes.csv?startDate=30d&endDate=now" \  -u YOUR_API_KEY: \  -o changes.csv

Sample CSV Output:

change_id,user_id,user_email,source,model,total_lines_added,total_lines_deleted,created_at,metadata_json749356201,user_3k9x8q...,developer@company.com,COMPOSER,gpt-4o,18,4,2025-07-30T15:10:12.000Z,"[{""fileName"":""src/analytics/report.ts"",""fileExtension"":""ts"",""linesAdded"":12,""linesDeleted"":3},{""fileName"":""src/analytics/ui.tsx"",""fileExtension"":""tsx"",""linesAdded"":6,""linesDeleted"":1}]"749356202,user_3k9x8q...,developer@company.com,TAB,,8,2,2025-07-30T15:08:45.000Z,"[{""fileName"":""src/utils/helpers.ts"",""fileExtension"":""ts"",""linesAdded"":8,""linesDeleted"":2}]"

Get Commit Details

GET/analytics/ai-code/commits/:commitHash

Retrieve detailed information for one or more commits, including blame annotations and referenced conversation metadata.

Path Parameters

commitHash string

Single commit hash or comma-separated list of hashes (e.g., abc123,def456)

Query Parameters

branch string

Optional filter by branch name

Response Fields

Returns an object containing commits and conversations arrays.

FieldTypeDescription
commitsarrayArray of commit objects with blame annotations
commits[].commitSource"ide" | "cli" | "cloud"Where the commit originated.
commits[].rangeAnnotationsarrayFile-level blame data for the commit
commits[].rangeAnnotations[].filePathstringPath to the file within the repository
commits[].rangeAnnotations[].groupsarrayArray of annotation groups
commits[].rangeAnnotations[].groups[].conversationIdstring | nullID of the conversation that generated this code
commits[].rangeAnnotations[].groups[].modelstring | nullAI model used to generate the code
commits[].rangeAnnotations[].groups[].operationTypestringType of operation performed
commits[].rangeAnnotations[].groups[].rangesarrayArray of line ranges affected by this annotation
commits[].rangeAnnotations[].groups[].ranges[].startnumberStarting line number
commits[].rangeAnnotations[].groups[].ranges[].endnumberEnding line number
conversationsarrayConversation metadata for all referenced conversations
conversations[].idstringUnique conversation identifier
conversations[].titlestring | nullConversation title
conversations[].tldrstring | nullBrief summary
conversations[].overviewstring | nullDetailed overview
conversations[].summaryBulletsarray | nullArray of summary bullet points

Single commit:

curl -X GET "https://api.cursor.com/analytics/ai-code/commits/0aabf603dc906e05bf5e4d9fd423fdd517f2e43f?branch=main" \  -u YOUR_API_KEY:

Multiple commits:

curl -X GET "https://api.cursor.com/analytics/ai-code/commits/abc123,def456,ghi789" \  -u YOUR_API_KEY:

Response:

{  "commits": [    {      "commitHash": "0aabf603dc906e05bf5e4d9fd423fdd517f2e43f",      "commitSource": "ide",      "rangeAnnotations": [        {          "filePath": "src/analytics/report.ts",          "groups": [            {              "conversationId": "conv_abc123",              "model": "gpt-4o",              "operationType": "insert",              "ranges": [                { "start": 10, "end": 25 },                { "start": 42, "end": 58 }              ]            }          ]        }      ]    }  ],  "conversations": [    {      "id": "conv_abc123",      "title": "Refactor analytics module",      "tldr": "Extracted report generation into separate functions",      "overview": "Refactored the analytics module to improve maintainability by extracting report generation logic.",      "summaryBullets": [        "Created dedicated report generator class",        "Added unit tests for new functions",        "Updated imports across affected files"      ]    }  ]}

Common Query Parameters

All endpoints accept the same query parameters via query string:

ParameterTypeRequiredDescription
startDatestring | dateNoISO date string, the literal "now", or relative days like "7d" (means now - 7 days). Default: now - 7 days
endDatestring | dateNoISO date string, the literal "now", or relative days like "0d". Default: now
pagenumberNoPage number (1-based). Default: 1
pageSizenumberNoResults per page. Default: 100, Max: 1000
userstringNoOptional filter by a single user. Accepts email (e.g., developer@company.com), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42)

Semantics and How Metrics Are Computed

  • Sources: "TAB" represents inline completions that were accepted; "COMPOSER" represents accepted diffs from Agent edits
  • Lines metrics: tabLinesAdded/Deleted and composerLinesAdded/Deleted are separately counted; nonAiLinesAdded/Deleted are derived as max(0, totalLines - AI lines)
  • Privacy mode: If enabled in the client, some metadata (like fileName) may be omitted
  • Branch info: isPrimaryBranch is true when the current branch equals the repo's default branch; may be undefined if repo info is unavailable

You can scan that file to understand how commits and changes are detected and reported.

Tips

  • Use user parameter to quickly filter a single user across all endpoints
  • For large data extractions, prefer CSV endpoints—they stream in pages of 10,000 records server-side
  • isPrimaryBranch may be undefined if the client couldn't resolve the default branch
  • commitTs is the commit timestamp; createdAt is the ingestion time on our servers
  • Some fields may be absent when privacy mode is enabled on the client
  • Commit hashes are not unique or unchangeable. For example, you may see the same commit twice if you amend commits with extra information.
  • Commit timestamps will remain unchanged even if the commit is amended.

Changelog

  • Alpha release: Initial endpoints for commits and changes. Response shapes may evolve based on feedback

AI Code Tracking is available on the Enterprise plan

Contact our team to get access to detailed AI usage metrics.

Contact Sales