> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superleap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Count Query Results

> Returns the number of rows a Superleap Object Query would produce, respecting the query's LIMIT.

## Overview

Companion endpoint to [Execute](/api-reference/reports/execute): instead of returning records, it returns how many rows the query produces. The count respects the query's `LIMIT`, and execution stops as soon as the limit is reached - which makes capped counting on very large objects fast.

Use it for:

* **Tile counts** - `SELECT DISTINCT id ... LIMIT 100001` returns in a fraction of the time of a full `COUNT(DISTINCT id)` aggregate when the cap is reached. If the result equals the limit, display it as "1,00,000+"; if it is below the limit, it is already the exact count.
* **Existence / threshold checks** - "are there at least N matching records?" without scanning everything.

The request body, authentication, and query rules are identical to [Execute](/api-reference/reports/execute), including the relationship guidance (use `DISTINCT id` whenever a virtual relation appears in the query, since the join can return one row per child).

## Request Body

<ParamField body="query" type="string" required>
  Raw PostgreSQL `SELECT` query. Include a `LIMIT` - it caps both the scan and the returned count.
</ParamField>

<ParamField body="slug" type="string" required>
  Base CRM object slug matching the query's top-level `FROM`.
</ParamField>

## Example Request

```bash theme={null}
curl --location 'https://<domain>.superleap.com/api/v1/reports/count' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer SUPERSECRETREDACTEDKEY' \
  --data @- <<'JSON'
{
  "query": "SELECT DISTINCT id FROM lead WHERE associated_opportunities.stage = 'Open' LIMIT 100001",
  "slug": "lead"
}
JSON
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "count": 100001
  }
}
```

Here the count equals the limit, so the true total is *at least* 100,001 - render it as a capped value ("1,00,000+") or follow up with an exact aggregate if needed.
