> 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-complete.md).

# Replace complete

{% 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/complete` to apply the pending revision in one atomic operation. When the call is successful, the catalog serves the new revision. Batch removes the previous contents. Readers see the full old catalog, then the full new catalog. They never see a state between the two.

## Replace Complete

> \*\*Beta.\*\* Catalog replace is a Beta feature and can change. Send the \`Batch-Beta: catalog-replace\` header on each call.\
> \<br/>\<br/>Applies the pending revision in one atomic operation. When this call is successful, the catalog serves the new revision and Batch removes the previous contents. Readers see the complete old catalog, then the complete new catalog. They never see a state between the two.\
> \<br/>\<br/>Batch must index every item in the pending revision before you can apply it. If indexing is not complete, the call returns \`409 CATALOG\_REPLACE\_NOT\_READY\`. Retry the call after a short delay. To follow the progress, read the \`pending\_replace\` block of \`/catalogs/view\`.<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"},"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"}}}},"200_empty":{"description":"Empty success response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmptyResponse"}}}},"replaceCompleteConflict":{"description":"You cannot apply the pending revision.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/catalogs/replace/complete":{"post":{"operationId":"catalog_replace_complete","summary":"Replace Complete","description":"**Beta.** Catalog replace is a Beta feature and can change. Send the `Batch-Beta: catalog-replace` header on each call.\n<br/><br/>Applies the pending revision in one atomic operation. When this call is successful, the catalog serves the new revision and Batch removes the previous contents. Readers see the complete old catalog, then the complete new catalog. They never see a state between the two.\n<br/><br/>Batch must index every item in the pending revision before you can apply it. If indexing is not complete, the call returns `409 CATALOG_REPLACE_NOT_READY`. Retry the call after a short delay. To follow the progress, read the `pending_replace` block of `/catalogs/view`.\n","tags":["Catalogs"],"parameters":[{"$ref":"#/components/parameters/HeaderProjectKey"},{"$ref":"#/components/parameters/HeaderBatchBetaReplace"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["replace_token"],"properties":{"replace_token":{"type":"string","description":"Token that `/catalogs/replace/start` returns."}}}}}},"responses":{"200":{"$ref":"#/components/responses/200_empty"},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"409":{"$ref":"#/components/responses/replaceCompleteConflict"},"429":{"$ref":"#/components/responses/429"},"500":{"$ref":"#/components/responses/500"},"503":{"$ref":"#/components/responses/503"}}}}}}
```

#### Request structure

**Route**

The Catalog API has a POST endpoint that applies the pending revision of a replace session:

`/catalogs/replace/complete`

Batch must index each item in the pending revision before you apply it. To see the progress, read the `pending_replace` block of `/catalogs/view`. Its `indexing_state` must be `APPLIED`.

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

```json
{
    "replace_token": "eqRqTF7xFznYoG0MLs1sIqM1JhmhGLTZ7I5NtM5f"
}
```

### Responses

#### Success

If the call is successful, you receive an HTTP 200 confirmation with an empty body. The catalog now serves the new revision.

#### Failure

You receive an HTTP 409 in these cases:

* `CATALOG_REPLACE_UNKNOWN`: the replace\_token is unknown, or its session is complete or cancelled.
* `CATALOG_REPLACE_NOT_READY`: the pending revision is still in indexing. Wait a short time and try again.
* `CATALOG_REPLACE_INCONSISTENT`: the staged items do not agree. Cancel the session and start a new replace.

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