> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.recurrente.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.recurrente.com/_mcp/server.

# Cerrar lote de terminal

POST https://app.recurrente.com/api/terminal_batch_closes
Content-Type: application/json

Cierra el lote abierto actual de una terminal POS. Recurrente marca el lote como `closed`, calcula sus totales y deja la terminal lista para abrir un nuevo lote automáticamente con el próximo pago.

Este endpoint es útil para integraciones que controlan el POS desde un sistema externo y necesitan cerrar lote sin operar la pantalla de la terminal.

Envía `Idempotency-Key` para reintentos seguros: si tu sistema pierde la respuesta después de cerrar el lote, repetir el mismo request con la misma clave devuelve la respuesta original en vez de intentar cerrar otro lote.


Reference: https://docs.recurrente.com/referencia-api/api-reference/terminal-batch-closes/close-terminal-batch

## Authentication

- `X-SECRET-KEY` header (required) — Tu clave secreta de API. Una llave de cuenta (`sk_live_...`, `sk_test_...`) opera sobre su propia cuenta y, con `X-ACCOUNT-ID`, sobre sus cuentas conectadas. La llave también fija el ambiente: una `sk_test_` solo lista y resuelve objetos de prueba (`live_mode: false`) y una `sk_live_` solo objetos reales. Un ID del otro ambiente responde `404` (`401` en `/customers`). Una llave de organización (`sk_org_live_...`, `sk_org_test_...`) alcanza todas las cuentas de una organización y solo sirve para leer: saldos, movimientos y reportes. Para operar sobre una cuenta debe nombrarla con `X-ACCOUNT-ID`; omitirlo en una lectura devuelve todas las cuentas de la organización. Cualquier otro endpoint responde `403` con `code: organization_key_unsupported`.

## Request

### Headers

- `Idempotency-Key` (string, optional) — Clave de idempotencia para reintentos seguros de operaciones críticas, especialmente las que mueven dinero o cambian estado operativo. Reintentar con la misma clave y el mismo cuerpo devuelve la respuesta original (header `Idempotency-Replayed: true`); reusarla con parámetros distintos devuelve 409.

### Body (application/json)

This endpoint expects an object.

- `terminal_id` (string, required) — ID de la terminal POS cuyo lote abierto quieres cerrar

## Response

### 200

Lote cerrado exitosamente

- `id` (string, optional) — ID del lote cerrado
- `status` (enum, optional) — Estado del lote
  - Allowed values: `open`, `closed`, `settled`
- `terminal_id` (string, optional) — ID de la terminal POS
- `transaction_count` (integer, optional) — Cantidad de transacciones exitosas incluidas en el lote
- `total_in_cents` (integer, optional) — Total agregado del lote en centavos
- `total_currency` (enum, optional) — Moneda principal del lote
  - Allowed values: `GTQ`, `USD`
- `totals_by_currency` (map from string to integer, optional) — Totales del lote agrupados por moneda
- `opened_at` (datetime, optional) — Fecha y hora en que se abrió el lote
- `closed_at` (datetime, optional, nullable) — Fecha y hora en que se cerró el lote

## Errors

### 404 Not Found Error

Terminal no encontrada o no asociada a tu cuenta

- `message` (string, optional) — Mensaje de error
- `code` (string, optional) — Código estable legible por máquinas, cuando aplica
- `refund_id` (string, optional) — ID del reembolso relacionado cuando aplica
- `endpoint` (string, optional) — Acción de API rechazada, cuando aplica
- `errors` (ErrorErrors, optional) — Detalles de errores por campo

### 422 Unprocessable Entity Error

La terminal no tiene un lote abierto para cerrar

- `message` (string, optional) — Mensaje de error
- `code` (string, optional) — Código estable legible por máquinas, cuando aplica
- `refund_id` (string, optional) — ID del reembolso relacionado cuando aplica
- `endpoint` (string, optional) — Acción de API rechazada, cuando aplica
- `errors` (ErrorErrors, optional) — Detalles de errores por campo

## Types

### ErrorErrors

Detalles de errores por campo

## Examples

**Request**

```json
{
  "terminal_id": "trm_abc123"
}
```

**Response**

```json
{
  "id": "tb_abc123",
  "status": "closed",
  "terminal_id": "trm_abc123",
  "transaction_count": 12,
  "total_in_cents": 125000,
  "total_currency": "GTQ",
  "totals_by_currency": {
    "GTQ": 125000
  },
  "opened_at": "2026-07-07T08:00:00-06:00",
  "closed_at": "2026-07-07T17:30:00-06:00"
}
```

**SDK Code**

```python Cerrar lote actual
import requests

url = "https://app.recurrente.com/api/terminal_batch_closes"

payload = { "terminal_id": "trm_abc123" }
headers = {
    "X-SECRET-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Cerrar lote actual
const url = 'https://app.recurrente.com/api/terminal_batch_closes';
const options = {
  method: 'POST',
  headers: {'X-SECRET-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"terminal_id":"trm_abc123"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Cerrar lote actual
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.recurrente.com/api/terminal_batch_closes"

	payload := strings.NewReader("{\n  \"terminal_id\": \"trm_abc123\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-SECRET-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Cerrar lote actual
require 'uri'
require 'net/http'

url = URI("https://app.recurrente.com/api/terminal_batch_closes")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-SECRET-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"terminal_id\": \"trm_abc123\"\n}"

response = http.request(request)
puts response.read_body
```

```java Cerrar lote actual
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.recurrente.com/api/terminal_batch_closes")
  .header("X-SECRET-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"terminal_id\": \"trm_abc123\"\n}")
  .asString();
```

```php Cerrar lote actual
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.recurrente.com/api/terminal_batch_closes', [
  'body' => '{
  "terminal_id": "trm_abc123"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-SECRET-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Cerrar lote actual
using RestSharp;

var client = new RestClient("https://app.recurrente.com/api/terminal_batch_closes");
var request = new RestRequest(Method.POST);
request.AddHeader("X-SECRET-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"terminal_id\": \"trm_abc123\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Cerrar lote actual
import Foundation

let headers = [
  "X-SECRET-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["terminal_id": "trm_abc123"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.recurrente.com/api/terminal_batch_closes")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```