--- title: "Filter Recommendation Responses" slug: "recommendation-api-filtering-responses" description: "Explains the Recommendation API's filter query parameter syntax, operators, dynamic filters, and AND/OR logic for refining recommendation results precisely." tags: ["filter recommendation", "recommendation api responses"] updated: 2026-11-16T16:07:03Z published: 2026-11-16T16:07:03Z canonical: "academy.insiderone.com/recommendation-api-filtering-responses" --- > ## Documentation Index > Fetch the complete documentation index at: https://academy.insiderone.com/llms.txt > Use this file to discover all available pages before exploring further. # Filter Recommendation Responses Filtering allows you to refine recommendation results to match your users' needs and preferences. Common use cases include: - **Exclude already-viewed products** - Don't recommend products the user has seen - **Price range filtering** - Show only products within budget - **Category/brand filtering** - Focus on specific product types - **Stock filtering** - Only recommend in-stock items - **Attribute filtering** - Filter by custom product attributes (color, size, rating, etc.) This increases relevance, improves user experience, and boosts conversion rates. > [!NOTE] > **Note**: On **/v2/bundle**, the filter parameter applies to every slot, including pinned products. A pinned product that does not match the filter is removed and is not replaced. See [Get Bundle Recommendations](/v1/docs/get-bundle-recommendations). ## Basic Syntax ```plaintext https://recommendation.api.useinsider.com/v2/{algorithm}?...\&filter=[{field}][{operator}][{value}] ``` Here is an example with a single filter that returns products with prices greater than 100 USD: ```plaintext ?filter=[price.USD][>][100] ``` ## Multiple Filters You can pass multiple filter parameters to combine conditions. Each condition is chained together via an **asterisk (*)**. #### Syntax ```plaintext ?filter=[field1][operator1][value1]*[field2][operator2][value2] ``` ### How Multiple Filters work Multiple filters are **combined with AND logic** - products must match ALL conditions to be included. #### Example 1: Exclude current product + filter by category ```plaintext ?filter=[item_id][!=][PRODUCT_ID]*[category][~][Shoes] ``` This filter returns products that are NOT PRODUCT_ID AND contain "Shoes" in the category. #### Example 2: Price range + in stock ```plaintext ?filter=[price.USD][>][50]*[price.USD][<][200]*[in_stock][=][1] ``` This filter returns products between $50-$200 AND in stock. ## Operator Reference | Operator Name | Symbol | Alias | Description | Example | | --- | --- | --- | --- | --- | | Equal To | = | is | Exact match on field value | [color][=][Blue] or [brand][=][Niki] | | Not Equal To | != | nis | Excludes products with matching field value | [color][!=][Red] (exclude red products) | | Greater Than | > | gt | Field value greater than the specified value | [price.USD][>][100] or [rating][>][3.5] | | Greater Than or Equal | >= | gte | Field value greater than or equal to the specified value | [price.EUR][>=][150] or [rating][>=][4] | | Less Than | < | lt | Field value less than the specified value | [price.EUR][<][150] or [stock_count][<][5] | | Less Than or Equal | <= | lte | Field value less than or equal to the specified value | [price.EUR][<=][150] or [created_at][<=][now-7d] | | Contains | ~ | ctn | Field contains the specified value (text search) | [category][~][Shoes] or [name][~][Niki Air] | | Does Not Contain | !~ | nctn | Field does not contain the specified value | [category][!~][Clearance] | | Between | >< | btw | Field value falls within a range. Format: [field][><][lower_bound:upper_bound] | [price.USD][><][50:200] | | Not Between | >!< | nbtw | Field value falls outside a range | [price.USD][>!<][50:200] (exclude $50-$200 range) | | Exists | ? | xst | Check if a field exists (value=1) or does not exist (value=0) | [price.USD][?][1] (products have USD price) | ## Date Field Values Insider One is designed to parse every filter value provided for date fields. If a simplified date expression fails to parse, the system will use it as a raw literal value. This allows you to use literal dates (e.g., "2022-09-30 15:45:00") directly in your date filters. The date fields available for filtering are: created_at and modified_at. ### Operator Compatibility Date fields are supported by every operator except for Between (><) and Not Between (>!<). This limitation is due to the **Between** operator using a **colon (:)** to separate the lower and upper bounds, which conflicts with the colon present in standard date/time formats (e.g., 2022-09-30 15:45:00). The most appropriate operators for date fields are: - After (>) - Before (<) - Is (=) - Is Not (!=) ### Relative Date Filtering Date filters also support relative unit values, allowing you to easily filter based on time relative to the current moment (now). - **Anchor**: now - **Units**: w (week), d (day), h (hour) - **Modifiers**: Use + to add units or - to subtract units. You can see the examples below: | Scenario | Filter Expression | | --- | --- | | Get products that were created last week | [created_at][>][now-1w] | | Get products created up to 2 days ago | [created_at][<=][now-2d] | ## Multiple Value Filtering (In / Not-In Filter Behavior) Match fields against multiple values by separating them with: ```plaintext || ``` Supported by all operators except between and not between. **Examples:** - Get products from multiple brands: ```plaintext ?filter=[brand][=][Niki||Abiba||Pamu] ``` - Exclude multiple colors: ```plaintext ?filter=[color][!=][Red||Green||Blue] ``` Get products with categories containing any of these terms: ```plaintext ?filter=[category][~][Shoes||Boots||Sneakers] ``` ## Advanced Filtering with AND/OR Combine multiple filters using logical operators within a single filter parameter. - **And (*)** = both conditions must be true - **Or (|)** = either condition can be true #### Examples - **AND** Example: Price range AND brand ```plaintext ?filter=([price.USD][>][100]*[brand][=][Niki]) ``` - **OR** Example: Multiple categories ```plaintext ?filter=([category][~][Shoes]|[category][~][Boots]) ``` - Complex: (A **AND** B) **OR** C Get products that are either (cheap AND in stock) OR highly rated: ```plaintext ?filter=(([price.USD][<][50]*[in_stock][=][1])|[rating][>=][5]) ``` > [!NOTE] > You can also use multiple parameters to achieve AND logic more simply: > > ```plaintext > ?filter=[price.USD][<][50]&filter=[in_stock][=][1]&filter=[rating][>=][5] > ``` > > This is often clearer than using complex parentheses. ## Dynamic Filters Use ${value} to reference the source product's field value in your filter. The expression is computed at request time using the actual product data. Supported Expressions - ${value} - Use the product's field value as-is - ${value*1.2} - Multiply by 1.2 (20% increase) - ${value*0.8} - Multiply by 0.8 (20% decrease) - ${value*0.8}:${value*1.3} - Range with dynamic bounds #### Examples - Match the product's category dynamically: ```plaintext ?categoryList=${value}&productId=PRODUCT_ID ``` If the product has a category "Shoes", recommendations are filtered to "Shoes" only. - Show products in a similar price range (±30%): ```plaintext ?productId=PRODUCT_ID&filter=[price.EUR][><][${value}:${value*1.3}] ``` If the product costs €100, it shows products priced €100-€130. ## Filter Validation Errors When filters are invalid, the API returns specific error messages with HTTP status codes: ### Format & Syntax Errors (400) | Error | Cause | How to fix | | --- | --- | --- | | "Filter is not in correct format." | Missing brackets, unmatched parentheses, invalid syntax | Check that every condition has three bracketed parts, [field][operator][value], that each opening parenthesis has a closing one, and that conditions are joined with * (AND) or \| (OR). | | "Depth of nested filters is greater than 4." | Too many nesting levels: ((((filter)))) | Remove parentheses you don't need. Conditions chained with the same operator, such as A*B*C, count as one level. To combine conditions with AND, you can also send each one as a separate filter parameter. | | "Number of filters is greater than 40." | Too many filter conditions total | Reduce the number of conditions to 40 or fewer across all filter parameters in the request. To match several values of the same field, use one condition with \|\| (for example, [brand][=][Niki\|\|Abiba]) instead of one condition per value. | ### Field Errors (400 or 422) | Error | HTTP | Cause | How to fix | | --- | --- | --- | --- | | "Entered field name is invalid." | 400 | Field doesn't exist in product data | Check the field name against your catalog's attributes on the Product Attributes page. Use the exact attribute name, and use price. (for example, price.USD) for prices. | | "The field '%s' in dynamic filter was not found in the product." | 422 | Field missing in source product (dynamic filters only) | The product in productId has no value for this field. Add the attribute to that product in your catalog, or use a fixed value instead of ${value} for requests about products that don't have it. | | "Field $$$ is not a filterable product attribute." | 400 | Field marked non-filterable in configuration | Turn on the Filterable toggle for this attribute on the Product Attributes page, then send the request again. | ### Operator Errors (400) | Error | Cause | How to fix | | --- | --- | --- | | "operator field is invalid." | Unknown operator | Use: =, !=, >, <, >=, <=, ~, !~, ><, >!<, ? | | "For the $$$ field, operator field is not valid by field type." | Operator incompatible with field type (e.g., ~ on numeric field) | Use an operator that fits the field's data type: Contains (~) and Does Not Contain (!~) for text fields, and comparison operators (>, <, >=, <=, ><, >!<) for numeric and date fields. Between and Not Between don't work on date fields. Check the field's data type on the Product Attributes page. | | "Operator $$$ is not allowed for dynamic filters." | EXIST/EXIST_ALIAS not allowed with ${value} | Don't use Exists (? or xst) with ${value}. Use another operator, such as = or ><, or use Exists with a fixed value of 1 or 0. | ### Value Errors (400 or 422) | Error | HTTP | Cause | How to fix | | --- | --- | --- | --- | | "For the $$$ field, entered value is empty." | 422 | Blank or null value | Enter a value in the third bracket. To check only whether a field has a value, use Exists, for example [price.USD][?][1]. | | "For the $$$ field, value length is invalid." | 400 | Exceeds limits | The value length limit: 100 chars for text search, 340 for others | | "Value for the field $$$ is invalid." | 400 | Invalid range format | Use **lower:upper** for **><** operator | | "For the $$$ field, value type is invalid." | 400 | Type mismatch (non-numeric on numeric field) | Send a plain number for numeric fields, without currency signs or units, for example [price.USD][>][100]. in_stock takes 0 or 1, and rating takes a number from 0 to 10. | ### Field-Specific Validations (400) | Field | Error | Cause | | --- | --- | --- | | in_stock | "Value is invalid for in_stock filter..." | 0 or 1 only | ### Dynamic Filter Errors (400) | Error | Cause | How to fix | | --- | --- | --- | | "Parameters productId and locale must be provided when dynamic value is used." | Using **${value}** without providing **productId** or **locale** | Provide **productId** or **locale** when using **${value}** | | "Product not found" | Specified **productId** doesn't exist | Check that the product exists in your catalog for the locale in the request. Search for the item ID in Catalog Manager with that locale selected. A product can exist in one locale and not another. | ## Limitations | Constraint | Limit | Notes | | --- | --- | --- | | Filter depth | 4 levels | Maximum nesting depth for parentheses | | Total filters | 40 filters | Total number of filter conditions in one request | | N-gram value length | 100 characters | For text search on **item_id**, **name**, **image_url** | | Other field value length | 340 characters | For text search on other fields |