---
title: "Count Account Events"
method: POST
path: "/api/events/count-by/{countable}"
tags: ["Events"]
---

# Count Account Events

`POST /api/events/count-by/{countable}`

Returns distinct objects and the count of events associated with them.  Objects
that can be counted include the day the event occurred, the type of event, or
the IDs of the resources associated with the event.

## Path parameters

- `countable` 'day' | 'time' | 'event' | 'resource', required — An enumeration.

## Headers

- `x-prefect-api-version` string

## Request body

- BodyCountAccountEventsEventsCountByCountablePost
  - `filter` EventFilter, required — A base class for filtering event data.
    - `occurred` EventOccurredFilter — A base class for filtering event data.
      - `since` string, date-time — Only include events after this time (inclusive)
      - `until` string, date-time — Only include events prior to this time (inclusive)
    - `event` EventNameFilter — A base class for filtering event data.
      - `prefix` string[] — Only include events matching one of these prefixes
      - `exclude_prefix` string[] — Exclude events matching one of these prefixes
      - `name` string[] — Only include events matching one of these names exactly
      - `exclude_name` string[] — Exclude events matching one of these names exactly
    - `any_resource` EventAnyResourceFilter — A base class for filtering event data.
      - `id` string[] — Only include events for resources with these IDs
      - `id_prefix` string[] — Only include events for resources with IDs starting with these prefixes
      - `labels` ResourceSpecification — A specification that may match zero, one, or many resources, used to target or select a set of resources in a query or automation. A resource must match at least one value of all of the provided labels
    - `resource` EventResourceFilter — A base class for filtering event data.
      - `id` string[] — Only include events for resources with these IDs
      - `id_prefix` string[] — Only include events for resources with IDs starting with these prefixes.
      - `labels` ResourceSpecification — A specification that may match zero, one, or many resources, used to target or select a set of resources in a query or automation. A resource must match at least one value of all of the provided labels
      - `distinct` boolean — Only include events for distinct resources
    - `related` EventRelatedFilter — A base class for filtering event data.
      - `id` string[] — Only include events for related resources with these IDs
      - `role` string[] — Only include events for related resources in these roles
      - `resources_in_roles` array[] — Only include events with specific related resources in specific roles
        - unknown[]
          - unknown
      - `labels` ResourceSpecification — A specification that may match zero, one, or many resources, used to target or select a set of resources in a query or automation. A resource must match at least one value of all of the provided labels
    - `id` EventIDFilter — A base class for filtering event data.
      - `id` string[] — Only include events with one of these IDs
    - `order` 'ASC' | 'DESC' — An enumeration.
  - `time_unit` 'week' | 'day' | 'hour' | 'minute' | 'second' — An enumeration.
  - `time_interval` number

## Response `200`

Successful Response

- EventCount[]
  - `value` string, required — The value to use for filtering
  - `label` string, required — The value to display for this count
  - `count` integer, required — The count of matching events
  - `start_time` string, date-time, required — The start time of this group of events
  - `end_time` string, date-time, required — The end time of this group of events

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/prefecthq/apis/untitled-api-2.md) · [All operations](https://skmtc.net/prefecthq/apis/untitled-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/prefecthq/untitled-api-2/revisions/29ba6c4f8837/schema)
