> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/developer/api/cep/catalogs/replace-items.md).

# Replace items

{% hint style="info" %}
**Beta.** Catalog replace is a Beta feature and its API surface may change before GA. You must send the `Batch-Beta: catalog-replace` header with each replace call.
{% endhint %}

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.

## Replace Items

> \*\*Beta.\*\* Catalog replace is a Beta feature and can change. Send the \`Batch-Beta: catalog-replace\` header on each call.\
> \<br/>\<br/>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.\
> \<br/>\<br/>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.<br>

```json
{"openapi":"3.1.0","info":{"title":"Batch - REST API","version":"2.9"},"tags":[{"name":"Catalogs"}],"servers":[{"url":"https://api.batch.com/{version}","description":"production","variables":{"version":{"default":"2.12","description":"Version of the API"}}}],"security":[{"rest_key":[]}],"components":{"securitySchemes":{"rest_key":{"type":"http","scheme":"bearer","description":"## API Key Authentication\n\nAuthentication is required in order to interact with Batch's APIs.\n\nBatch implements authentication using API Keys, that we call the \"REST API Key\".\nYou can find it on your dashboard.\n\nPlease make sure that you keep this key secret. You should never use it in client apps to call APIs from there as it would\neasily be extractable.\n\n### How to authenticate\n\nIn order to authenticate your requests, add your REST API Key in the `Authorization` header and prefix it by `Bearer`. Example: `Authorization: Bearer bcd38d9rfb38ra28`.\n"}},"parameters":{"HeaderProjectKey":{"in":"header","name":"X-Batch-Project","description":"The unique project key, identifying a project on the Batch platform","schema":{"type":"string"},"required":true},"HeaderBatchBetaReplace":{"in":"header","name":"Batch-Beta","description":"Beta opt-in. This endpoint is in Beta. It accepts only requests that carry the `catalog-replace` flag. Batch rejects a request without the flag with a `400`.\n","schema":{"$ref":"#/components/schemas/BatchBetaFlags"},"required":true}},"schemas":{"BatchBetaFlags":{"description":"Value of the `Batch-Beta` header. It is a comma-separated list of Beta contract flags. Thus one request can opt into more than one Beta contract at the same time (`first-flag, second-flag`). Flags are lowercase and case-sensitive, and the order does not matter. Batch rejects an unknown flag with a `400` on any endpoint. When a contract becomes generally available, Batch continues to accept its flag but the flag has no more effect. Thus you never need to remove it.\n","type":"string"},"attributes":{"type":"object","description":"A map of attribute keys to values.\nKey rules:\n  - `url(...)` → value must be a valid URL\n  - `date(...)` → value must be RFC 3339 or Unix timestamp\n  - `^[a-z0-9_]+$` → regular attribute names\n","additionalProperties":{"oneOf":[{"type":"array","maxItems":15,"items":{"type":"string","maxLength":64}},{"type":"boolean"},{"type":"integer"},{"type":"number","format":"float"},{"type":"string","maxLength":10000},{"type":"string","format":"date-time"},{"type":"integer","format":"int64"},{"type":"string","format":"uri"}]}},"EmptyResponse":{"type":"object"},"Error":{"type":"object","required":["error_message","error_code"],"properties":{"error_message":{"description":"A human readable error message","type":"string"},"error_code":{"description":"Error code","type":"string"}}}},"responses":{"400":{"description":"The request is malformed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The Rest API Key is not valid for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Unexpected error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Batch's services are under maintenance. Please try again later","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"replaceItemsAccepted":{"description":"Batch 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. <br/>To see the indexing progress, read the `pending_replace` block of `/catalogs/view`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmptyResponse"}}}},"replaceUnknownSession":{"description":"The replace session is unknown or no longer open.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/catalogs/replace/items":{"post":{"operationId":"catalog_replace_items","summary":"Replace Items","description":"**Beta.** Catalog replace is a Beta feature and can change. Send the `Batch-Beta: catalog-replace` header on each call.\n<br/><br/>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.\n<br/><br/>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.\n","tags":["Catalogs"],"parameters":[{"$ref":"#/components/parameters/HeaderProjectKey"},{"$ref":"#/components/parameters/HeaderBatchBetaReplace"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["replace_token","items"],"properties":{"replace_token":{"type":"string","description":"Token that `/catalogs/replace/start` returns."},"items":{"type":"array","minItems":1,"maxItems":200,"description":"List of catalog items to add to the pending revision.","items":{"type":"object","required":["action","id","attributes"],"properties":{"id":{"type":"string","description":"Unique identifier of the catalog item."},"action":{"type":"string","enum":["add"],"description":"Action to do on the catalog item. A replace accepts only `add`, because the pending revision starts empty."},"attributes":{"type":"object","$ref":"#/components/schemas/attributes"}}}}}}}}},"responses":{"202":{"$ref":"#/components/responses/replaceItemsAccepted"},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"409":{"$ref":"#/components/responses/replaceUnknownSession"},"429":{"$ref":"#/components/responses/429"},"500":{"$ref":"#/components/responses/500"},"503":{"$ref":"#/components/responses/503"}}}}}}
```

#### 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. This endpoint also needs the `Batch-Beta: catalog-replace` header.

**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.

```json
{
  "replace_token": "eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5f",
  "items": [
    {
      "action": "add",
      "id": "1",
      "attributes": {
        "title": "Squid Game",
        "description": "Hundreds of cash-strapped players accept a strange invitation to compete in children's games.",
        "cast": [
          "Lee Jung-jae",
          "Park Hae-soo",
          "Wi Ha-jun"
        ]
      }
    }
  ]
}
```

### 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.

```json
{}
```

#### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.batch.com/developer/api/cep/catalogs/replace-items.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
