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

# Filter

> Selectively include or exclude objects from a collection based on field values

The Filter command (Command Type: 1004) selectively includes or excludes objects from a collection based on specific field values. It supports both allowlist and blocklist filtering modes.

## Overview

The Filter command provides functionality for:

* Including only objects whose field value matches the filter list
* Excluding objects whose field value matches the filter list
* Filtering by string, number, or boolean values

## Command Type

**Command Type ID:** 1004

## Parameters

| Parameter   | Type                               | Description                                                                            | Required |
| ----------- | ---------------------------------- | -------------------------------------------------------------------------------------- | -------- |
| **filter**  | Array of string / number / boolean | Defines the set of values to be matched against the key                                | Yes      |
| **include** | boolean                            | If `true`, returns only items matching the filter. If `false`, excludes matching items | Yes      |
| **key**     | string                             | Specifies the field in each object used for filtering                                  | Yes      |

## Usage Examples

### Include Only Specific Statuses

```json theme={null}
{
  "command": "filter",
  "params": {
    "key": "status",
    "filter": ["active", "pending"],
    "include": true
  }
}
```

### Exclude Specific IDs

```json theme={null}
{
  "command": "filter",
  "params": {
    "key": "id",
    "filter": [101, 202, 303],
    "include": false
  }
}
```

### Filter by Boolean Flag

```json theme={null}
{
  "command": "filter",
  "params": {
    "key": "isVisible",
    "filter": [true],
    "include": true
  }
}
```

## Common Use Cases

* **Status Filtering**: Keep only records in specific states (e.g. `active`, `live`)
* **ID Exclusion**: Remove known irrelevant or blacklisted IDs
* **Feature Flagging**: Filter based on boolean feature flags in the data

## Related Commands

* [Distinct](/stream/commands/parse/distinct) - Remove duplicates after filtering
* [Json Path](/stream/commands/parse/json-path) - Extract specific fields from filtered results
* [Key Mapping](/stream/commands/parse/key-mapping) - Remap fields after filtering
