Ranking rules and audiences 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_ranking_rules

Lists site-search ranking rules as paginated summaries. Ranking rules control how products are ordered in search results for specific queries. For example, a rule can boost certain products to the top when a shopper searches for green shoes. Each rule ties to one or more search queries and can be scheduled, A/B tested, and targeted to an audience.

The summary leaves out the rule's merchandising actions. Use get_ranking_rule for a rule's full configuration. For global ranking rules that apply across both site search and category pages, use list_ranking_rules_global.

Request parameters

NameTypeRequired?Description
pageintNoThe page number, 0-based. Defaults to 0.
limitintNoResults per page. Defaults to 10, maximum 100.
sort_bystrNoField to sort by: lastModifiedAt, identifier, or duration. Defaults to lastModifiedAt.
sort_orderstrNoSort direction: ASC or DESC. Defaults to DESC.
qstr | nullNoText search to filter by query or username.
durationstr | nullNoComma-separated duration filter: unscheduled, scheduled, active, expiringSoon, or expired.
audience_idsstr | nullNoComma-separated audience IDs to filter by.
enabledstr | nullNoEnabled filter: true or false.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The ranking 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, for example ranking.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
durationTagstr | nullDuration tag: unscheduled, scheduled, active, expiringSoon, or expired.
startedAtint | nullUnix timestamp in milliseconds of when the rule became active.
endedAtint | nullUnix timestamp in milliseconds of when the rule expires.
createdAtint | nullUnix timestamp in milliseconds of when the rule was created.
lastModifiedAtint | nullUnix timestamp in milliseconds of when the rule was last modified.
lastModifiedBystr | nullEmail or name of the user who last modified the rule.
querieslist[CustomizationQuery]The queries this rule applies to.
isAbTestLiveboolWhether an A/B test is currently active for this rule.
audienceNamestr | nullName of the audience segment this rule targets.

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_ranking_rules_global

Lists global ranking rules as paginated summaries. Global ranking rules apply across both site-search and category queries, unlike query-specific rules that affect individual search terms. They suit broad merchandising strategies, such as always boosting in-stock products or demoting clearance items across the whole site.

Each summary includes the name, enabled status, associated queries, A/B test state, and scheduling details. Use get_ranking_rule for a rule's full configuration. For query-specific site-search rules, use list_site_search_ranking_rules.

Request parameters

NameTypeRequired?Description
pageintNoThe page number, 0-based. Defaults to 0.
limitintNoResults per page. Defaults to 10, maximum 100.
sort_bystrNoField to sort by: lastModifiedAt, identifier, or duration. Defaults to lastModifiedAt.
sort_orderstrNoSort direction: ASC or DESC. Defaults to DESC.
qstr | nullNoText search to filter by identifier or username.
durationstr | nullNoComma-separated duration filter: unscheduled, scheduled, active, expiringSoon, or expired.
audience_idsstr | nullNoComma-separated audience IDs to filter by.
enabledstr | nullNoEnabled filter: true or false.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The global ranking 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, for example ranking.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
durationTagstr | nullDuration tag: unscheduled, scheduled, active, expiringSoon, or expired.
startedAtint | nullUnix timestamp in milliseconds of when the rule became active.
endedAtint | nullUnix timestamp in milliseconds of when the rule expires.
createdAtint | nullUnix timestamp in milliseconds of when the rule was created.
lastModifiedAtint | nullUnix timestamp in milliseconds of when the rule was last modified.
lastModifiedBystr | nullEmail or name of the user who last modified the rule.
querieslist[CustomizationQuery]The queries this rule applies to.
isAbTestLiveboolWhether an A/B test is currently active for this rule.
audienceNamestr | nullName of the audience segment this rule targets.

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_ranking_rules

Lists query-specific category ranking rules as paginated summaries. Category ranking rules control how products are ordered on category pages. For example, a rule can boost best-sellers or seasonal items when a shopper browses a specific category. Each rule ties to one or more category queries and can be scheduled, A/B tested, and targeted to an audience.

Use get_ranking_rule for a rule's full configuration. For global rules that apply across all categories and site search, use list_ranking_rules_global.

Request parameters

NameTypeRequired?Description
pageintNoThe page number, 0-based. Defaults to 0.
limitintNoResults per page. Defaults to 10, maximum 100.
sort_bystrNoField to sort by: lastModifiedAt, identifier, or duration. Defaults to lastModifiedAt.
sort_orderstrNoSort direction: ASC or DESC. Defaults to DESC.
qstr | nullNoText search to filter by category, note, or username.
durationstr | nullNoComma-separated duration filter: unscheduled, scheduled, active, expiringSoon, or expired.
audience_idsstr | nullNoComma-separated audience IDs to filter by.
enabledstr | nullNoEnabled filter: true or false.

Response parameters

