Item collection configuration 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 item collection schema, its destination pipelines, and the reindex jobs they trigger. Configuration writes are audited with a before-state snapshot, but there is no automatic rollback, so review every change and confirm the target before applying it.

get_item_collection_configuration

Gets the schema configuration for a Data hub item collection. The response covers the custom attribute definitions, the identifier fields, the destination pipeline configurations, and an etag version hash. Read it before you query records or items, so you know what fields the collection defines rather than guessing from the data.

This tool has a second job: it supplies the etag that update_item_collection_configuration requires as expected_hash. Read the configuration immediately before every write, since a hash that another change has superseded is rejected.

By default you get the LATEST version. Pass a configuration_id version hash to fetch a historical version instead. That's how you compare the schema a past job ran with against the current one, because each job record from search_datahub_jobs carries the configuration_id that was active when it ran. A collection with no configuration yet returns an error, as does a configuration_id that isn't in the version history. Timestamps here are ISO 8601 strings, unlike the Unix epoch floats that search_item_collections returns. This tool is in alpha, so its API or response shape may change.

Request parameters

NameTypeRequired?Description
workspace_idstrYesThe workspace ID returned by list_workspaces.
collection_namestrYesThe collection name returned by search_item_collections.
configuration_idstrNoThe configuration version to fetch. Defaults to LATEST. Pass a version hash to fetch a historical version, such as the configuration_id a past job ran with.

Response parameters

The tool returns a CollectionConfigurationResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the request succeeded.
dataCollectionConfiguration | nullThe requested configuration, LATEST by default.
detailslist[Any]Additional detail messages from the API.
errorstr | nullError message if the request failed.

The CollectionConfiguration object has the following fields:

FieldTypeDescription
createdstr | nullISO 8601 timestamp of when the configuration was created.
created_by_idstr | nullThe ID of the user or service that created the configuration.
editedstr | nullISO 8601 timestamp of when the configuration was last edited.
edited_by_idstr | nullThe ID of the user or service that last edited the configuration.
etagstr | nullThe configuration version hash. Pass it as expected_hash on update_item_collection_configuration.
collection_schemaCollectionConfigurationSchema | nullThe attribute and identifier schema definitions. The API field name is schema.
destinationslist[dict[str, Any]]The destination pipeline configurations.

The CollectionConfigurationSchema object has the following fields:

FieldTypeDescription
attributeslist[dict[str, Any]]The custom attribute definitions.
identifierslist[dict[str, Any]]The identifier field definitions.

update_item_collection_configuration

Applies a change-list to an item collection's configuration. Each entry names an action of add, modify, or remove, an object_type of schema.attribute, schema.identifier, or destination, and the compound keys that identify the target object. Use it to add a custom attribute, repoint a destination, or retire a field that your feed no longer sends.

The tool uses optimistic concurrency. Call get_item_collection_configuration immediately before writing and pass data.etag as expected_hash. A stale hash returns an error, which means someone or something else changed the configuration between your read and your write, so re-read and rebuild the change-list. The tool also pre-validates keys locally: modify or remove on a key that isn't in the current configuration is rejected, as is add on a key that already exists. That check exists because the backend would otherwise accept the request and silently do nothing.

Two read tools pair with this one. Run validate_item_collection_attribute on each attribute new_value before you write, and use compare_item_collection_configurations to build or review the change-list. Set on_success_trigger if you want a pipeline such as update-items to run after the write succeeds, and expect the response details to mention any downstream job the platform rate-limited. Changes here alter the live schema and destinations and can trigger reindex jobs, so confirm the collection with the user first. A blank workspace_id is rejected before any call is made. Writes are audited with a full before-state snapshot and throttled to one call every five seconds and 10 per minute. This tool is in alpha, so its API or response shape may change.

Request parameters

NameTypeRequired?Description
workspace_idstrYesThe workspace ID returned by list_workspaces.
collection_namestr | nullYesThe name of the collection to update. Confirm the exact name with the user. Use search_item_collections to list the options.
expected_hashstr | nullYesThe configuration version hash from data.etag on get_item_collection_configuration. Read it immediately before calling.
changeslist[ConfigurationChange]YesThe ordered change-list to apply.
on_success_triggerlist[str] | nullNoPipelines to trigger after a successful write, such as update-items.

