# Batches   Batch out and Open Batches Query

## Get Current Open Batch

> Retrieve the currently open batch on the gateway for the terminal.

```json
{"openapi":"3.0.1","info":{"title":"Batches","version":"2.0"},"paths":{"/rest/v1/batches/open":{"get":{"tags":["Batches - Batch out and Open Batches Query"],"summary":"Get Current Open Batch","description":"Retrieve the currently open batch on the gateway for the terminal.","operationId":"getOpenBatch_1","parameters":[{"name":"api-key","in":"header","description":"An access API key issued to you by Xplor Pay.","required":true},{"name":"refund-count","in":"query","description":"Total number of refund transactions in the batch."},{"name":"refund-total","in":"query","description":"Total number of refund transactions in the batch."},{"name":"sales-count","in":"query","description":"Total number of sale transactions in the batch."},{"name":"sales-total","in":"query","description":"Total amount of sale transactions in the batch."},{"name":"net-amount","in":"query","description":"Total amount of transactions in the batch."},{"name":"total-count","in":"query","description":"Total number of transactions in the batch."},{"name":"confirmation-code","in":"query","description":"Confirmation code for the settled batch."},{"name":"settled","in":"query","description":"Date and time when the batch was settled."},{"name":"status","in":"query","description":"The status of the batch."}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/batch"}},"application/xml":{"schema":{"$ref":"#/components/schemas/batch"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}}}}}},"components":{"schemas":{"batch":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the open batch."},"status":{"type":"string","description":"Current status of the batch."},"settled":{"type":"string","description":"Indicates whether the batch has been settled."},"refund_count":{"type":"string","description":"Total number of refund transactions in the batch."},"refund_total":{"type":"string","description":"Total amount of refunds processed in the batch."},"sales_count":{"type":"string","description":"Total number of sales transactions in the batch."},"sales_total":{"type":"string","description":"Total amount of sales processed in the batch."},"net_amount":{"type":"string","description":"Net amount for the batch after sales and refunds are applied."},"total_count":{"type":"string","description":"Total number of transactions in the batch."},"confirmation_code":{"type":"string","description":"Confirmation code when the batch is opened or updated."}},"xml":{"name":"batch"}},"ErrorPayloadResponsePayload":{"type":"object","properties":{"error":{"$ref":"#/components/schemas/ErrorPayload"},"payloadType":{"type":"string","description":"Type of payload returned in the response.","xml":{"name":"type","attribute":true}}},"description":"Payload","xml":{"name":"payload"}},"ErrorPayload":{"type":"object","properties":{"error-message":{"type":"string","description":"Describes the reason for the error."},"result-code":{"type":"string","description":"Numeric code that identifies the type of error returned by the request."},"time-stamp":{"type":"string","description":"Date and time when the error occurred, ISO 8601 format (UTC)."}},"xml":{"name":"error"}}}}}
```

## Close Current Open Batch

> Close the currently open batch on the gateway.

```json
{"openapi":"3.0.1","info":{"title":"Batches","version":"2.0"},"paths":{"/rest/v1/batches/open":{"put":{"tags":["Batches - Batch out and Open Batches Query"],"summary":"Close Current Open Batch","description":"Close the currently open batch on the gateway.","operationId":"closeOpenBatch_1","parameters":[{"name":"api-key","in":"header","description":"An access API key issued to you by Xplor Pay.","required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncomingBatchRequest"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/batch"}},"application/xml":{"schema":{"$ref":"#/components/schemas/batch"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}},"application/xml":{"schema":{"$ref":"#/components/schemas/ErrorPayloadResponsePayload"}}}}}}}},"components":{"schemas":{"IncomingBatchRequest":{"type":"object","properties":{"lastBatchClosedRequiredInResponse":{"type":"boolean","description":"Indicates whether the response must include details about the last batch that was closed.","readOnly":true},"software-type":{"type":"string","description":"Identifies the type of software that initiated the batch close request."}},"description":"Request payload for closing the batch","xml":{"name":"batch-validation"}},"batch":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the open batch."},"status":{"type":"string","description":"Current status of the batch."},"settled":{"type":"string","description":"Indicates whether the batch has been settled."},"refund_count":{"type":"string","description":"Total number of refund transactions in the batch."},"refund_total":{"type":"string","description":"Total amount of refunds processed in the batch."},"sales_count":{"type":"string","description":"Total number of sales transactions in the batch."},"sales_total":{"type":"string","description":"Total amount of sales processed in the batch."},"net_amount":{"type":"string","description":"Net amount for the batch after sales and refunds are applied."},"total_count":{"type":"string","description":"Total number of transactions in the batch."},"confirmation_code":{"type":"string","description":"Confirmation code when the batch is opened or updated."}},"xml":{"name":"batch"}},"ErrorPayloadResponsePayload":{"type":"object","properties":{"error":{"$ref":"#/components/schemas/ErrorPayload"},"payloadType":{"type":"string","description":"Type of payload returned in the response.","xml":{"name":"type","attribute":true}}},"description":"Payload","xml":{"name":"payload"}},"ErrorPayload":{"type":"object","properties":{"error-message":{"type":"string","description":"Describes the reason for the error."},"result-code":{"type":"string","description":"Numeric code that identifies the type of error returned by the request."},"time-stamp":{"type":"string","description":"Date and time when the error occurred, ISO 8601 format (UTC)."}},"xml":{"name":"error"}}}}}
```


---

# Agent Instructions: 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:

```
GET https://docs.xplorpay.com/api-reference/api/payments/batches/batches-batch-out-and-open-batches-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