The tool returns a CustomizationsResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[CustomizationSummary]The category ranking 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, for example ranking.
isEnabledbool | nullWhether the rule is currently enabled.
syncStatusstr | nullSync status: SUCCESS, QUEUED, FAILED, EXPIRED, or FUTURE.
durationTagstr | nullDuration tag: unscheduled, scheduled, active, expiringSoon, or expired.
startedAtint | nullUnix timestamp in milliseconds of when the rule became active.
endedAtint | nullUnix timestamp in milliseconds of when the rule expires.
createdAtint | nullUnix timestamp in milliseconds of when the rule was created.
lastModifiedAtint | nullUnix timestamp in milliseconds of when the rule was last modified.
lastModifiedBystr | nullEmail or name of the user who last modified the rule.
querieslist[CustomizationQuery]The queries this rule applies to.
isAbTestLiveboolWhether an A/B test is currently active for this rule.
audienceNamestr | nullName of the audience segment this rule targets.

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.

get_ranking_rule

Fetches the full configuration of a single ranking rule by ID. It works for site-search, category, and global ranking rules. The response returns every merchandising action on the rule: boosted and buried products, locked product slot positions, attribute-level boost and bury adjustments, sliced variant attributes, any ranking algorithm override, and scheduling metadata.

Discover rule IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_global, then call this tool to inspect a specific rule's full effect.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the ranking rule to fetch. Discover IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_global.
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 ranking rule detail as freeform JSON. Includes id, ruleType, enabled, queries, customizationItems (boosted and buried products, locked slots, attribute boosts), startedAt, endedAt, and scheduling metadata.
errorstr | nullError message if the request failed.

list_discovery_audiences

Lists the audience segments defined in an account. Audiences target ranking rules, redirects, and facets to specific groups of shoppers based on device, location, URL, or referral URL conditions. Use the numeric id from each result as the audience ID when you target a rule to a segment.

Each audience reports how many rules it currently affects and the targeting conditions that define it. Audiences can also draw on Bloomreach segmentations, which enable behavior-based targeting beyond device and location. Audiences are account-level, so this tool takes no site group parameter.

Request parameters

NameTypeRequired?Description
account_namestr | nullNoThe account name. Auto-selected when you have exactly one account. Use list_discovery_accounts to see available accounts.

Response parameters

The tool returns an AudiencesResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
datalist[Audience]The audience segments.
sizeint | nullThe total number of audiences returned.
errorstr | nullError message if the request failed.

The Audience object has the following fields:

FieldTypeDescription
idintThe numeric audience ID, used to target a rule to this segment.
audienceNamestrThe human-readable audience name, for example Mobile Device.
userstr | nullEmail of the user who last modified this audience.
createdAtint | nullUnix timestamp in milliseconds of when the audience was created.
modifiedAtint | nullUnix timestamp in milliseconds of when the audience was last modified.
rulesAffectedint | nullThe number of ranking rules currently using this audience.
editablebool | nullWhether you can edit this audience.
dimensionListlist[AudienceDimension]The targeting conditions that define this audience.
sitegroupany | nullThe site group this audience is scoped to, or null for account level.

The AudienceDimension object has the following fields:

FieldTypeDescription
idint | nullThe dimension ID.
internalNamestr | nullThe internal dimension name, for example device, geo, url, or ref_url.
externalNamestr | nullThe human-readable dimension name, for example Device, Location, URL, or Referral URL.
typestr | nullThe dimension type, for example discovery.
dimensionValueListlist[any]The condition values for this dimension, each with an internal value, an external value, and a match type such as IS, IS NOT, or CONTAINS.

create_ranking_rule

Creates a new ranking rule. Ranking rules control the order of products returned for site-search queries, category pages, or globally, depending on the queryType of each query entry. A rule can boost or bury specific products, freeze product positions, slice variants, override the ranking algorithm, target an audience, and be scheduled with start and end times. Set each query's queryType to sitesearch with a search term, category with a category path, or global, sitesearch_global, or category_global with query='*' to apply the rule across all matching traffic.

When enabled is true, the rule takes effect after an asynchronous sync to the search index (typically seconds to minutes), so it affects live shopper traffic. Only one un-targeted global rule is allowed per queryType; to add another global rule for a queryType that already has one, pass an audience_id. Product boosts and buries have no effect on global rules, queries that contain a colon (:) can't be used, and a buried product is only affected if it already appears in the results for that query. Use list_discovery_audiences to find audience IDs, and confirm the rule synced with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_global.

Request parameters

NameTypeRequired?Description
querieslist[dict]YesQueries this rule targets. Each entry needs query (a search term, category path, or * for global rules), queryType (sitesearch, category, global, category_global, or sitesearch_global), and matchType (EXACT_MATCH or BROAD). Use EXACT_MATCH for category paths.
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. Defaults to -1 (account level) when omitted.
namestr | nullNoDisplay name for the rule.
enabledboolNoWhether the rule is active immediately after sync. Defaults to true.
audience_idint | nullNoNumeric audience segment ID. Required when you create an additional global rule and an un-targeted global rule already exists. Discover IDs with list_discovery_audiences.
boost_product_idslist[str] | nullNoProduct IDs to boost (surface higher) for this query.
bury_product_idslist[str] | nullNoProduct IDs to bury (push lower) for this query.
freeze_productsbool | nullNoWhen true, freezes all product positions so the ranking algorithm won't reorder results.
sliced_attributeslist[str] | nullNoAttributes to slice variants on, for example ['color', 'size'].
ranking_algo_idstr | nullNoOverride the ranking algorithm ID. Omit to use the account default.
customization_itemslist[dict] | nullNoAdvanced: raw items for types not covered by named parameters, such as attribute_boost_bury or product_slots. Each entry: {'customizationType': '<type>', 'customizationValue': '<json-string>'}.
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 ranking rule as freeform JSON. Use the returned id for later update, delete, or variant operations.
errorstr | nullError message if the operation failed.

