---
title: Count cases
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Case Management
---

# Count cases{% #count-cases %}

{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                         |
| ----------------- | ---------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/cases/count |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/cases/count |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/cases/count      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/cases/count      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/cases/count  |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/cases/count     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/cases/count |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/cases/count |

### Overview

Returns case counts, optionally grouped by one or more fields (for example, status, priority). Supports a query filter to narrow the scope.

OAuth apps require the `cases_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#case-management) to access this endpoint.



### Arguments

#### Query Strings

| Name         | Type    | Description                         |
| ------------ | ------- | ----------------------------------- |
| query_filter | string  | Filter query for cases.             |
| group_bys    | string  | Comma-separated fields to group by. |
| limit        | integer | Maximum facet values to return.     |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response containing the total number of cases matching a query, optionally grouped by specified fields.

| Parent field | Field                          | Type     | Description                                                                                 |
| ------------ | ------------------------------ | -------- | ------------------------------------------------------------------------------------------- |
|              | data [*required*]         | object   | Data object containing the count results, including per-field group breakdowns.             |
| data         | attributes [*required*]   | object   | Attributes for the count response, including the total count and optional facet breakdowns. |
| attributes   | groups [*required*]       | [object] | List of facet groups, one per field specified in `group_bys`.                               |
| groups       | group [*required*]        | string   | The name of the field being grouped on (for example, `status` or `priority`).               |
| groups       | group_values [*required*] | [object] | Values within this group.                                                                   |
| group_values | count [*required*]        | int64    | Count of cases for this value.                                                              |
| group_values | value [*required*]        | string   | The group value.                                                                            |
| data         | id [*required*]           | string   | Count response identifier.                                                                  |
| data         | type [*required*]         | string   | Count resource type.                                                                        |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "groups": [
        {
          "group": "status",
          "group_values": [
            {
              "count": 42,
              "value": "OPEN"
            }
          ]
        }
      ]
    },
    "id": "count-result-001",
    "type": "count"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl command curl -X GET "https://api.datadoghq.com/api/v2/cases/count" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" 
                
{% /tab %}
