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

# Create filter

> Create a new filter by specifying the field, operator and type

This endpoint creates a new filter for use in stream transformations.

Filters support comparison operators (`=`, `!=`, `>`, `>=`, `<`, `<=`), the `in` operator for matching against arrays or data sources, the `exists` operator for field presence checks, and compound AND/OR logic for complex conditions.

<Note>
  See the [Filter Syntax](/datastreams/filters) documentation for complete details on all operators, nested conditions, and examples.
</Note>

## Example Filter with Data Source

```json theme={null}
{
    "filter": {
        "field": "token_address",
        "operator": "in",
        "data_source_id": "3123712-aqw1-asdg-0293-1f48914e1e3f"
    }
}
```

## Example Filter with Array Values

```json theme={null}
{
    "filter": {
        "field": "token_address",
        "operator": "in",
        "value": [
            "0x1234567890abcdef1234567890abcdef12345678",
            "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
        ]
    }
}
```

## Example Compound Filter

```json theme={null}
{
    "filter": {
        "op": "AND",
        "conditions": [
            {
                "field": "blockchain",
                "operator": "=",
                "value": "ethereum"
            },
            {
                "field": "value",
                "operator": ">",
                "value": "1000000000000000000"
            }
        ]
    }
}
```

## Supported Operators

| Operator | Description                   | Example Value             |
| :------- | :---------------------------- | :------------------------ |
| `=`      | Equals                        | `"ethereum"`              |
| `!=`     | Not equals                    | `"pending"`               |
| `>`      | Greater than                  | `1000000`                 |
| `>=`     | Greater than or equal         | `18000000`                |
| `<`      | Less than                     | `50000`                   |
| `<=`     | Less than or equal            | `100`                     |
| `in`     | Value in array or data source | `["ethereum", "polygon"]` |
| `exists` | Field exists or doesn't exist | `true` or `false`         |

## Old Filter Syntax (Deprecated)

<Warning>
  The old filter syntax with `"type": "data_source"` and uppercase operators is deprecated. We recommend using the new syntax shown above.
</Warning>

```json theme={null}
{
    "filter": {
        "field": "token_address",
        "operator": "IN",
        "type": "data_source",
        "data_source_id": "3123712-aqw1-asdg-0293-1f48914e1e3f"
    }
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Filter Syntax" icon="filter" href="/datastreams/filters">
    Learn how to filter streams with complex conditions
  </Card>
</CardGroup>


## OpenAPI

````yaml /_openapi/data-transformation-api.json POST /api/v1/streams/data-management/filters
openapi: 3.1.0
info:
  title: Allium API
  version: 0.1.0
servers:
  - url: https://api.allium.so
security: []
paths:
  /api/v1/streams/data-management/filters:
    post:
      tags:
        - STREAMS
        - DATA-MANAGEMENT
        - FILTERS
      summary: Filter
      description: Create a new filter by specifying the field, operator and type
      operationId: create_filter_api_v1_streams_data_management_filters_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilterRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseWithID'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyBearer: []
components:
  schemas:
    FilterRequest:
      properties:
        filter:
          type: object
          title: Filter
      type: object
      required:
        - filter
      title: FilterRequest
    ResponseWithID:
      properties:
        message:
          type: string
          title: Message
        result_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Result Id
      type: object
      required:
        - message
      title: ResponseWithID
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyBearer:
      type: apiKey
      in: header
      name: X-API-KEY

````