Replace items
Use /catalogs/replace/items to add items to the pending revision of an open replace session. Reads of the live catalog do not see these items. The items become live only when you complete the replace.
Adds a batch of items to the pending revision of an open session. The items have the same structure, validation, and rate limit as /catalogs/items/edit. The items are not visible to reads of the live catalog until you complete the replace.
Send as many batches as necessary to load the full catalog. The pending revision starts empty, thus every item is an add. Send each item id only once per session. If you send the same id two times, the session becomes inconsistent and you cannot complete it.
API Key Authentication
Authentication is required in order to interact with Batch's APIs.
Batch implements authentication using API Keys, that we call the "REST API Key". You can find it on your dashboard.
Please make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would easily be extractable.
How to authenticate
In order to authenticate your requests, add your REST API Key in the Authorization header and prefix it by Bearer. Example: Authorization: Bearer bcd38d9rfb38ra28.
The unique project key, identifying a project on the Batch platform
project_0664hxvwffvbpn278gxdyhsadddqgna6Token that /catalogs/replace/start returns.
eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5fBatch added the items to the pending revision. The items are not visible to reads of the live catalog until you complete the replace. Batch returns no indexing token, and the body is an empty JSON object.
To see the indexing progress, read the pending_replace block of /catalogs/view.
The request is malformed
The Rest API Key is not valid for this project
The replace session is unknown or no longer open.
Too Many Requests
Unexpected error
Batch's services are under maintenance. Please try again later
POST /2.13/catalogs/replace/items HTTP/1.1
Host: api.batch.com
Authorization: Bearer YOUR_SECRET_TOKEN
X-Batch-Project: text
Content-Type: application/json
Accept: */*
Content-Length: 293
{
"replace_token": "eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5f",
"items": [
{
"id": "CATALOG_ITEM_ID",
"action": "add",
"attributes": {
"product_name": "Sample Product",
"price": 19.99,
"tags": [
"summer",
"sale"
],
"date(launch_date)": "2023-08-01T12:00:00Z",
"available": true,
"url(website)": "https://example.com"
}
}
]
}{}Rate Limiting
Items that you send to a replace session have the same limits as /catalogs/items/edit:
You can send up to 5 requests per second.
Batch adds up to 1000 items per second.
If you go above these limits, the API returns an HTTP 429 Too Many Requests error. If you receive this error, wait a few seconds and try again.
Request structure
Route
The Catalog API has a POST endpoint that adds items to the pending revision of a replace session:
/catalogs/replace/items
You can send one or more items in each call, up to a limit of 200 items. Send as many batches as necessary to load the full catalog.
Headers and authentication
See Overview → Using Project APIs.
Post data
The body of the request must contain a valid JSON payload. The payload gives the replace_token from /catalogs/replace/start and the list of items to add.
The pending revision starts empty. Thus each item uses the add action. Send each item id only one time per session. If you send the same id two times, the session becomes inconsistent and you cannot complete it.
Responses
Success
If the call is successful, you receive an HTTP 202 confirmation. The body is an empty JSON object. Batch does not return an indexing token. To see the indexing progress of the pending revision, read the pending_replace block of /catalogs/view.
Failure
If the replace_token is unknown, or its session is complete or cancelled, you receive an HTTP 409 with the CATALOG_REPLACE_UNKNOWN error code.
For each other problem, you receive an error message that tells you what to do. Contact us at support@batch.com if you need more help.
Last updated

