<@ULVA73B9P> I'm using the REST API endpoint `/api...
# ask-marvin
c
@Marvin I'm using the REST API endpoint
/api/accounts/{account_id}/workspaces/{workspace_id}/events/filter
. If I post to this with no request body it only returns total=20 records and next_page = null. I was expecting to get many more records than that. The cloud UI shows over a 1000 pages. Can you explain what I'm doing wrong.
m
thought for 128.6 seconds
You’re not doing anything wrong — the behavior you’re seeing is due to the endpoint’s defaults. A POST to /events/filter with no body does not mean “return all events”. The API applies a default filter (including a recent time window) and a page size cap. As a result: - total is the count of events that match the default filter, not your entire history - next_page is null because, for that default filter, there aren’t any additional pages That’s why you’re seeing total=20 while the Cloud UI shows far more — the UI is likely using a broader time range than the API’s default. How to get everything you expect: 1) Specify your desired time window explicitly - Include an occurred filter with since (and optionally until) to match the UI’s date range or to fetch your full history. - Example request:
Copy code
POST <https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/events/filter>
Content-Type: application/json

{
  "filter": {
    "occurred": {
      "since": "1970-01-01T00:00:00Z",
      "until": "2026-12-31T23:59:59Z"
    }
  },
  "limit": 50
}
Notes: - limit is capped by the API (you’ll get up to 50 per page). - total in the response will reflect the count for that filter window. 2) Follow pagination using next_page - The response includes next_page when there are more results. Call that URL directly (it’s a GET) to fetch subsequent pages until next_page is null.
Copy code
GET <https://api.prefect.cloud/api/events/filter/next?page-token=>...
3) Sanity checks if counts still look off - Make sure you’re using the same account_id/workspace_id as the UI you’re viewing. - Ensure your token is scoped to that workspace. - Align the occurred filter with any time filters you’ve set in the UI. Reference docs: - Prefect Events concept: Events overview - Cloud REST API reference (Redoc): Prefect Cloud API docs If you can share the exact date range you’re trying to match from the UI, I can give you a precise filter body to use.