# Product Filters

Configure the filters shoppers use to narrow product listings.

Use these endpoints to configure product filters for storefront listings. Reads require `read_products`; creating, updating, reordering, or deleting a filter requires `write_products`.

Built-in filters cover price, availability, sale status, vendor, brand, categories, tags, rating (`rating`: the average of a product's approved reviews, 1 to 5, as a range) and discount (`discount`: the whole percent a running sale takes off a product's regular price in the shopper's currency, 0 without a sale, as a range). You can change their labels, enabled state, and order; their filter behavior is fixed. On a storefront listing, an enabled filter appears only when it can narrow that listing's results (for example, no price filter when every product has one price); an applied filter always appears. To add a filter, list eligible attribute or metafield sources first. Each source lists its compatible filter and display types and a recommended configuration. An app can use only metafield definitions it can read, and product and variant metafields have distinct filter keys. Configuration endpoints return base-language labels. [Product filter translations](/store-api/translations/product-filters) read and write only `label` for an enabled non-default locale and additionally require `read_translations` or `write_translations`. Labels accept up to 100 characters; an empty string removes a translation. Storefront listings show the translated heading and each choice's translated label from its source; a heading without a translation shows its base-language label. Filter keys and choice values remain unchanged. Built-in yes/no, availability, and sale-state phrases use Storefront Messages, including per-language overrides.

For an update, send that definition’s current `revision`. For a reorder, fetch the unfiltered list, then send its top-level `revision` and every definition ID, including disabled ones. A stale revision returns `409 FILTER_REVISION_STALE`. Every filter has its own position. Reordering changes the revision of each definition whose position moves, so fetch the list again before updating one. A `sort_order` on create or update places that one filter at the position and shifts the others; past the end it goes last.

Configuration changes publish webhooks: `product_filters/create`, `product_filters/update` (with `changed_fields`; saving unchanged values publishes nothing), `product_filters/delete` (also when uninstalling the app that owns a filter's metafield definition deletes the filter) and one `product_filters/reorder` per changed order (a reorder, a filter moved with `sort_order`, or a filter added in front of others), carrying every filter in the new order and the new list revision. Deleting a filter with label translations also sends `product_filters/translations/delete` per language; deliveries can arrive in any order. Label translations publish `product_filters/translations/update` and `product_filters/translations/delete`. Every event carries the same `product_filter` object. Subscribing requires `read_products` (translation events also `read_translations`); store endpoints need edit access to products. Hiding a filter on a listing where it cannot narrow the results is decided per page view and publishes nothing.

## Endpoints

## Product filter contract

`GET /api/2025-01/product-filters/contract`

max_per_store includes built-in and disabled filters. The query_max_* and facet_values_* limits govern storefront selections. Use the sources endpoint to see which presentation choices a specific attribute or metafield definition supports.

Scope: `read_products`

```curl
curl 'https://api-store.tringify.com/api/2025-01/product-filters/contract' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"data":{"creatable_source_types":["attribute","metafield"],"display_types":["checkbox","image_swatch","pills","range","swatch","toggle"],"display_types_by_filter_type":{"boolean":["toggle","checkbox"],"color":["swatch","checkbox"],"enum":["checkbox","pills","image_swatch"],"multi_enum":["checkbox","pills","image_swatch"],"range":["range"]},"filter_types":["boolean","color","enum","multi_enum","range"],"limits":{"max_per_store":50,"list_max_limit":50,"list_search_max_length":200,"label_max_length":100,"sort_order_max":1000,"source_list_default":25,"source_list_max":100,"source_search_max_length":200,"default_sort":"sort_order","default_sort_direction":"asc","sort_columns":["sort_order","label","source_type","display_type","enabled"],"query_max_filters":50,"query_max_values":100,"query_max_total_values":256,"query_max_bytes":8192,"query_value_max_length":255,"facet_values_default":50,"facet_values_max":100,"visibility_targets_max":100},"visibility_page_types":["shop","category","collection","vendor","brand","search"],"visibility_target_types":["category","collection","vendor","brand"]},"success":true}
```

## List product filter sources

`GET /api/2025-01/product-filters/sources`

Each source includes compatible filter types, display choices, and a recommended configuration. Sources already used by a filter are omitted. A metafield definition must be readable by the token, visible on the storefront, and enabled for filtering. metafield_owner_type distinguishes product and variant definitions.

Scope: `read_products`

```curl
curl 'https://api-store.tringify.com/api/2025-01/product-filters/sources?limit=25&offset=0&search=Material&source_type=attribute' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"success":true,"data":{"sources":[{"source_id":"42","label":"Material","source_type":"attribute","attribute_sub_type":"standard","allowed_filter_types":["enum","multi_enum"],"display_types_by_filter_type":{"enum":["checkbox","pills"],"multi_enum":["checkbox","pills"]},"recommended":{"filter_type":"multi_enum","display_type":"checkbox"}}],"total":1,"limit":25,"offset":0}}
```

## List product filters

`GET /api/2025-01/product-filters`

Search matches label or filter_key. store_total counts every definition, including disabled ones, even when search or filters narrow the response. The top-level revision covers the complete list; use it when reordering. Each definition has its own revision for updates. source_available reflects whether its source remains eligible and readable by the token. platform_labelled marks a built-in filter that still has its platform label: its label is returned in the store's default language, and Tringify provides it in every storefront language. Sorting this response does not change storefront order.

Scope: `read_products`

```curl
curl 'https://api-store.tringify.com/api/2025-01/product-filters?enabled=true&search=Price&sort_by=sort_order&sort_direction=asc&source_type=system' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"data":{"filter_definitions":[{"allowed_filter_types":["range"],"display_type":"range","display_types_by_filter_type":{"range":["range"]},"enabled":true,"filter_key":"price","filter_type":"range","hide_on":[],"id":"22222222-2222-4222-8222-222222222221","label":"Price","page_types":["shop","category","collection","vendor","brand","search"],"platform_labelled":true,"recommended":{"display_type":"range","filter_type":"range"},"revision":1,"show_on":[],"sort_order":0,"source_available":true,"source_id":null,"source_type":"system","system_managed":true}],"revision":7,"store_total":7},"success":true}
```

## Create a product filter

`POST /api/2025-01/product-filters`

Choose a filter type and display type supported by the source. The service derives filter_key: for example, the Material attribute yields `attribute:material`, while a product metafield with namespace specs and key material yields `metafield:product:specs.material`. enabled defaults to true. The filter type decides selection: shoppers pick one value of an enum, boolean or range filter and any number of values of a multi_enum or color filter. A successful create publishes `product_filters/create`; when it goes in before other filters, their new positions also send `product_filters/reorder`. Where the filter shows: `page_types` lists the listing pages it appears on (shop, category, collection, vendor, brand, search; all of them by default); `show_on` limits it to specific pages (a category, optionally with all its subcategories, a collection, a vendor or a brand), overriding `page_types`; `hide_on` never shows it on the pages it names, and wins over both. A filter a shopper has already applied always stays so it can be removed, and a filter that cannot narrow the page's results is hidden anyway.

Scope: `write_products`

```curl
curl -X POST 'https://api-store.tringify.com/api/2025-01/product-filters' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "display_type": "checkbox",
  "enabled": true,
  "filter_type": "multi_enum",
  "hide_on": [
    {
      "id": "8a6f0d4e-1c2b-4d5e-9f00-1234567890ab",
      "type": "collection"
    }
  ],
  "label": "Material",
  "page_types": [
    "shop",
    "search"
  ],
  "show_on": [
    {
      "id": "12",
      "include_children": true,
      "type": "category"
    }
  ],
  "sort_order": 7,
  "source_id": "42",
  "source_type": "attribute"
}'
```

Response:

```json
{"code":"FILTER_CREATED","data":{"allowed_filter_types":["enum","multi_enum"],"display_type":"checkbox","display_types_by_filter_type":{"enum":["checkbox","pills"],"multi_enum":["checkbox","pills"]},"enabled":true,"filter_key":"attribute:material","filter_type":"multi_enum","hide_on":[],"id":"4b7eac32-68d9-4d1e-a322-33ce1cb324a5","label":"Material","page_types":["shop","category","collection","vendor","brand","search"],"platform_labelled":false,"recommended":{"display_type":"checkbox","filter_type":"multi_enum"},"revision":1,"show_on":[],"sort_order":7,"source_available":true,"source_id":"42","source_label":"Material","source_type":"attribute","system_managed":false},"message":"Filter added.","success":true}
```

## Reorder product filters

`PUT /api/2025-01/product-filters/reorder`

Read the unfiltered list, then send its top-level revision and every definition id once, including disabled filters. A changed revision returns FILTER_REVISION_STALE; an incomplete or duplicate set returns FILTER_ORDER_INVALID. The operation is atomic. Reordering changes the revision of each definition whose position moves, so read the list again before a later update. A changed order publishes one `product_filters/reorder` event with every filter in the new order; sending the current order changes nothing and publishes nothing.

Scope: `write_products`

```curl
curl -X PUT 'https://api-store.tringify.com/api/2025-01/product-filters/reorder' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "definition_ids": [
    "22222222-2222-4222-8222-222222222221",
    "22222222-2222-4222-8222-222222222222",
    "22222222-2222-4222-8222-222222222223",
    "22222222-2222-4222-8222-222222222224",
    "22222222-2222-4222-8222-222222222225",
    "22222222-2222-4222-8222-222222222226",
    "22222222-2222-4222-8222-222222222227",
    "4b7eac32-68d9-4d1e-a322-33ce1cb324a5"
  ],
  "revision": 8
}'
```

Response:

```json
{"code":"FILTER_REORDERED","data":{"reordered":true},"message":"Filter order saved.","success":true}
```

## Update a product filter

`PUT /api/2025-01/product-filters/{id}`

Send the current definition revision. This is a merge update: omitted fields stay unchanged. A stale revision is rejected without saving. You can disable a filter even if its source is no longer eligible or readable. Built-in filter type and display are fixed; their labels, enabled state, and order can change. A built-in filter keeps its platform label, which Tringify provides in every storefront language, while its label equals that platform label in English or in the store's default language; any other label is the store's own text, translated like a custom filter's. Changing a base-language label marks its translations outdated without deleting them. A request that changes nothing leaves the revision unchanged and publishes no webhook; a successful change publishes `product_filters/update` with `changed_fields`. A new `sort_order` moves the filter and sends `product_filters/reorder` (with every filter's new position) instead of listing sort_order in `changed_fields`. Where the filter shows: `page_types` lists the listing pages it appears on (shop, category, collection, vendor, brand, search; all of them by default); `show_on` limits it to specific pages (a category, optionally with all its subcategories, a collection, a vendor or a brand), overriding `page_types`; `hide_on` never shows it on the pages it names, and wins over both. A filter a shopper has already applied always stays so it can be removed, and a filter that cannot narrow the page's results is hidden anyway.

Scope: `write_products`

```curl
curl -X PUT 'https://api-store.tringify.com/api/2025-01/product-filters/4b7eac32-68d9-4d1e-a322-33ce1cb324a5' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "display_type": "pills",
  "enabled": true,
  "filter_type": "multi_enum",
  "hide_on": [
    {
      "id": "8a6f0d4e-1c2b-4d5e-9f00-1234567890ab",
      "type": "collection"
    }
  ],
  "label": "Fabric",
  "page_types": [
    "shop",
    "search"
  ],
  "revision": 2,
  "show_on": [
    {
      "id": "12",
      "include_children": true,
      "type": "category"
    }
  ],
  "sort_order": 7
}'
```

Response:

```json
{"code":"FILTER_UPDATED","data":{"allowed_filter_types":["enum","multi_enum"],"display_type":"pills","display_types_by_filter_type":{"enum":["checkbox","pills"],"multi_enum":["checkbox","pills"]},"enabled":true,"filter_key":"attribute:material","filter_type":"multi_enum","hide_on":[{"id":"12","include_children":true,"name":"Posters","type":"category"}],"id":"4b7eac32-68d9-4d1e-a322-33ce1cb324a5","label":"Fabric","page_types":["shop","category","collection","vendor","brand","search"],"platform_labelled":false,"recommended":{"display_type":"checkbox","filter_type":"multi_enum"},"revision":3,"show_on":[],"sort_order":7,"source_available":true,"source_id":"42","source_label":"Material","source_type":"attribute","system_managed":false},"message":"Filter saved.","success":true}
```

## Delete a product filter

`DELETE /api/2025-01/product-filters/{id}`

Deleting a custom filter removes its label translations but leaves the source attribute or metafield definition and products intact. Built-in filters cannot be deleted; disable one with the update endpoint. A successful delete publishes `product_filters/delete`.

Scope: `write_products`

```curl
curl -X DELETE 'https://api-store.tringify.com/api/2025-01/product-filters/4b7eac32-68d9-4d1e-a322-33ce1cb324a5' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"code":"FILTER_DELETED","data":{"deleted":true},"message":"Filter deleted.","success":true}
```

## Webhook events

## Product filter created

Event: `product_filters/create` · App scope: `read_products` · Staff permission: `products:write`

Fired when a storefront product filter is created from an attribute or metafield definition.

```json
{
  "product_filter": {
    "display_type": "checkbox",
    "enabled": true,
    "filter_key": "attribute:material",
    "filter_type": "multi_enum",
    "hide_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "collection"
      }
    ],
    "id": "4b7eac32-68d9-4d1e-a322-33ce1cb324a5",
    "label": "Material",
    "page_types": [],
    "platform_labelled": false,
    "revision": 1,
    "show_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "category"
      }
    ],
    "sort_order": 7,
    "source_id": "42",
    "source_owner_type": null,
    "source_type": "attribute",
    "system_managed": false
  }
}
```

## Product filter deleted

Event: `product_filters/delete` · App scope: `read_products` · Staff permission: `products:write`

Fired when a product filter is deleted, including when uninstalling the app that owns its metafield definition deletes it. The payload carries the filter as it was before deletion. The same deletion also sends product_filters/translations/delete for each locale the filter had a label translation in; deliveries can arrive in either order.

```json
{
  "product_filter": {
    "display_type": "checkbox",
    "enabled": true,
    "filter_key": "attribute:material",
    "filter_type": "multi_enum",
    "hide_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "collection"
      }
    ],
    "id": "4b7eac32-68d9-4d1e-a322-33ce1cb324a5",
    "label": "Material",
    "page_types": [],
    "platform_labelled": false,
    "revision": 3,
    "show_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "category"
      }
    ],
    "sort_order": 7,
    "source_id": "42",
    "source_owner_type": null,
    "source_type": "attribute",
    "system_managed": false
  }
}
```

## Product filters reordered

Event: `product_filters/reorder` · App scope: `read_products` · Staff permission: `products:write`

Fired when the storefront order of product filters changes: a complete reorder, a filter moved with a new sort_order, or a filter added in front of others. One event carries every filter in the new order, each with its new sort_order and revision, plus the new list revision. An unchanged order sends nothing.

```json
{
  "product_filters": [
    {
      "display_type": "checkbox",
      "enabled": true,
      "filter_key": "attribute:material",
      "filter_type": "multi_enum",
      "hide_on": [
        {
          "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
          "include_children": false,
          "type": "collection"
        }
      ],
      "id": "4b7eac32-68d9-4d1e-a322-33ce1cb324a5",
      "label": "Material",
      "page_types": [],
      "platform_labelled": false,
      "revision": 4,
      "show_on": [
        {
          "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
          "include_children": false,
          "type": "category"
        }
      ],
      "sort_order": 0,
      "source_id": "42",
      "source_owner_type": null,
      "source_type": "attribute",
      "system_managed": false
    }
  ],
  "revision": 9
}
```

## Product filter updated

Event: `product_filters/update` · App scope: `read_products` · Staff permission: `products:write`

Fired when a product filter's label, filter type, display type, enabled state or the pages it shows on (page_types, show_on, hide_on) change, including when deleting a category, collection, vendor or brand removes it from show_on or hide_on. changed_fields lists what changed. Saving unchanged values sends nothing. A change of position, whether a complete reorder or one filter's new sort_order, sends product_filters/reorder instead.

```json
{
  "changed_fields": [
    "label"
  ],
  "product_filter": {
    "display_type": "checkbox",
    "enabled": true,
    "filter_key": "attribute:material",
    "filter_type": "multi_enum",
    "hide_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "collection"
      }
    ],
    "id": "4b7eac32-68d9-4d1e-a322-33ce1cb324a5",
    "label": "Fabric",
    "page_types": [],
    "platform_labelled": false,
    "revision": 3,
    "show_on": [
      {
        "id": "c672bace-7900-4bc7-8ab0-dae33df4eab0",
        "include_children": false,
        "type": "category"
      }
    ],
    "sort_order": 7,
    "source_id": "42",
    "source_owner_type": null,
    "source_type": "attribute",
    "system_managed": false
  }
}
```

