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

# Replace cancel

{% 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/cancel` to close an open replace session without an apply. Batch discards the pending revision and all its staged items. The live catalog does not change.

## Replace Cancel

> \*\*Beta.\*\* Catalog replace is a Beta feature and can change. Send the \`Batch-Beta: catalog-replace\` header on each call.\
> \<br/>\<br/>Cancels an open replace session. Batch discards the pending revision and all of its items. The live catalog does not change. A session that is already complete or cancelled returns \`409 CATALOG\_REPLACE\_UNKNOWN\`.<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"}}}},"replaceUnknownSession":{"description":"The replace session is unknown or no longer open.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/catalogs/replace/cancel":{"post":{"operationId":"catalog_replace_cancel","summary":"Replace Cancel","description":"**Beta.** Catalog replace is a Beta feature and can change. Send the `Batch-Beta: catalog-replace` header on each call.\n<br/><br/>Cancels an open replace session. Batch discards the pending revision and all of its items. The live catalog does not change. A session that is already complete or cancelled returns `409 CATALOG_REPLACE_UNKNOWN`.\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/replaceUnknownSession"},"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 cancels a replace session:

`/catalogs/replace/cancel`

**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 session is closed. Batch discards the pending revision.

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