Crownpeak
  • Product Discovery Developer Guide
  • 🛒Item catalog management
    • What is the Items API?
    • How to work with Items
      • Item Schema
        • Attributes
        • Nested Item Schemas
        • Using the Item Schema API
        • DefaultLocale API
        • Onboarding on/migrating to Fredhopper
        • List of Reserved Attributes
      • Category Tree
        • Using the Category Tree API
        • Onboarding on XO
      • Item Catalog
        • Using the Catalog API
      • Items
        • Using the streaming Items API
        • Using the batch Items API
    • Step by Step guide
      • Step by step guide for Fredhopper customers
    • Feedback
      • Using the Feedback API
    • Authorization to APIs
    • Troubleshooting API errors
  • 🎯XO Recommendations
    • Introduction
    • Using the Recommendations API
    • Setting up the Chrome extension
    • Micro-segmentation
    • XO Legacy APIs
  • 🔎XO Search
    • Introduction
    • Getting started
    • API Reference
      • Search API
      • Autocomplete API (Beta)
      • Product Suggest API
    • API Parameters
      • Search
      • Pagination
      • Faceting
      • Sorting
      • Grouping
      • Filtering
      • Disable features
      • Response mask
      • Context
    • Configuration limitation
  • 🧪A/B testing
    • Fredhopper A/B testing
      • Integration steps for a non-caching solution
      • Integration steps for a caching solution
        • Java SDK Integration
          • Setup
          • Retrieve running A/B tests - Java SDK
          • Filter and request variant - Java SDK
          • Extending the SDK
        • Manual A/B tests integration
          • Retrieve running A/B tests
          • Filter out irrelevant A/B tests
          • Assign variants to user
          • Request variant for page
        • Limitations and Best Practices
  • 📚Resources
    • Glossary
    • Best Practices
      • Tracker Best Practices
      • Items API Best Practices
      • Fredhopper Data Configuration Best Practices
      • Fredhopper Query Response Best Practices
      • Fredhopper Merchandising Studio Best Practices
    • Privacy Notice
  • Archived Pages
    • FHR Tracking plan
    • XO Tracking plan
    • The Tracking API and JS Library
      • What to Track
        • Generic Actions
          • View
          • Click
          • Add to Cart
          • Remove from Cart
          • Purchase
        • Custom Actions
      • Initializing the JavaScript Library
      • REST API Technical Documentation
Powered by GitBook
On this page
  • Migrating from streaming Items API to batch Items API
  • Create a batch
  • Create a default catalog batch
  • List batches
  • Add items to batch
  • Modify items in batch
  • Delete items from batch
  • Batch ingestion
  • Get batch import ingestion
  • List batch import ingestions
  • Delete a batch ingestion
  1. Item catalog management
  2. How to work with Items
  3. Items

Using the batch Items API

PreviousUsing the streaming Items APINextStep by Step guide

Last updated 1 day ago

Required fields are marked with a red asterisk (*) in the Name column.

Use the batch Items API to replace a whole or parts of a catalog.

Migrating from streaming Items API to batch Items API

If you have been using the streaming Items API to send your entire catalog, we recommend migrating to the batch Items API, which has been designed for this purpose specifically.

Fredhopper currently does not support loading batches into active catalogs. Clients integrated with Fredhopper must use this method.

Before you enforce the following changes reach out to Crownpeak to enable the feature.

Implementation changes:

  1. Add a createBatchImport=true query parameter to the .

  2. When sending items:

    1. Change URL from https://items.attraqt.io/items to https://items.attraqt.io/batch-imports/items.

    2. Add a batch_id query parameter with a value set to the catalog version.

    3. Remove catalogVersion from request body attributes.

  3. Once all items are sent, replace the catalog promotion call with a batch ingestion creation similar to the following:

curl --request POST
 --url 'https://items.attraqt.io/batch-imports/ingestions?tenant=$TENANT&environment=$ENVIRONMENT'
 --header 'Authorization: Bearer $ACCESS_TOKEN'
 --header 'Content-Type: application/json'
  --data '{
  "catalogVersion": $CATALOG_VERSION,
  "promoteCatalogOnCompletion": true
}'

Optionally specify minItemCount and minSuccessRatePercent.

Clients integrated with XO only can use this method.

Implementation changes:

  1. Create a batch before sending items, and keep its ID.

curl --request POST 
 --url 'https://items.attraqt.io/batch-imports?tenant=$TENANT&environment=$ENVIRONMENT' 
 --header 'Authorization: Bearer $ACCESS_TOKEN'
  1. When sending items:

    1. Change URL from https://items.attraqt.io/items to https://items.attraqt.io/batch-imports/items.

    2. Add a batch_id query parameter with a value set to the batch ID created earlier.

    3. Remove catalogVersion from request body attributes.

  2. Once all items are sent, launch a batch ingestion.

