cursor-docs/latest/content · Jun 26, 20:20 UTC
pages/account/teams/ai-code-tracking-api.txt
TXT13.9 KB293 lines
route: /docs/account/teams/ai-code-tracking-api title: AI Code Tracking API description: Track AI-generated code contributions across your team with the 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., [email protected]), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42) Response Fields Field Type Description commitHash string Git commit hash userId string Encoded user ID (e.g., user_abc123) userEmail string User's email address repoName string | null Repository name branchName string | null Branch name isPrimaryBranch boolean | null Whether this is the primary branch commitSource "ide" | "cli" | "cloud" Where the commit originated. totalLinesAdded number Total lines added in commit totalLinesDeleted number Total lines deleted in commit tabLinesAdded number Lines added via TAB completions tabLinesDeleted number Lines deleted via TAB completions composerLinesAdded number Lines added via Composer composerLinesDeleted number Lines deleted via Composer nonAiLinesAdded number | null Non-AI lines added nonAiLinesDeleted number | null Non-AI lines deleted message string | null Commit message commitTs string | null Commit timestamp (ISO format) createdAt string Ingestion 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": "[email protected]", "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., [email protected]), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42) Response Headers Content-Type: text/csv; charset=utf-8 CSV Columns Column Type Description commit_hash string Git commit hash user_id string Encoded user ID user_email string User's email address repo_name string Repository name branch_name string Branch name is_primary_branch boolean Whether this is the primary branch commit_source string Where the commit originated (ide, cli, or cloud) total_lines_added number Total lines added in commit total_lines_deleted number Total lines deleted in commit tab_lines_added number Lines added via TAB completions tab_lines_deleted number Lines deleted via TAB completions composer_lines_added number Lines added via Composer composer_lines_deleted number Lines deleted via Composer non_ai_lines_added number Non-AI lines added non_ai_lines_deleted number Non-AI lines deleted message string Commit message commit_ts string Commit timestamp (ISO format) created_at string Ingestion 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_at a1b2c3d4,ide,user_3k9x8q...,[email protected],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.000Z e5f6g7h8,cloud,user_3k9x8q...,[email protected],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., [email protected]), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42) Response Fields Field Type Description changeId string Deterministic ID for the change userId string Encoded user ID (e.g., user_abc123) userEmail string User's email address source "TAB" | "COMPOSER" Source of the AI change model string | null AI model used totalLinesAdded number Total lines added totalLinesDeleted number Total lines deleted createdAt string Ingestion timestamp (ISO format) metadata Array File 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": "[email protected]", "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., [email protected]), encoded ID (e.g., user_abc123...), or numeric ID (e.g., 42) Response Headers Content-Type: text/csv; charset=utf-8 CSV Columns Column Type Description change_id string Deterministic ID for the change user_id string Encoded use …