Facet rules tools

🚧

Warning

Write tools change your live configuration. Just like changes made in the Bloomreach dashboard, actions your users or agents take with these tools can have a substantial impact on your live search and category experience. There is no automatic rollback and activity logging is limited, so review every change and confirm the target before applying it.

list_site_search_facets

Lists the site-search facet rules for an account. Facets are the filter options shown alongside search results, such as Brand, Color, Price range, or Size. A facet rule controls which facets appear, their order, and how they behave, for example multi-select versus single-select. This tool returns every site-search facet rule in one response, without pagination.

Use get_facet_rule for a rule's full configuration. For global facets that apply across both site search and category pages, use list_facets_global. For category-specific facets, use list_category_facets.

Request parameters

NameTypeRequired?Description
merchant_keystrYesThe merchant key identifying the account, for example your-account.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The facet rule summaries.
errorstr | nullError message if the request failed.

The CustomizationSummary object has the following fields:

FieldTypeDescription
idintThe unique customization ID.
namestr | nullThe rule's display name.
ruleTypestrThe rule type, facet.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
querieslist[CustomizationQuery]The queries this facet rule applies to.
groupBystr | nullThe group-by attribute, for example color.

The CustomizationQuery object has the following fields:

FieldTypeDescription
idint | nullThe query identifier.
querystr | nullThe query text, for example green shoes.
typestr | nullThe query type, for example sitesearch or category.

list_facets_global

Lists the global facet rules for an account. Global facet rules apply across both site-search and category pages, so shoppers see a consistent set of filter options however they navigate the catalog. This tool returns every global facet rule in one response, without pagination.

Use get_facet_rule for a rule's full configuration. For site-search facets, use list_site_search_facets. For category facets, use list_category_facets.

Request parameters

NameTypeRequired?Description
merchant_keystrYesThe merchant key identifying the account, for example your-account.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The global facet rule summaries.
errorstr | nullError message if the request failed.

The CustomizationSummary object has the following fields:

FieldTypeDescription
idintThe unique customization ID.
namestr | nullThe rule's display name.
ruleTypestrThe rule type, facet.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
querieslist[CustomizationQuery]The queries this facet rule applies to.
groupBystr | nullThe group-by attribute, for example color.

The CustomizationQuery object has the following fields:

FieldTypeDescription
idint | nullThe query identifier.
querystr | nullThe query text, for example green shoes.
typestr | nullThe query type, for example sitesearch or category.

list_category_facets

Lists the category facet rules for an account. Category facet rules control which facets appear on category pages and how they behave. Unlike global facets that apply everywhere, category facets are specific to browsing. For example, a Size facet can appear only on clothing categories, or a Resolution facet only on electronics. This tool returns every category facet rule in one response, without pagination.

Use get_facet_rule for a rule's full configuration. For site-search facets, use list_site_search_facets. For global facets, use list_facets_global.

Request parameters

NameTypeRequired?Description
merchant_keystrYesThe merchant key identifying the account, for example your-account.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The category facet rule summaries.
errorstr | nullError message if the request failed.

The CustomizationSummary object has the following fields:

FieldTypeDescription
idintThe unique customization ID.
namestr | nullThe rule's display name.
ruleTypestrThe rule type, facet.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
querieslist[CustomizationQuery]The queries this facet rule applies to.
groupBystr | nullThe group-by attribute, for example color.

The CustomizationQuery object has the following fields:

FieldTypeDescription
idint | nullThe query identifier.
querystr | nullThe query text, for example green shoes.
typestr | nullThe query type, for example sitesearch or category.

list_facet_attributes

Lists the product attributes available for facet configuration. Each result gives an attribute field name, such as brand, color, or Rating, that you can use when you define which facets a rule boosts, buries, excludes, or always includes. Take the name field from each result as the attribute identifier.

By default the response returns only facetable attributes. Set only_facetable to false to see every attribute. The results are paginated, so use page and limit for large catalogs, and query to search by attribute name.

Request parameters

NameTypeRequired?Description
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account.
site_group_idstr | int | nullNoA site group ID (numeric) or site name. Omit for account level.
querystr | nullNoText search to filter attributes by name, for example brand or color.
only_facetableboolNoWhen true (default), returns only attributes usable as facet filters. Set to false to see all attributes.
pageintNoThe page number, 0-based. Defaults to 0.
limitintNoResults per page. Defaults to 50, maximum 200.
sort_bystrNoSort field: NAME (default), ID, TYPE, or FACETABLE.
sort_orderstrNoSort direction: ASC (default) or DESC.

