> ## 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.

# Filter Object Data

Get filtered list of records for a requested object. This API is useful when you want to fetch a subset of records based on certain criteria.

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication, [click here](https://app.superleap.com/settings/apiAccess) to generate one
</ParamField>

<ParamField header="Content-Type" type="string" default="application/json" required>
  application/json
</ParamField>

### Path Parameters

<ParamField path="object_slug" type="string" required>
  The slug identifier for the object type you want to filter (e.g., "lead", "user", "opportunity")
</ParamField>

### Body

<ParamField body="query" type="object" required>
  Query object containing filter parameters

  <Expandable title="Properties">
    <ParamField body="fields" type="string[]">
      Specific fields to return in the response.

      <Expandable title="Example">
        ```json theme={null}
        ["name", "email", "phone", "created_at"]
        ```
      </Expandable>
    </ParamField>

    <ParamField body="filters" type="object">
      Filter conditions to apply to the query

      <Expandable title="Properties">
        <ParamField body="and" type="object[]">
          Array of conditions that must all be satisfied (AND logic)

          <Expandable title="Filter Condition">
            <ParamField body="field" type="string" required>
              Field name to apply filter on
            </ParamField>

            <ParamField body="operator" type="string" required>
              Comparison operator (see Filter Operators section for complete list)
            </ParamField>

            <ParamField body="value" type="any" required>
              Value to compare against
            </ParamField>

            <ParamField body="and" type="object[]">
              Nested AND conditions (can be used for complex filtering)
            </ParamField>

            <ParamField body="or" type="object[]">
              Nested OR conditions (can be used for complex filtering)
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="or" type="object[]">
          Array of conditions where at least one must be satisfied (OR logic)

          <Expandable title="Filter Condition">
            <ParamField body="field" type="string" required>
              Field name to apply filter on
            </ParamField>

            <ParamField body="operator" type="string" required>
              Comparison operator (see Filter Operators section for complete list)
            </ParamField>

            <ParamField body="value" type="any" required>
              Value to compare against
            </ParamField>

            <ParamField body="and" type="object[]">
              Nested AND conditions (can be used for complex filtering)
            </ParamField>

            <ParamField body="or" type="object[]">
              Nested OR conditions (can be used for complex filtering)
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="sort" type="object[]">
      Array of sort objects that define the order of results

      <Expandable title="Sort Object">
        <ParamField body="field" type="string" required>
          Field name to sort by
        </ParamField>

        <ParamField body="direction" type="string" required>
          Sort direction: "asc" (ascending) or "desc" (descending)
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="pagination" type="object">
      Pagination controls for the result set

      <Expandable title="Properties">
        <ParamField body="page" type="number" default="1">
          Page number to retrieve (starts at 1)
        </ParamField>

        <ParamField body="page_size" type="number" default="10">
          Number of records per page
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

### Example Request

```bash theme={null}
curl --location 'https://app.superleap.com/api/v1/org/objects/lead/filter' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERSECRETREDACTEDKEY' \
--data-raw '{
  "query": {
    "fields": ["created_at", "email", "external_id", "id", "name", "phone"],
    "filters": {
      "or": [
        {
          "and": [
            {
              "field": "email",
              "operator": "contains",
              "value": "ad"
            }
          ]
        },
        {
          "or": [
            {
              "field": "name",
              "operator": "contains",
              "value": "P"
            },
            {
              "field": "name",
              "operator": "starts_with",
              "value": "C"
            }
          ]
        }
      ]
    },
    "sort": [
      {
        "field": "name",
        "direction": "desc"
      }
    ],
    "pagination": {
      "page": 1,
      "page_size": 150
    }
  }
}'
```

### Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "records": [
      {
        "created_at": 1741267307472,
        "email": "cariappa2@gmail.com",
        "external_id": "I am external",
        "id": "cK2p5W_pL8b6BEh",
        "name": "Cariappa 2",
        "phone": "+91-9999999999"
      },
      {
        "created_at": 1741614402286,
        "email": null,
        "external_id": null,
        "id": "cK2p5W_mWCp7EHz",
        "name": "Cariappa",
        "phone": null
      },
      {
        "created_at": 1741348841428,
        "email": "asd2sadf@s.com",
        "external_id": "we",
        "id": "cK2p5W_rcZAmD55",
        "name": "Cariappa",
        "phone": null
      },
      {
        "created_at": 1741266340544,
        "email": "cariappa@gmail.com",
        "external_id": "asdf",
        "id": "cK2p5W_zz3t4dBH",
        "name": "Cariappa",
        "phone": "+91-9999999999"
      },
      {
        "created_at": 1741616420041,
        "email": null,
        "external_id": "Sdfasdf",
        "id": "cK2p5W_UssVtMdf",
        "name": "Car",
        "phone": null
      }
    ]
  }
}
```

### Filter Operators

| Operator        | Description                         | Example                                                                    |
| --------------- | ----------------------------------- | -------------------------------------------------------------------------- |
| `eq`            | Equal to                            | `{"field": "status", "operator": "eq", "value": "active"}`                 |
| `neq`           | Not equal to                        | `{"field": "status", "operator": "neq", "value": "deleted"}`               |
| `gt`            | Greater than                        | `{"field": "amount", "operator": "gt", "value": 1000}`                     |
| `lt`            | Less than                           | `{"field": "amount", "operator": "lt", "value": 5000}`                     |
| `gte`           | Greater than or equal to            | `{"field": "amount", "operator": "gte", "value": 1000}`                    |
| `lte`           | Less than or equal to               | `{"field": "amount", "operator": "lte", "value": 5000}`                    |
| `in`            | Value is in array                   | `{"field": "status", "operator": "in", "value": ["active", "pending"]}`    |
| `nin`           | Value is not in array               | `{"field": "status", "operator": "nin", "value": ["deleted", "archived"]}` |
| `like`          | Pattern matching (case sensitive)   | `{"field": "name", "operator": "like", "value": "%Smith%"}`                |
| `ilike`         | Pattern matching (case insensitive) | `{"field": "name", "operator": "ilike", "value": "%smith%"}`               |
| `starts_with`   | String starts with                  | `{"field": "name", "operator": "starts_with", "value": "Car"}`             |
| `ends_with`     | String ends with                    | `{"field": "email", "operator": "ends_with", "value": "@gmail.com"}`       |
| `contains`      | String contains                     | `{"field": "name", "operator": "contains", "value": "John"}`               |
| `not_contains`  | String does not contain             | `{"field": "name", "operator": "not_contains", "value": "Deleted"}`        |
| `between`       | Value is between (inclusive)        | `{"field": "amount", "operator": "between", "value": [1000, 5000]}`        |
| `is_empty`      | Field is null or empty              | `{"field": "notes", "operator": "is_empty"}`                               |
| `not_empty`     | Field is not null and not empty     | `{"field": "email", "operator": "not_empty"}`                              |
| `exists`        | Field exists                        | `{"field": "custom_field", "operator": "exists"}`                          |
| `not_exists`    | Field does not exist                | `{"field": "custom_field", "operator": "not_exists"}`                      |
| `global_search` | Search across multiple fields       | `{"field": "", "operator": "global_search", "value": "search term"}`       |
| `leq`           | Lower or equal (legacy)             | `{"field": "priority", "operator": "leq", "value": 3}`                     |
| `nleq`          | Not lower or equal (legacy)         | `{"field": "priority", "operator": "nleq", "value": 3}`                    |