curl --request POST 
 --url 'https://items.attraqt.io/batch-imports/ingestions?tenant=$TENANT&environment=$ENVIRONMENT' 
 --header 'Authorization: Bearer $ACCESS_TOKEN' 
 --header 'Content-Type: application/json' 
  --data '{
  "batchImportId": $BATCH_ID,
  "catalogVersion": $CATALOG_VERSION,
}'

Create a batch

POST https://items.attraqt.io/batch-imports

This endpoint allows you to import a batch.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

Headers

Name

Description

Authorization*

Response Body

Name

Type

Description

id

string

batch ID

Batches automatically expire after 7 days and can therefore not be ingested after this period.

Create a default catalog batch

You can also create batches automatically along with catalogs:

List batches

GET https://items.attraqt.io/batch-imports

This allows you to retrieve a list of batches.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

Headers

Name

Description

Authorization*

Response body

The response body consists of an array of objects containing the following fields:

Name

Type

Description

id*

object

batch ID

createdAt*

batch creation date

Add items to batch

POST https://items.attraqt.io/batch-imports/items

This allows you to add items to an existing batch.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

batch_id*

batch ID

Headers

Name

Description

Authorization*

Content-Type*

application/json

Request body

The request body consists of an array of JSON items with the following fields:

Name

Type

Description

id*

string

Item ID; can not be empty and can only include alphanumeric characters, underscores, and hyphens

type*

string

context

string

Context (store ID, private sales...); can only include alphanumeric characters, underscores, and hyphens

timestamp

defaults to current time stamp; allows for ordering insertion, modification, and deletion operations on the same item

parentId

string

Parent item, if item is a variant

attributes*

object

Sample request body:
[
   {
        "id": "id1",
        "type": "product",
        "timestamp": "2024-09-05T10:50:42Z",
        "attributes": {
            "title": "Item 1",
            "url": "https://example.com/item1"
        }
   },
   {
        "id": "id2",
        "type": "variant",
        "parentId": "id1",
        "attributes": {
            "size": 2
        }
    }
]

Response body

Results are returned in the form of an array. Each array element corresponds to an item in the request body. The results have the following fields:

Name

Type

Description

id*

object

ID, type, and context of the item

code*

integer

0 means success, any other value is an internal error code

message

string

Error message if code is different from 0

A success code (0) means that the item has been added into the batch, but not necessarily that the item is valid.

Items can only be validated against a specific schema during batch ingestions once the target catalog is defined.

Modify items in batch

PATCH https://items.attraqt.io/batch-imports/items

This allows you to modify the items included in an existing batch.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

batch_id*

batch ID

Headers

Name

Description

Authorization*

Content-Type*

application/json

Request body

The request body consists of an array of JSON items with the following fields:

Name

Type

Description

id*

string

Item ID; can not be empty and can only include alphanumeric characters, underscores and hyphens

type*

string

context

string

Context (store ID, private sales...); can only include alphanumeric characters, underscores and hyphens

timestamp

Defaults to current time stamp; allows ordering insertion, modification, and deletion operations on the same item

parentId

string

Parent item, if item is a variant

attributes

object

Item attributes that need to be modified; unchanged attributes don’t have to be included

sample request body:

Sample request body:
[{
        "id": "id1",
        "type": "product",
        "attributes": {
		    "url": "https://example.com/item1_patch"
        }
}]

Response body

Delete items from batch

POST https://items.attraqt.io/batch-imports/items/delete

This allows you to delete items from an existing batch.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

batch_id*

batch ID

Headers

Name

Description

Authorization*

Content-Type*

application/json

Request body

The request body consists of an array of JSON items with the following fields:

Name

Type

Description

id*

string

Item ID; can not be empty and can only include alphanumeric characters, underscores and hyphens

type*

string

context

string

Context (store ID, private sales...); can only include alphanumeric characters, underscores and hyphens

timestamp

Defaults to current time stamp; allows ordering insertion, modification, and deletion operations on the same item

Sample request body:
[{
  "id": "id1",
  "type": "product"
}]

Batch ingestion

Ingesting a batch in a catalog will:

  • Validate all items in the batch against catalog item schema

  • Check that the absolute and relative number of items that pass validation is above the optionally provided threshold

  • Insert all items that passed validation in the provided catalog

  • Optionally promote the catalog

POST https://items.attraqt.io/batch-imports/ingestions

This allows you to ingest a batch.

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

Headers

Name

Description

Authorization*

Content-Type*

application/json

Request body

Name

Type

Default value

Description

batchImportId

string

default catalog batch

batch ID returned by the batch creation call; leave empty when ingesting the default catalog batch

catalogVersion*

string

version of the catalog in which the batch must be ingested

