---
title: "Retrieve Event Counts for an Organization (v2)"
url: https://docs.sentry.io/api/organizations/retrieve-event-counts-for-an-organization-v2/
---

# Retrieve Event Counts for an Organization (v2) | Sentry Docs

GET /api/0/organizations/{organization\_id\_or\_slug}/stats\_v2/

Query event counts for your Organization. Select a field, define a date range, and group or filter by columns.

### Path Parameters

* `organization_id_or_slug` *(string)*

  REQUIRED

  The ID or slug of the organization the resource belongs to.

### Query Parameters:

* `groupBy` *(array(string))*

  REQUIRED

  **choices**:

  * `outcome
    category
    reason
    project`

  can pass multiple groupBy parameters to group by multiple, e.g. `groupBy=project&groupBy=outcome` to group by multiple dimensions. Note that grouping by project can cause missing rows if the number of projects / interval is large. If you have a large number of projects, we recommend filtering and querying by them individually.Also note that grouping by projects does not currently support timeseries interval responses and will instead be a sum of the projectover the entire period specified.

* `field` *(string)*

  REQUIRED

  **choices**:

  * `sum(quantity)
    sum(times_seen)`

  the `sum(quantity)` field is bytes for attachments, and all others the 'event' count for those types of events.

  `sum(times_seen)` sums the number of times an event has been seen. For 'normal' event types, this will be equal to `sum(quantity)` for now. For sessions, quantity will sum the total number of events seen in a session, while `times_seen` will be the unique number of sessions. and for attachments, `times_seen` will be the total number of attachments, while quantity will be the total sum of attachment bytes.

  * `sum(quantity)`
  * `sum(times_seen)`

* `statsPeriod` *(string)*

  This defines the range of the time series, relative to now. The range is given in a `<number><unit>` format. For example `1d` for a one day range. Possible units are `m` for minutes, `h` for hours, `d` for days and `w` for weeks. You must either provide a `statsPeriod`, or a `start` and `end`.

* `interval` *(string)*

  This is the resolution of the time series, given in the same format as `statsPeriod`. The default resolution is `1h` and the minimum resolution is currently restricted to `1h` as well. Intervals larger than `1d` are not supported, and the interval has to cleanly divide one day.

* `start` *(string)*

  This defines the start of the time series range as an explicit datetime, either in UTC ISO8601 or epoch seconds. Use along with `end` instead of `statsPeriod`.

* `end` *(string)*

  This defines the inclusive end of the time series range as an explicit datetime, either in UTC ISO8601 or epoch seconds. Use along with `start` instead of `statsPeriod`.

* `project` *(array(undefined))*

  The ID of the projects to filter by.

  Use `-1` to include all accessible projects.

* `category` *(string)*

  **choices**:

  * `error
    transaction
    attachment
    replay
    profile
    profile_duration
    profile_duration_ui
    profile_chunk
    profile_chunk_ui
    monitor`

  Filter by data category. Each category represents a different type of data:

  * `error`: Error events (includes `default` and `security` categories)
  * `transaction`: Transaction events
  * `attachment`: File attachments (note: cannot be combined with other categories since quantity represents bytes)
  * `replay`: Session replay events
  * `profile`: Performance profiles
  * `profile_duration`: Profile duration data (note: cannot be combined with other categories since quantity represents milliseconds)
  * `profile_duration_ui`: Profile duration (UI) data (note: cannot be combined with other categories since quantity represents milliseconds)
  * `profile_chunk`: Profile chunk data
  * `profile_chunk_ui`: Profile chunk (UI) data
  * `monitor`: Cron monitor events

  - `error`
  - `transaction`
  - `attachment`
  - `replay`
  - `profile`
  - `profile_duration`
  - `profile_duration_ui`
  - `profile_chunk`
  - `profile_chunk_ui`
  - `monitor`

* `outcome` *(string)*

  **choices**:

  * `accepted
    filtered
    rate_limited
    invalid
    abuse
    client_discard
    cardinality_limited`

  See https\://docs.sentry.io/product/stats/ for more information on outcome statuses.

  * `accepted`
  * `filtered`
  * `rate_limited`
  * `invalid`
  * `abuse`
  * `client_discard`
  * `cardinality_limited`

* `reason` *(string)*

  The reason field will contain why an event was filtered/dropped.

### Scopes

You need to [authenticate via bearer auth token.](https://docs.sentry.io/api/auth.md)

`<auth_token>` requires one of the following scopes:

* `org:admin`
* `org:read`
* `org:write`

```
curl https://sentry.io/api/0/organizations/{organization_id_or_slug}/stats_v2/ \
 -H 'Authorization: Bearer <auth_token>'
```

RESPONSESCHEMA

```
Copied
{
  "start": "2022-02-14T19:00:00Z",
  "end": "2022-02-28T18:03:00Z",
  "intervals": [
    "2022-02-28T00:00:00Z"
  ],
  "groups": [
    {
      "by": {
        "outcome": "invalid"
      },
      "totals": {
        "sum(quantity)": 165665
      },
      "series": {
        "sum(quantity)": [
          165665
        ]
      }
    }
  ]
}
```

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
