Skip to main content

Create Product Filter

Creates a new product filter that shoppers can use on product listing and search pages. The filter uses the product metafield given in metaFieldId, or the metafield whose code matches name.

HTTP Request​

  • URL: /productFilter
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_PRODUCT

Request Body​

Send the product filter as a JSON object.

FieldTypeRequiredDescription
nameStringYesInternal name, usually the metafield code. Must be unique.
displayNameStringYesLabel shown to shoppers.
metaFieldIdStringNoID of the product metafield to filter by. See Metafields.
statusBooleanNoWhether the filter is shown on the storefront. Default is false.
sortOrderStringNoDisplay order as a number in a string, for example "3". Default is 0.
sortByStringNoHow the filter's values are ordered: alpha or item_count. Default is alpha.
collapsedDefaultBooleanNoWhether the filter is collapsed when the page loads. Default is false.

cURL Example​

curl --location '<BASE_URL>/productFilter' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "material",
"displayName": "Material",
"metaFieldId": "66d1f0c2a1b2c3d4e5f60718",
"status": true,
"sortOrder": "3",
"sortBy": "item_count",
"collapsedDefault": false
}'

Response​

  • 200 OK: The product filter was created successfully.
  • 400 Bad Request: The access token is missing or invalid, a required field is missing, a value is not valid, or a filter with the same name already exists.

Sample JSON Response​

{
"success": true,
"message": "ProductFilter added Successfully",
"data": {
"_id": "6704b8e2c9a1d2e3f4a5b6c7",
"name": "material",
"displayName": "Material",
"type": "filter",
"displayProductCount": false,
"status": true,
"metaFieldId": "66d1f0c2a1b2c3d4e5f60718",
"sortOrder": 3,
"sortBy": "item_count",
"collapsedDefault": false,
"itemsToShow": 0,
"productCounts": 0,
"createdAt": "2025-10-08T07:55:14.392Z",
"updatedAt": "2025-10-08T07:55:14.392Z"
}
}

Response Details​

FieldTypeDescription
successBooleantrue when the product filter was created.
messageStringConfirmation message.
dataObjectThe new product filter. Its ID is returned as _id. For all fields, see Get All Product Filters.

Notes​

  • New filters have the type filter.
  • New filters are hidden from the storefront until status is true. You can also turn them on later with Update Product Filter Status.