minItemCount

number

0

Minimum number of items in the batch that should pass schema validation; ingestion will fail if this threshold is not reached

minSuccessRatePercent

number

0

Minimum percentage of items in the batch that should pass schema validation; ingestion will fail if this threshold is not reached

source

string

empty string

Source of items in the batch, can be any string; this field is only meaningful when used in conjunction with deleteMissingItems

deleteMissingItems

boolean

false

whether items with same source present in the catalog but not present in the batch must be deleted

promoteCatalogOnCompletion

boolean

false

whether the catalog must be promoted after having been loaded

Response body

Name

Type

Description

id

string

batch ingestion ID; can be used to query batch ingestion status

Get batch import ingestion

GET https://items.attraqt.io/batch-imports/ingestions/{id}

This allows you to retrieve the status of a batch ingestion.

Path Parameters

Name

Type

Description

id*

string

ID of batch import ingestion to get

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

Headers

Name

Description

Authorization*

Response body

Name

Type

Required

Description

id*

string

yes

Batch ingestion ID

status*

string

yes

Results in one of the following:

  • RUNNING

  • SUCCESS

  • FAILURE (invalid batch, e.g. quality threshold was not met)

  • ERROR(unexpected error)

statusReason

string

if status is FAILURE or ERROR

Reason why the ingestion failed or errored

itemErrorCount

number

if status is SUCCESS or FAILURE

Number of items that didn’t pass validation

itemErrorsSummary

object

if status is SUCCESS or FAILURE

Number of errors by error type, with some Sample error IDs

upsertedItemCount

number

if status is SUCCESS

Number of items that were either inserted or updated in the catalog

deletedItemCount

number

if status is SUCCESS and batch ingestion was launched with deleteMissingItems set to true

Number of items that were deleted from the catalog

duration

string

if status is SUCCESS or FAILURE

Duration of batch ingestion in seconds

createdAt*

yes

Creation timestamp

updatedAt*

yes

Last time batch ingestion status was updated

configuration*

object

yes

Batch ingestion configuration; format is the same as batch ingestion creation request body

Fredhopper currently does not support loading batches into active catalogs. If you try to ingest a batch into the active catalog of a Fredhopper client, it will result in an HTTP 400 error.

You can only ingest one batch into a given catalog at any given time. If you try to load a batch into a catalog which already has a running batch ingestion, it will result in an HTTP 409 error. Once the first ingestion is complete, you can launch another into the same catalog.

Catalogs cannot be promoted during an active batch ingestion. If you try to do so, it will result in an HTTP 409 error.

List batch import ingestions

GET https://items.attraqt.io/batch-imports/ingestions

This allows you to get the status for all ingestions.

Query Parameters

Name

Type

Description

tenant*

string

environment

string

lookback_duration

number

Time window in milliseconds, going back from now

status

string

Filters ingestions by their status. Possible values: RUNNING, SUCCESS, ERROR, FAILURE

Headers

Name

Description

Authorization*

Response body

Delete a batch ingestion

Batches will be automatically deleted seven days after their creation date, but they can be deleted earlier if they are not longer needed.

DELETE https://items.attraqt.io/batch-imports/ingestions/{id}

This allows you to delete a certain batch.

Path Parameters

Name

Type

Description

id*

string

ID of batch import ingestion to delete

Query Parameters

Name

Type

Description

tenant*

string

environment*

string

Headers

Name

Description

Authorization*

Add a createBatchImport=true query parameter to the . -> The ID of this default catalog batch is identical to the catalog version.

returned by the OR

identical to catalog version for

name

, e.g. 1985-04-12T23:20:50.52Z

c.f.

returned by the OR

identical to catalog version for

name

, e.g. 1985-04-12T23:20:50.52Z

The structure of the response body when modifying items is identical to the structure of the .

returned by the OR

identical to catalog version for

name

, e.g. 1985-04-12T23:20:50.52Z

The for which you want to list ingestions. This parameter can be set multiple times, or none to fetch ingestions for all environments

The response body lists all batch ingestions for the active tenant and environment and has the same format as the response body.

🛒
This API requires Authentication.
catalog creation call
catalog creation call
response body when adding items
Get batch import ingestion
Bearer token
Bearer token
RFC 3339 Internet date/time format
Bearer token
Item schema
RFC 3339 Internet date/time format
item attributes
Bearer token
Item schema
RFC 3339 Internet date/time format
Bearer token
Item schema
RFC 3339 Internet date/time format
Bearer token
Bearer token
RFC 3339 Internet date/time format
RFC 3339 Internet date/time format
Bearer token
Bearer token
batch creation call
default catalog batches
batch creation call
default catalog batches
batch creation call
default catalog batches
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
Your environment ID
Your tenant ID
environment
Your tenant ID
Your environment ID