Response parameters

The tool returns a FacetAttributesResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[FacetAttribute]The facet attributes.
errorstr | nullError message if the request failed.
totalint | nullThe total number of matching attributes across all pages.
pageint | nullThe current page number, 0-based.
total_pagesint | nullThe total number of pages.

The FacetAttribute object has the following fields:

FieldTypeDescription
idint | nullThe internal attribute ID.
namestrThe attribute field name. Use this value when you configure facets in a rule.
typestr | nullThe attribute type: STR (text), NUM (numeric), or HIERARCHY.
facetablebool | nullWhether this attribute can be used as a facet filter.
storedbool | nullWhether the attribute value is stored in the index.
levelstr | nullPARENT (product level) or CHILD (variant level).
multiValuedbool | nullWhether a product can have multiple values for this attribute.
siteIdint | nullThe site ID if the attribute is site-specific, or null for account-level attributes.

get_facet_rule

Fetches the full configuration of a single facet rule by ID. It works for site-search, category, and global facet rules. The response returns every facet action on the rule: boosted and buried facets, always-included facets, excluded facets, associated queries, audience targeting, and scheduling metadata. The customizationItems map holds the facet actions keyed by type: boosted_facets, buried_facets, excluded_facets, and always_included_facets.

Discover rule IDs with list_site_search_facets, list_facets_global, or list_category_facets, then call this tool to inspect a specific rule's full configuration.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the facet rule to fetch. Discover IDs with list_site_search_facets, list_facets_global, or list_category_facets.
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account. Use list_discovery_accounts to see available accounts.
site_group_idstr | int | nullNoA site group ID (numeric) or site name (string). Defaults to -1 (account level) when omitted. Use list_discovery_sites to discover sites.

Response parameters

The tool returns a CustomizationDetailResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
dataany | nullThe full facet rule detail as freeform JSON. Includes id, ruleType (facet), enabled, queries, customizationItems (keyed by boosted_facets, buried_facets, excluded_facets, and always_included_facets), audience targeting, startedAt, endedAt, and scheduling metadata.
errorstr | nullError message if the request failed.

create_facet_rule

Creates a new facet rule. Facet rules control which filter attributes (facets) appear on search and category pages and how they're ordered. Set each query's queryType to sitesearch with a search term, category with a category ID (find valid IDs with list_categories), or global with query='*' to apply the rule across all pages. One rule can cover multiple categories or search terms when you pass multiple query entries.

The facet parameters map to the dashboard controls: boosted_facets surfaces facets near the top of the filter list, buried_facets pushes them to the end, excluded_facets hides them entirely, and always_included_facets forces them to appear. The boosted_facets and buried_facets lists use 1-based ordering, so the first entry gets position 1. max_count_facets sets the maximum number of facets returned (up to 50) and applies to global rules only. When enabled is true, the rule takes effect after an asynchronous sync to the search index (typically seconds to minutes). Range facet configuration, facet value merging, facet value renaming, per-value reordering, and category facet inheritance aren't available through this tool — use the Discovery dashboard for those. Discover valid attribute names with list_facet_attributes and audience IDs with list_discovery_audiences, then confirm the rule synced with list_site_search_facets, list_category_facets, or list_facets_global.

Request parameters

NameTypeRequired?Description
querieslist[dict]YesQueries this rule targets. Pass multiple entries to apply one rule to multiple categories or search terms. Each entry: query (a search term, category ID from list_categories, or * for global), queryType (sitesearch, category, or global), and matchType (EXACT_MATCH or BROAD).
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account.
site_group_idstr | int | nullNoA site group ID (numeric) or site name. Omit for account level.
namestr | nullNoDisplay name for the rule.
enabledboolNoWhether the rule is active after sync. Defaults to true.
audience_idint | nullNoNumeric audience segment ID to scope this rule to a specific audience. Omit for no audience targeting. Discover IDs with list_discovery_audiences.
boosted_facetslist[str] | nullNoFacet field names to boost near the top of the filter list. Order matters — the first entry gets position 1, for example ['brand', 'color']. Discover valid names with list_facet_attributes.
buried_facetslist[str] | nullNoFacet field names to push to the end of the filter list. Order matters, for example ['material', 'weight'].
excluded_facetslist[str] | nullNoFacet field names to hide entirely from the filter list, for example ['warehouse_location', 'internal_sku'].
always_included_facetslist[str] | nullNoFacet field names to always show regardless of the algorithm, for example ['price', 'brand'].
max_count_facetsint | nullNoGlobal advanced setting: the maximum number of facets returned. Maximum 50. Applies to global rules only.
facet_itemslist[dict] | nullNoAdvanced: raw customization items for types not covered by named parameters, such as aliases_facets or value_configs_facets. Each entry: {'customizationType': '<type>', 'customizationValue': '<json-encoded-string>'}. Merged alongside named parameters by type.
started_atint | nullNoUnix timestamp in milliseconds of when the rule becomes active. Omit for unscheduled.
ended_atint | nullNoUnix timestamp in milliseconds of when the rule expires. Omit for no expiry.

