---
title: "Exact counts for several filter sets in one request"
description: "Body: { queries: [{ key, filters: [{ field, op, value }] }] }, up to 48 queries of 20 filters each."
canonical_url: "https://twominutebilling.com/help/developers/api-reference/subscriptions/exact-counts-for-several-filter-sets-in-one-requ"
---
# Exact counts for several filter sets in one request

> Body: { queries: [{ key, filters: [{ field, op, value }] }] }, up to 48 queries of 20 filters each.

<api-operation method="POST" path="/v1/businesses/{biz}/subscriptions/count">
<template v-slot:docs="">

Body: `{ queries: [{ key, filters: [{ field, op, value }] }] }`, up to 48 queries of 20 filters each. Fields, operators and value shapes are exactly the list's `<field>[<op>]` filters (custom fields included), so a count agrees with the list its drill-down opens. Answers `{ object: "subscription_counts", counts: { <key>: n } }`. A read: no `Idempotency-Key` needed.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Business id (biz_…)
    </td>
  </tr>
</tbody>
</table>

## Headers

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        Idempotency-Key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Safely retry writes — repeats return the original response. If a write FAILED after it had already taken effect, that failure is what repeats: the key is spent, and a new attempt needs a new key.
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type; always <code>
        subscription_counts
      </code>
      
      . One of <code>
        subscription_counts
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        counts
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      The number of matching subscriptions for each query key.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      Counts keyed by query
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      Unknown field, operator or value shape
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload.
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl -X POST "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/subscriptions/count" \
  -H "Authorization: Bearer $TMBILLING_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

</template>

<template v-slot:response="">
<code-group>

```json [200 OK]
{
  "object": "subscription_counts",
  "counts": {
    "active": 412,
    "past_due": 9
  }
}
```

```json [400 Bad Request]
{
  "error": {
    "type": "invalid_request_error",
    "message": "Unknown field, operator or value shape"
  }
}
```

```json [409 Conflict]
{
  "error": {
    "type": "idempotency_error",
    "message": "Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload."
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
