onWatch can track Cursor AI usage quotas automatically by reading auth tokens from the local system.
onWatch detects your Cursor authentication from two sources:
- Cursor Desktop SQLite (preferred) - reads
cursorAuth/accessTokenandcursorAuth/refreshTokenfrom~/Library/Application Support/Cursor/User/globalStorage/state.vscdb - macOS Keychain (fallback) - reads
cursor-access-tokenandcursor-refresh-tokenservices
If both sources exist and the SQLite account is a free-tier plan while the keychain has a different account, onWatch prefers the keychain token (matching openusage behavior).
No manual configuration needed. If Cursor Desktop is installed and you're logged in, onWatch will auto-detect your credentials on startup.
If auto-detection fails, set the CURSOR_TOKEN environment variable:
export CURSOR_TOKEN="your_cursor_access_token"Or add it to your .env file:
CURSOR_TOKEN=your_cursor_access_token
Cursor access tokens are short-lived JWTs. onWatch automatically refreshes them:
- Before each poll, onWatch checks if the token expires within 5 minutes
- If expiring, it calls the Cursor OAuth refresh endpoint (
https://api2.cursor.sh/oauth/token) - The refreshed access token is written back to Cursor's SQLite database
If the refresh token is invalid (e.g., revoked), onWatch pauses polling and logs an error. You'll need to re-authenticate via the Cursor app.
- Total Usage - percentage of plan limit used
- Auto Mode - auto-mode usage percentage
- API Usage - API/manual usage percentage
- Credits - combined credit grants + Stripe prepaid balance (dollars)
- On-Demand - spend limit usage (dollars, if configured)
- Total Usage - dollar-based spend tracking
- Auto Mode - auto-mode usage percentage
- API Usage - API manual usage percentage
- Credits - combined credit grants + Stripe balance (dollars)
- On-Demand - individual or pooled spend limit (dollars)
- Requests - per-model request counts and limits
onWatch automatically detects your account type:
- Individual:
planNameis "pro", "ultra", or "free", orspendLimitUsage.limitTypeis "user" - Team:
planNameis "team"/"business", orlimitTypeis "team", orpooledLimitis present - Enterprise:
planNameis "enterprise" (uses request-based/api/usageinstead of Connect RPC)
| Endpoint | Purpose |
|---|---|
POST /aiserver.v1.DashboardService/GetCurrentPeriodUsage |
Current usage metrics (Connect RPC) |
POST /aiserver.v1.DashboardService/GetPlanInfo |
Plan name and pricing (Connect RPC) |
POST /aiserver.v1.DashboardService/GetCreditGrantsBalance |
Credit grants balance (Connect RPC) |
GET https://cursor.com/api/auth/stripe |
Stripe prepaid balance (cookie auth) |
GET https://cursor.com/api/usage |
Request-based usage for enterprise (cookie auth) |
POST https://api2.cursor.sh/oauth/token |
OAuth token refresh |
onWatch will attempt to refresh your token automatically. If refresh fails, try:
- Open Cursor Desktop and make sure you're logged in
- Restart onWatch to trigger fresh token detection
Your refresh token has been revoked. You need to:
- Re-authenticate in the Cursor app
- Restart onWatch
If onWatch detects your free-tier SQLite account instead of your paid keychain account, try:
- Logging out of the free-tier account in Cursor Desktop
- Restarting onWatch