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.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Internal name, usually the metafield code. Must be unique. |
displayName | String | Yes | Label shown to shoppers. |
metaFieldId | String | No | ID of the product metafield to filter by. See Metafields. |
status | Boolean | No | Whether the filter is shown on the storefront. Default is false. |
sortOrder | String | No | Display order as a number in a string, for example "3". Default is 0. |
sortBy | String | No | How the filter's values are ordered: alpha or item_count. Default is alpha. |
collapsedDefault | Boolean | No | Whether 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
| Field | Type | Description |
|---|---|---|
success | Boolean | true when the product filter was created. |
message | String | Confirmation message. |
data | Object | The 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
statusistrue. You can also turn them on later with Update Product Filter Status.