Each ConfigurationChange object has the following fields:

FieldTypeDescription
actionstrThe change action: add, modify, or remove.
object_typestrThe object type: schema.attribute, schema.identifier, or destination.
keysdictThe compound key identifying the object. Attributes use name, item_type, family, and level. Identifiers use item_type, family, and level. Destinations use name and type.
new_valuedict | nullThe object definition for add and modify. Omit it for remove.

Response parameters

The tool returns a CollectionConfigurationWriteResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the write succeeded.
dataCollectionConfiguration | nullThe updated configuration, including the new etag and any jobs_triggered.
detailslistAdditional detail messages from the API, such as downstream jobs that were rate-limited.
errorstr | nullError message if the write failed.

compare_item_collection_configurations

Compares a candidate configuration against a stored base version and returns the difference as a change-list. The change-list uses the same ConfigurationChange shape that update_item_collection_configuration accepts, so you can review a diff and then apply the entries you want. Nothing is written.

Set the base version with configuration_id, which defaults to LATEST. Describe the candidate one of two ways. Pass compare_schema and compare_destinations together to compare against a configuration you've assembled inline, or pass compare_collection_name and compare_configuration_id together to compare against another stored version. Reference mode works across collections in the same workspace, which is how you check whether a staging collection and a production collection have drifted apart.

The backend may add display fields such as display_type and display_name to each change, and compare output also carries original_value. Only action, object_type, keys, and new_value matter when you pass the changes on to a write. Validate any attribute changes with validate_item_collection_attribute before you apply them. This tool is in alpha, so its API or response shape may change.

Request parameters

NameTypeRequired?Description
workspace_idstrYesThe workspace ID returned by list_workspaces.
collection_namestrYesThe collection name that holds the base configuration.
configuration_idstrNoThe base configuration version. Defaults to LATEST. Pass a version hash for a historical base.
compare_schemadict[str, Any] | nullNoThe inline candidate schema, with attributes and identifiers. Requires compare_destinations.
compare_destinationslist[dict[str, Any]] | nullNoThe inline candidate destinations list. Requires compare_schema.
compare_collection_namestr | nullNoThe collection name holding a stored candidate configuration. Requires compare_configuration_id.
compare_configuration_idstr | nullNoThe configuration version hash, or LATEST, for the stored candidate. Requires compare_collection_name.

Provide either the inline pair, compare_schema and compare_destinations, or the reference pair, compare_collection_name and compare_configuration_id.

Response parameters

The tool returns a ConfigurationCompareResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the comparison succeeded.
dataConfigurationCompareData | nullThe diff change-list when the call succeeded.
errorstr | nullError message if the comparison failed.

The ConfigurationCompareData object has the following fields:

FieldTypeDescription
changeslist[ConfigurationChange]The changes from base to candidate, in the same shape as the changes parameter on update_item_collection_configuration.

validate_item_collection_attribute

Checks a single attribute definition without writing anything. Call it when you want to add or modify a custom attribute and need to catch a malformed definition before it reaches the configuration. A success value of true means the definition is valid, and false comes back with an error message explaining what to fix.

The recommended sequence is to read the current schema with get_item_collection_configuration, validate the proposed attribute here, then include it as an add or modify change on update_item_collection_configuration. Re-read the configuration immediately before that write so you pass a current expected_hash.

This tool validates attribute definitions only. Identifier and destination changes have no validation endpoint, so those are checked when you apply them on the write tool. Use it before every attribute add or modify where the shape is new or uncertain. This tool is in alpha, so its API or response shape may change.

Request parameters

NameTypeRequired?Description
workspace_idstrYesThe workspace ID returned by list_workspaces.
collection_namestrYesThe collection name returned by search_item_collections.
attributedict[str, Any]YesThe attribute definition to validate, for example {'name': 'title', 'item_type': 'product', 'family': 'main', 'level': 'parent', 'data_type': 'String'}.

Response parameters

The tool returns a ConfigurationValidateResponse object with the following parameters:

ParameterTypeDescription
successboolWhether the attribute definition is valid.
errorstr | nullThe validation or request error message when it isn't valid.

Did this page help you?

© Bloomreach, Inc. All rights reserved.