Response parameters

The tool returns a RankingRuleMutationResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the operation succeeded.
dataany | nullThe created facet rule as freeform JSON. Use the returned id for later update or delete operations.
errorstr | nullError message if the operation failed.

update_facet_rule

Updates an existing facet rule. Only the fields you provide change; every other field carries forward from the current rule. The tool fetches the current rule, merges your changes on top, then saves the result. Facet item parameters such as boosted_facets and excluded_facets merge by type, so only the types you specify are replaced while other existing items stay unchanged.

Changes to an enabled rule affect which facets appear for live customers after an asynchronous sync (typically seconds to minutes). Discover the rule ID and confirm its current state with list_site_search_facets, list_category_facets, or list_facets_global before updating.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the facet rule to update. Discover IDs with list_site_search_facets, list_category_facets, or list_facets_global.
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account.
site_group_idstr | int | nullNoA site group ID (numeric) or site name. Omit for account level.
namestr | nullNoNew display name. Omit to keep the existing name.
enabledbool | nullNoEnable or disable the rule. Omit to keep the existing state.
audience_idint | nullNoNumeric audience segment ID. Omit to keep the existing audience. Discover IDs with list_discovery_audiences.
querieslist[dict] | nullNoNew query list that replaces the existing one. Pass multiple entries to apply the rule to multiple categories or search terms. Each entry: query (a category ID, search term, or *), queryType, and matchType. Omit to keep the existing queries.
boosted_facetslist[str] | nullNoNew list of facet names to boost near the top of the filter list. Order matters — the first entry gets position 1. Replaces the existing list. Omit to keep it.
buried_facetslist[str] | nullNoNew list of facet names to push to the end of the filter list. Order matters. Replaces the existing list. Omit to keep it.
excluded_facetslist[str] | nullNoNew list of facet names to hide entirely. Replaces the existing list. Omit to keep it.
always_included_facetslist[str] | nullNoNew list of facet names to always show. Replaces the existing list. Omit to keep it.
max_count_facetsint | nullNoNew global maximum number of facets (up to 50). Replaces the existing value. Omit to keep it.
facet_itemslist[dict] | nullNoAdvanced: raw items merged by customizationType. Omit to keep the existing items.
started_atint | nullNoNew start timestamp in milliseconds. Omit to keep the existing value.
ended_atint | nullNoNew end timestamp in milliseconds. Omit to keep the existing value.

Response parameters

The tool returns a RankingRuleMutationResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the operation succeeded.
dataany | nullThe updated facet rule as freeform JSON.
errorstr | nullError message if the operation failed.

delete_facet_rule

Permanently deletes a facet rule. This is irreversible — the rule can't be recovered after deletion, so verify the target before you run it. The rule is removed from live facet display after an asynchronous sync (typically seconds to minutes), not instantly.

If the rule is currently enabled, it's actively shaping which facets appear for shoppers, and deleting it reverts those pages to algorithm defaults once the sync completes. Consider disabling it first with update_facet_rule to preview the impact before permanent removal. Deletion is blocked when the rule is part of a running A/B experiment, where the API returns a Customization is live error; end the experiment first. Discover IDs with list_site_search_facets, list_category_facets, or list_facets_global.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the facet rule to delete. Discover IDs with list_site_search_facets, list_category_facets, or list_facets_global.
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account.
site_group_idstr | int | nullNoA site group ID (numeric) or site name. Omit for account level.

Response parameters

The tool returns a DeleteResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the delete succeeded.
errorstr | nullError message if the delete failed.


Did this page help you?

© Bloomreach, Inc. All rights reserved.