|
| 1 | +--- |
| 2 | +description: Cursor Enterprise API reference — endpoints, auth, response shapes, rate limits |
| 3 | +globs: "**/cursor-client.ts" |
| 4 | +alwaysApply: false |
| 5 | +--- |
| 6 | + |
| 7 | +# Cursor Enterprise API Reference |
| 8 | + |
| 9 | +Base URL: `https://api.cursor.com` |
| 10 | +Auth: **Basic Auth** — `Authorization: Basic {base64(API_KEY + ':')}` |
| 11 | +Two separate API keys: Admin API key and Analytics API key (generated from team settings). |
| 12 | + |
| 13 | +## Rate Limits (per team, per minute) |
| 14 | + |
| 15 | +| API | Endpoint Type | Limit | |
| 16 | +|-----|---------------|-------| |
| 17 | +| Admin API | Most endpoints | 20 req/min | |
| 18 | +| Admin API | `/teams/user-spend-limit` | 250 req/min | |
| 19 | +| Analytics API | Team-level (`/analytics/team/*`) | 100 req/min | |
| 20 | +| Analytics API | By-user (`/analytics/by-user/*`) | 50 req/min | |
| 21 | + |
| 22 | +304 responses from ETag caching do NOT count against rate limits. |
| 23 | + |
| 24 | +## Admin API Endpoints |
| 25 | + |
| 26 | +### GET /teams/members |
| 27 | +Returns `{ teamMembers: [{ name, email, role }] }` |
| 28 | + |
| 29 | +### POST /teams/daily-usage-data |
| 30 | +Body: `{ startDate: number (ms), endDate: number (ms) }` |
| 31 | +Poll at most once per hour (data aggregated hourly). |
| 32 | + |
| 33 | +### POST /teams/spend |
| 34 | +Body: `{ page, pageSize }` |
| 35 | +Returns `{ teamMemberSpend: [{ email, spendCents, fastPremiumRequests }], subscriptionCycleStart: number, totalPages }` |
| 36 | + |
| 37 | +### POST /teams/filtered-usage-events |
| 38 | +Body: `{ email?, startDate?, endDate?, page, pageSize }` |
| 39 | +Returns `{ usageEvents: [{ timestamp, model, kindLabel, tokenUsage: { inputTokens, outputTokens, cacheWriteTokens, cacheReadTokens }, userEmail }], pagination: { hasNextPage } }` |
| 40 | +Poll at most once per hour (data aggregated hourly). Max 30 days per request. |
| 41 | + |
| 42 | +### POST /teams/user-spend-limit |
| 43 | +Body: `{ email, hardLimitDollars }` |
| 44 | + |
| 45 | +## Analytics API Endpoints (separate key: CURSOR_ANALYTICS_API_KEY) |
| 46 | + |
| 47 | +All use `startDate`/`endDate` params (formats: `YYYY-MM-DD`, `7d`, `30d`, `today`, `yesterday`). Max 30 days. Default: last 7 days. |
| 48 | +Optional `users` param: comma-separated emails or user IDs. |
| 49 | + |
| 50 | +### Team-Level |
| 51 | +- `GET /analytics/team/dau` — daily active users (includes cli_dau, cloud_agent_dau, bugbot_dau) |
| 52 | +- `GET /analytics/team/models` — model usage with `model_breakdown` per day |
| 53 | +- `GET /analytics/team/agent-edits` — agent edits (suggested/accepted diffs and lines) |
| 54 | +- `GET /analytics/team/tabs` — tab autocomplete usage |
| 55 | +- `GET /analytics/team/leaderboard` — ranked by AI usage (supports `page`, `pageSize`) |
| 56 | +- `GET /analytics/team/mcp` — MCP tool adoption |
| 57 | +- `GET /analytics/team/commands` — command adoption |
| 58 | +- `GET /analytics/team/plans` — plan mode adoption |
| 59 | +- `GET /analytics/team/ask-mode` — ask mode adoption |
| 60 | +- `GET /analytics/team/client-versions` — Cursor version distribution |
| 61 | +- `GET /analytics/team/top-file-extensions` — most edited file types |
| 62 | + |
| 63 | +### By-User (paginated: `page`, `pageSize`, max 500) |
| 64 | +All follow pattern: `GET /analytics/by-user/{metric}` |
| 65 | +Available: `agent-edits`, `tabs`, `models`, `mcp`, `commands`, `plans`, `ask-mode`, `client-versions`, `top-file-extensions` |
| 66 | + |
| 67 | +## Known Model Strings (from API responses) |
| 68 | + |
| 69 | +`claude-sonnet-4.5`, `claude-opus-4.5`, `claude-opus-4.6`, `gpt-4o`, `gpt-5.2`, `gpt-5.3-codex`, `gemini-3-flash`, `gemini-3-pro`, `grok-code` |
| 70 | + |
| 71 | +## Caching |
| 72 | + |
| 73 | +Analytics and AI Code Tracking APIs support ETags. Use `If-None-Match` header for 304 responses (15-minute cache, `Cache-Control: public, max-age=900`). |
| 74 | + |
| 75 | +## Important |
| 76 | + |
| 77 | +Admin API endpoint response shapes are based on community implementations and may not exactly match the live API. Analytics API shapes are from official Cursor documentation (Feb 2026). If you encounter mismatches, update `src/lib/types.ts` and `src/lib/cursor-client.ts`. |
0 commit comments