---
title: "Add a new filter"
method: POST
path: "/filters"
tags: ["Filters"]
---

# Add a new filter

`POST /filters`

Adds a new filter, returns the ID upon success. Note that in the conditions JSON object only one first-level condition group is supported, and it must be glued with 'AND', and only two second level condition groups are supported of which one must be glued with 'AND' and the second with 'OR'. Other combinations do not work (yet) but the syntax supports introducing them in future. For more information, see the tutorial for <a href="https://pipedrive.readme.io/docs/adding-a-filter" target="_blank" rel="noopener noreferrer">adding a filter</a>.

## Query parameters

- `include_field_code` boolean

## Request body

- object
  - `name` string, required — The name of the filter
  - `conditions` object, required — The conditions of the filter as a JSON object. Please note that a maximum of 16 conditions is allowed per filter and `date` values must be supplied in the `YYYY-MM-DD` format. It requires a minimum structure as follows: `{"glue":"and","conditions":[{"glue":"and","conditions": [CONDITION_OBJECTS]},{"glue":"or","conditions":[CONDITION_OBJECTS]}]}`. Replace `CONDITION_OBJECTS` with JSON objects of the following structure: `{"object":"","field_id":"", "operator":"","value":"", "extra_value":""}` or leave the array empty. Depending on the object type you should use another API endpoint to get `field_id`. There are five types of objects you can choose from: `"person"`, `"deal"`, `"organization"`, `"product"`, `"activity"` and you can use these types of operators depending on what type of a field you have: `"IS NOT NULL"`, `"IS NULL"`, `"<="`, `">="`, `"<"`, `">"`, `"!="`, `"="`, `"LIKE '$%'"`, `"LIKE '%$%'"`, `"NOT LIKE '$%'"`. To get a better understanding of how filters work try creating them directly from the Pipedrive application.
  - `type` 'deals' | 'leads' | 'org' | 'people' | 'products' | 'activity' | 'projects', required — The type of filter to create

## Response `200`

Success

- object
  - `success` boolean — If the response is successful or not
  - `data` object
    - `id` integer — The ID of the filter
    - `name` string — The name of the filter
    - `filter_code` string, nullable — The system code of the filter
    - `is_editable` boolean — Whether the filter can be edited by the requesting user
    - `active_flag` boolean — The activity flag of the filter
    - `type` 'deals' | 'leads' | 'org' | 'people' | 'products' | 'activity' | 'projects'
    - `temporary_flag` boolean, nullable — Whether the filter is temporary
    - `user_id` integer — The user ID of the filter owner
    - `add_time` string — The date and time when the filter was added
    - `update_time` string, nullable — The date and time when the filter was last updated
    - `visible_to` '1' | '3' | '5' | '7' — The visibility group ID of the filter
    - `last_used_time` string, nullable — The date and time when the filter was last used
    - `custom_view_id` integer, nullable — The custom view ID linked to the filter
    - `conditions` object — The conditions object of a filter
      - `glue` 'and' — The top-level glue is always "and"
      - `conditions` object[] — The condition groups
        - `glue` 'and' | 'or' — The logical operator joining conditions within this group
        - `conditions` object[] — The individual conditions in this group
          - `object` string — The type of entity the condition applies to (e.g. "deal", "person")
          - `field_id` string — The ID of the field
          - `operator` string — The operator used in the condition (e.g. "=", "IS NOT NULL")
          - `value` string, nullable — The value of the condition
          - `extra_value` string, nullable — An extra value for conditions that require two values
          - `json_value_flag` boolean — Whether the value is JSON-encoded
          - `field_code` string, nullable — The code name of the field. Present when `include_field_code=true` is passed as a query parameter; `null` if the field code cannot be resolved

---

[API](https://skmtc.net/pipedrive/apis/pipedrive-api-v1.md) · [All operations](https://skmtc.net/pipedrive/apis/pipedrive-api-v1/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pipedrive/pipedrive-api-v1/revisions/bf863a979545/schema)
