I’m working on hourly anomaly detection using the Cursor Admin API.
According to the documentation, usage data is aggregated hourly, and the recommendation is to poll the API once an hour.
I have a question about the timing of the data availability.
For example, if my anomaly detection job runs at 10:00 AM, I want to analyze the complete data for the previous hour, i.e. 9:00–10:00 AM.
How long after the hour should I wait before calling the API to make sure the data for the previous hour is complete?
Also, is there any recommended way to make sure that I don’t miss data because of a delay in aggregation?
For example:
10:15 AM → my job runs
9:00–10:00 AM → target data window
When should I call the API?
Is the data guaranteed to be complete at a specific time?
Should I introduce a delay or overlap the previous hour when polling?
I found the documentation mentioning that usage data is aggregated hourly, but I couldn’t find information about the expected data availability/lag after the hour.
Any guidance on the recommended polling strategy would be helpful.
“Aggregated at the hourly level” is just polling-cadence guidance, not fixed hourly batching, and there’s no point after which an hour is guaranteed 100% complete. Each /teams/filtered-usage-events row is stamped with the request’s start time but only appears once that request finishes, so a long run spanning 9:55–10:40 lands in your 9:00–10:00 window only after 10:40.
Practical setup for hourly detection:
Run at ~:15 past the hour (your 10:15 is fine). Most of the previous hour is in by then.
Each run, re-pull a trailing window (for example the last 6h), not just the last hour, and overwrite whole hour buckets instead of appending. There’s no per-event ID, so last-write-wins on hour buckets avoids double counting.
Treat the most recent hour as provisional. Run strict detection on the hour before it, which is essentially complete.
Optional: re-pull the previous full day once daily to catch rare long-running requests.
Also: endDate is inclusive (use 09:59:59.999 for an hour window), and limits are 60 req/min with 1000 events/page, so this stays well within budget.