---
title: "Count deals matching a backtest selection"
method: POST
path: "/api/policy_version/{version}/backtest/count"
tags: ["Policy Backtests"]
---

# Count deals matching a backtest selection

`POST /api/policy_version/{version}/backtest/count`

## Request

- Base URL: `https://app.herondata.io`
- URL: `https://app.herondata.io/api/policy_version/{version}/backtest/count`
- Auth: API key in header `x-api-key`

Return the matching count and the count retained after applying the run limit.

## Path parameters

- `version` integer, required

## Request body

- BacktestSelectionSchema
  - `check_filter` BacktestCheckFilter
    - `check_identity` string
    - `result` 'passed' | 'failed' | 'review_required' | 'missing_data' | 'execution_error' | 'skipped', required
    - `section_heron_id` string, required
  - `end_user_heron_ids` string[], nullable: Specific deals to run, in request order; cannot be combined with selection filters
  - `limit` integer, nullable: Deals to include, at most 4000 (default 200)
  - `source_filter` BacktestSourceFilter
    - `names` string[]: Source names sent through the API, matched case-insensitively
    - `sender_addresses` string[]: Addresses that sent the deal's first email, matched case-insensitively
    - `sender_domains` string[]: Domains that sent the deal's first email, like broker.com
  - `window_days` integer, nullable: How far back to look for deals; the account's configured window when omitted
  - `window_end` string, date-time, nullable: Exclusive deal creation bound; requires window_start and is clamped to now when in the future
  - `window_start` string, date-time, nullable: Inclusive deal creation bound; requires window_end and cannot be combined with window_days
  - `with_policy_result` string[], nullable: Only deals whose last policy result was one of ['failed', 'missing_data', 'passed', 'review_required']; omit for all

## Response `200`

Matching and selected deal counts

- BacktestDealCountSchema
  - `matching_deal_count` integer
  - `selected_deal_count` integer

## Other responses

- `404`: Policy version not found
- `422`: Invalid deal selection

## Changes

- **2026-11-03** `bd8008e49534`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/herondata/apis/heron-data-api/changes/api/policy_version/:version/backtest/count/post.md)

---

[API](https://skmtc.dev/herondata/apis/heron-data-api.md) - [All operations](https://skmtc.dev/herondata/apis/heron-data-api/llms.txt) - [OpenAPI document](https://skmtc.dev/herondata/apis/heron-data-api/revisions/4f9eaaa87f09?raw)