update_ranking_rule

Updates an existing ranking rule, whether it's a site-search, category, or global 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. Item parameters such as boost_product_ids and freeze_products merge by type, so only the types you specify are replaced while other existing items stay unchanged. Audience targeting is preserved automatically unless you pass a new audience_id, and you can change the query scope by supplying a new queries list.

Changes to an enabled rule affect live search traffic after an asynchronous sync (typically seconds to minutes). Discover the rule ID and confirm its current state with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_global before updating.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the ranking rule to update. Discover IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_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. Defaults to -1 (account level) when omitted.
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. Each entry: query, queryType, matchType. Omit to keep the existing queries.
boost_product_idslist[str] | nullNoProduct IDs to boost. Replaces the existing boosted products. Omit to keep the existing list.
bury_product_idslist[str] | nullNoProduct IDs to bury. Replaces the existing buried products. Omit to keep the existing list.
freeze_productsbool | nullNoEnable or disable position freezing. Omit to keep the existing setting.
sliced_attributeslist[str] | nullNoAttributes to slice variants on. Replaces the existing list. Omit to keep it.
ranking_algo_idstr | nullNoOverride the ranking algorithm ID. Omit to keep the existing setting.
customization_itemslist[dict] | nullNoAdvanced: raw items merged by customizationType, so only the specified types are replaced and others are preserved.
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 ranking rule as freeform JSON.
errorstr | nullError message if the operation failed.

delete_ranking_rule

Permanently deletes a ranking rule. This is irreversible — the platform uses a soft delete that filters the rule from all responses with no restore endpoint, so verify the target before you run it. The rule is removed from live search results after an asynchronous sync (typically seconds to minutes), not instantly.

If the rule is currently enabled, it's actively shaping product rankings for shoppers, and deleting it changes search result ordering for all affected queries once the sync completes. Consider disabling it first with update_ranking_rule to preview the impact before removing it. Deletion is blocked when the rule is part of a running A/B experiment, where the API returns a Customization is live error, or when the rule is in the cloning queue; end the experiment or wait for cloning to finish first. Discover IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_global.

Request parameters

NameTypeRequired?Description
rule_idintYesThe ID of the ranking rule to delete. Discover IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_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. Defaults to -1 (account level) when omitted.

Response parameters

The tool returns a DeleteResponse object with the following parameters:

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

create_ranking_rule_variant

Creates a new test variant of an existing ranking rule, equivalent to the Save new test variant button in the Discovery dashboard. Use it to A/B test two different merchandising configurations against each other (Rule A versus Rule B). To test only whether a rule helps against default search behavior, you don't need this tool — omit the customization on the control bucket in create_discovery_experiment instead.

The variant inherits the parent rule's queries, audience, rule type, and site group, so only the merchandising configuration (boost, bury, freeze, and so on) can differ. The variant starts disabled, so enable it with update_ranking_rule before you set up an A/B test. Variants can't be scheduled, so started_at and ended_at aren't supported. The parent rule is variant 1 and this call creates variant 2, up to a maximum of four per group. Inspect the parent rule's full configuration with get_ranking_rule first, then use the returned variant id as the customization when you set up an experiment with create_discovery_experiment.

Request parameters

NameTypeRequired?Description
base_rule_idintYesThe ID of the existing ranking rule to create a variant of. Discover IDs with list_site_search_ranking_rules, list_category_ranking_rules, or list_ranking_rules_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. Defaults to -1 (account level) when omitted.
namestr | nullNoDisplay name for this variant, for example Boost seasonal products.
boost_product_idslist[str] | nullNoProduct IDs to boost in this variant.
bury_product_idslist[str] | nullNoProduct IDs to bury in this variant.
freeze_productsbool | nullNoFreeze product positions in this variant.
sliced_attributeslist[str] | nullNoAttributes to slice variants on in this variant.
ranking_algo_idstr | nullNoOverride the ranking algorithm ID for this variant.
customization_itemslist[dict] | nullNoAdvanced: raw customization items. Each entry: {'customizationType': '<type>', 'customizationValue': '<json-string>'}.

Response parameters

The tool returns a RankingRuleMutationResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the operation succeeded.
dataany | nullThe created variant as freeform JSON. Use the returned id as the customization when you set up an experiment with create_discovery_experiment.
errorstr | nullError message if the operation failed.


Did this page help you?

© Bloomreach, Inc. All rights reserved.