---
title: "Count Flow Runs"
method: POST
path: "/api/flow_runs/count"
tags: ["Flow Runs"]
---

# Count Flow Runs

`POST /api/flow_runs/count`

Query for flow runs.

## Headers

- `x-prefect-api-version` string

## Request body

- BodyCountFlowRunsFlowRunsCountPost
  - `flows` FlowFilter — Filter for flows. Only flows matching all criteria will be returned.
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` FlowFilterId — Filter by `Flow.id`.
      - `any_` string[] — A list of flow ids to include
    - `deployment` FlowFilterDeployment — Filter by flows by deployment
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `is_null_` boolean — If true, only include flows without deployments
    - `name` FlowFilterName — Filter by `Flow.name`.
      - `any_` string[] — A list of flow names to include
      - `like_` string — A case-insensitive partial match. For example, passing 'marvin' will match 'marvin', 'sad-Marvin', and 'marvin-robot'.
    - `tags` FlowFilterTags — Filter by `Flow.tags`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `all_` string[] — A list of tags. Flows will be returned only if their tags are a superset of the list
      - `is_null_` boolean — If true, only include flows without tags
  - `flow_runs` FlowRunFilter — Filter flow runs. Only flow runs matching all criteria will be returned
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` FlowRunFilterId — Filter by `FlowRun.id`.
      - `any_` string[] — A list of flow run ids to include
      - `not_any_` string[] — A list of flow run ids to exclude
    - `name` FlowRunFilterName — Filter by `FlowRun.name`.
      - `any_` string[] — A list of flow run names to include
      - `like_` string — A case-insensitive partial match. For example, passing 'marvin' will match 'marvin', 'sad-Marvin', and 'marvin-robot'.
    - `tags` FlowRunFilterTags — Filter by `FlowRun.tags`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `all_` string[] — A list of tags. Flow runs will be returned only if their tags are a superset of the list
      - `is_null_` boolean — If true, only include flow runs without tags
    - `deployment_id` FlowRunFilterDeploymentId — Filter by `FlowRun.deployment_id`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `any_` string[] — A list of flow run deployment ids to include
      - `is_null_` boolean — If true, only include flow runs without deployment ids
    - `work_queue_name` FlowRunFilterWorkQueueName — Filter by `FlowRun.work_queue_name`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `any_` string[] — A list of work queue names to include
      - `is_null_` boolean — If true, only include flow runs without work queue names
    - `state` FlowRunFilterState — Filter by `FlowRun.state_type` and `FlowRun.state_name`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `type` FlowRunFilterStateType — Filter by `FlowRun.state_type`.
        - `any_` StateType[] — A list of flow run state types to include
      - `name` FlowRunFilterStateName — Filter by `FlowRun.state_name`.
        - `any_` string[] — A list of flow run state names to include
    - `flow_version` FlowRunFilterFlowVersion — Filter by `FlowRun.flow_version`.
      - `any_` string[] — A list of flow run flow_versions to include
    - `start_time` FlowRunFilterStartTime — Filter by `FlowRun.start_time`.
      - `before_` string, date-time — Only include flow runs starting at or before this time
      - `after_` string, date-time — Only include flow runs starting at or after this time
      - `is_null_` boolean — If true, only return flow runs without a start time
    - `expected_start_time` FlowRunFilterExpectedStartTime — Filter by `FlowRun.expected_start_time`.
      - `before_` string, date-time — Only include flow runs scheduled to start at or before this time
      - `after_` string, date-time — Only include flow runs scheduled to start at or after this time
    - `next_scheduled_start_time` FlowRunFilterNextScheduledStartTime — Filter by `FlowRun.next_scheduled_start_time`.
      - `before_` string, date-time — Only include flow runs with a next_scheduled_start_time or before this time
      - `after_` string, date-time — Only include flow runs with a next_scheduled_start_time at or after this time
    - `parent_flow_run_id` FlowRunFilterParentFlowRunId — Filter for subflows of a given flow run
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `any_` string[] — A list of parent flow run ids to include
    - `parent_task_run_id` FlowRunFilterParentTaskRunId — Filter by `FlowRun.parent_task_run_id`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `any_` string[] — A list of flow run parent_task_run_ids to include
      - `is_null_` boolean — If true, only include flow runs without parent_task_run_id
    - `idempotency_key` FlowRunFilterIdempotencyKey — Filter by FlowRun.idempotency_key.
      - `any_` string[] — A list of flow run idempotency keys to include
      - `not_any_` string[] — A list of flow run idempotency keys to exclude
  - `task_runs` TaskRunFilter — Filter task runs. Only task runs matching all criteria will be returned
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` TaskRunFilterId — Filter by `TaskRun.id`.
      - `any_` string[] — A list of task run ids to include
    - `name` TaskRunFilterName — Filter by `TaskRun.name`.
      - `any_` string[] — A list of task run names to include
      - `like_` string — A case-insensitive partial match. For example, passing 'marvin' will match 'marvin', 'sad-Marvin', and 'marvin-robot'.
    - `tags` TaskRunFilterTags — Filter by `TaskRun.tags`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `all_` string[] — A list of tags. Task runs will be returned only if their tags are a superset of the list
      - `is_null_` boolean — If true, only include task runs without tags
    - `state` TaskRunFilterState — Filter by `TaskRun.type` and `TaskRun.name`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `type` TaskRunFilterStateType — Filter by `TaskRun.state_type`.
        - `any_` StateType[] — A list of task run state types to include
      - `name` TaskRunFilterStateName — Filter by `TaskRun.state_name`.
        - `any_` string[] — A list of task run state names to include
    - `start_time` TaskRunFilterStartTime — Filter by `TaskRun.start_time`.
      - `before_` string, date-time — Only include task runs starting at or before this time
      - `after_` string, date-time — Only include task runs starting at or after this time
      - `is_null_` boolean — If true, only return task runs without a start time
    - `subflow_runs` TaskRunFilterSubFlowRuns — Filter by `TaskRun.subflow_run`.
      - `exists_` boolean — If true, only include task runs that are subflow run parents; if false, exclude parent task runs
    - `flow_run_id` TaskRunFilterFlowRunId — Filter by `TaskRun.flow_run_id`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `any_` string[] — A list of task run flow run ids to include
      - `is_null_` boolean — Filter for task runs with None as their flow run id
  - `deployments` DeploymentFilter — Filter for deployments. Only deployments matching all criteria will be returned.
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` DeploymentFilterId — Filter by `Deployment.id`.
      - `any_` string[] — A list of deployment ids to include
    - `name` DeploymentFilterName — Filter by `Deployment.name`.
      - `any_` string[] — A list of deployment names to include
      - `like_` string — A case-insensitive partial match. For example, passing 'marvin' will match 'marvin', 'sad-Marvin', and 'marvin-robot'.
    - `paused` DeploymentFilterPaused — Filter by `Deployment.paused`.
      - `eq_` boolean — Only returns where deployment is/is not paused
    - `is_schedule_active` DeploymentFilterIsScheduleActive — Legacy filter to filter by `Deployment.is_schedule_active` which is always the opposite of `Deployment.paused`.
      - `eq_` boolean — Only returns where deployment schedule is/is not active
    - `tags` DeploymentFilterTags — Filter by `Deployment.tags`.
      - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
      - `all_` string[] — A list of tags. Deployments will be returned only if their tags are a superset of the list
      - `is_null_` boolean — If true, only include deployments without tags
    - `work_queue_name` DeploymentFilterWorkQueueName — Filter by `Deployment.work_queue_name`.
      - `any_` string[] — A list of work queue names to include
  - `work_pools` WorkPoolFilter — Filter work pools. Only work pools matching all criteria will be returned
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` WorkPoolFilterId — Filter by `WorkPool.id`.
      - `any_` string[] — A list of work pool ids to include
    - `name` WorkPoolFilterName — Filter by `WorkPool.name`.
      - `any_` string[] — A list of work pool names to include
    - `type` WorkPoolFilterType — Filter by `WorkPool.type`.
      - `any_` string[] — A list of work pool types to include
  - `work_pool_queues` WorkQueueFilter — Filter work queues. Only work queues matching all criteria will be returned
    - `operator` 'and_' | 'or_' — Operators for combining filter criteria.
    - `id` WorkQueueFilterId — Filter by `WorkQueue.id`.
      - `any_` string[] — A list of work queue ids to include
    - `name` WorkQueueFilterName — Filter by `WorkQueue.name`.
      - `any_` string[] — A list of work queue names to include
      - `startswith_` string[] — A list of case-insensitive starts-with matches. For example, passing 'marvin' will match 'marvin', and 'Marvin-robot', but not 'sad-marvin'.

## Response `200`

Successful Response

- integer

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/prefecthq/apis/untitled-api-2.md) · [All operations](https://skmtc.net/prefecthq/apis/untitled-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/prefecthq/untitled-api-2/versions/29ba6c4f8837/schema)
