# Lotes de facturas

> Las operaciones de Lotes de facturas de la API de Trevol: parámetros, cuerpo, respuestas y ejemplos de código.

Fuente: https://platform.trevol.si/docs/api/invoice-batches

Emitir varias facturas en una llamada: Trevol las valida, las numera y las envía a la DIAN de a una, en segundo plano. Cada factura tiene su propia Idempotency-Key y su resultado.

Los ejemplos de código salen de los SDK reales. La llave va en `TREVOL_API_KEY`; los cuerpos de ejemplo son los de la especificación. Los errores comunes están en [Errores](/docs/errores).

## Emitir un lote de facturas

`POST /v1/invoice_batches` · `createInvoiceBatch`

Emite de 1 a 50 facturas en una llamada: responde `202` enseguida y Trevol las valida (las que no pasan quedan `failed`, sin gastar número), las numera y las envía a la DIAN de a una, en segundo plano. Cada factura lleva su `idempotency_key` (la de `POST /v1/invoices`); la `Idempotency-Key` del encabezado es la del lote. Consume un envío por factura, todo o nada. Sin notas ni facturas de papel (03).

**Parámetros**

| Nombre | En | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | cabecera | texto | sí | Obligatoria: 1 a 255 caracteres ASCII visibles, única por pedido (7 días). |

**Cuerpo** ([InvoiceBatchInput](/docs/api/objetos#InvoiceBatchInput), obligatorio)

| Campo | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- |
| `invoices` | lista de [InvoiceBatchInvoiceInput](/docs/api/objetos#InvoiceBatchInvoiceInput) | sí | Máximo 50. |

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 202 | El lote, con el estado de cada factura ([InvoiceBatch](/docs/api/objetos#InvoiceBatch)) |
| 400 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| 403 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| 413 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| 422 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| 429 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`POST /v1/invoice_batches` (`createInvoiceBatch`)

#### cURL

```bash
curl -X POST "https://api.trevol.si/v1/invoice_batches" \
  -H "Authorization: Bearer $TREVOL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "invoices": [
    {
      "customer": {
        "document_type": "31",
        "document_number": "900123456",
        "name": "COMERCIALIZADORA ANDINA SAS",
        "person_type": "legal",
        "email": "facturacion@comercializadoraandina.example",
        "address": "Calle 72 # 10-34, Oficina 501",
        "municipality_code": "11001"
      },
      "items": [
        {
          "code": "LIC-ANUAL",
          "description": "Licencia anual de software",
          "quantity": "2",
          "unit_price": "150000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        },
        {
          "code": "SOP-MES",
          "description": "Soporte técnico mensual",
          "quantity": "1",
          "unit_price": "80000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        }
      ],
      "payment": {
        "form": "credit",
        "term_days": 30
      },
      "notes": [
        "Gracias por su compra"
      ],
      "external_id": "VENTA-2026-000124",
      "idempotency_key": "VENTA-2026-000124"
    },
    {
      "external_id": "VENTA-2026-000125",
      "idempotency_key": "VENTA-2026-000125",
      "customer": {
        "final_consumer": true
      },
      "items": [
        {
          "description": "Soporte técnico mensual",
          "quantity": "0",
          "unit_price": "80000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        }
      ]
    }
  ]
}'
```

#### Node.js

```javascript
import { Trevol } from '@trevol/sdk';

const trevol = new Trevol(); // lee TREVOL_API_KEY

const resultado = await trevol.invoiceBatches.createInvoiceBatch({
  invoiceBatchInput: {
    invoices: [
      {
        customer: {
          document_type: '31',
          document_number: '900123456',
          name: 'COMERCIALIZADORA ANDINA SAS',
          person_type: 'legal',
          email: 'facturacion@comercializadoraandina.example',
          address: 'Calle 72 # 10-34, Oficina 501',
          municipality_code: '11001'
        },
        items: [
          {
            code: 'LIC-ANUAL',
            description: 'Licencia anual de software',
            quantity: '2',
            unit_price: '150000',
            taxes: [{ code: '01', rate: '19' }]
          },
          {
            code: 'SOP-MES',
            description: 'Soporte técnico mensual',
            quantity: '1',
            unit_price: '80000',
            taxes: [{ code: '01', rate: '19' }]
          }
        ],
        payment: { form: 'credit', term_days: 30 },
        notes: ['Gracias por su compra'],
        external_id: 'VENTA-2026-000124',
        idempotency_key: 'VENTA-2026-000124'
      },
      {
        external_id: 'VENTA-2026-000125',
        idempotency_key: 'VENTA-2026-000125',
        customer: { final_consumer: true },
        items: [
          {
            description: 'Soporte técnico mensual',
            quantity: '0',
            unit_price: '80000',
            taxes: [{ code: '01', rate: '19' }]
          }
        ]
      }
    ]
  },
  // idempotencyKey: 'VENTA-2026-000123', // opcional: si falta, el SDK pone una y la repite en los reintentos
});
console.log(resultado);
```

#### Python

```python
from trevol import Trevol

trevol = Trevol()  # lee TREVOL_API_KEY

resultado = trevol.invoice_batches.create_invoice_batch(
    invoice_batch_input={
        "invoices": [
            {
                "customer": {
                    "document_type": "31",
                    "document_number": "900123456",
                    "name": "COMERCIALIZADORA ANDINA SAS",
                    "person_type": "legal",
                    "email": "facturacion@comercializadoraandina.example",
                    "address": "Calle 72 # 10-34, Oficina 501",
                    "municipality_code": "11001",
                },
                "items": [
                    {
                        "code": "LIC-ANUAL",
                        "description": "Licencia anual de software",
                        "quantity": "2",
                        "unit_price": "150000",
                        "taxes": [{"code": "01", "rate": "19"}],
                    },
                    {
                        "code": "SOP-MES",
                        "description": "Soporte técnico mensual",
                        "quantity": "1",
                        "unit_price": "80000",
                        "taxes": [{"code": "01", "rate": "19"}],
                    },
                ],
                "payment": {"form": "credit", "term_days": 30},
                "notes": ["Gracias por su compra"],
                "external_id": "VENTA-2026-000124",
                "idempotency_key": "VENTA-2026-000124",
            },
            {
                "external_id": "VENTA-2026-000125",
                "idempotency_key": "VENTA-2026-000125",
                "customer": {"final_consumer": True},
                "items": [
                    {
                        "description": "Soporte técnico mensual",
                        "quantity": "0",
                        "unit_price": "80000",
                        "taxes": [{"code": "01", "rate": "19"}],
                    },
                ],
            },
        ],
    },
    # idempotency_key="VENTA-2026-000123",  # opcional: si falta, el SDK pone una y la repite en los reintentos
)
print(resultado)
```

#### PHP

```php
<?php

use Trevol\Trevol;

require __DIR__ . '/vendor/autoload.php';

$trevol = new Trevol(getenv('TREVOL_API_KEY')); // tvl_test_… → $trevol->environment === 'test'

$resultado = $trevol->invoiceBatches->createInvoiceBatch(
    invoice_batch_input: [
        'invoices' => [
            [
                'customer' => [
                    'document_type' => '31',
                    'document_number' => '900123456',
                    'name' => 'COMERCIALIZADORA ANDINA SAS',
                    'person_type' => 'legal',
                    'email' => 'facturacion@comercializadoraandina.example',
                    'address' => 'Calle 72 # 10-34, Oficina 501',
                    'municipality_code' => '11001',
                ],
                'items' => [
                    [
                        'code' => 'LIC-ANUAL',
                        'description' => 'Licencia anual de software',
                        'quantity' => '2',
                        'unit_price' => '150000',
                        'taxes' => [['code' => '01', 'rate' => '19']],
                    ],
                    [
                        'code' => 'SOP-MES',
                        'description' => 'Soporte técnico mensual',
                        'quantity' => '1',
                        'unit_price' => '80000',
                        'taxes' => [['code' => '01', 'rate' => '19']],
                    ],
                ],
                'payment' => ['form' => 'credit', 'term_days' => 30],
                'notes' => ['Gracias por su compra'],
                'external_id' => 'VENTA-2026-000124',
                'idempotency_key' => 'VENTA-2026-000124',
            ],
            [
                'external_id' => 'VENTA-2026-000125',
                'idempotency_key' => 'VENTA-2026-000125',
                'customer' => ['final_consumer' => true],
                'items' => [
                    [
                        'description' => 'Soporte técnico mensual',
                        'quantity' => '0',
                        'unit_price' => '80000',
                        'taxes' => [['code' => '01', 'rate' => '19']],
                    ],
                ],
            ],
        ],
    ],
    // idempotency_key: 'VENTA-2026-000123', // opcional: si falta, el SDK pone una y la repite en los reintentos
);
echo $resultado, PHP_EOL;

```

#### Java

```java
import si.trevol.Trevol;
import si.trevol.generado.model.InvoiceBatchInput;

public class Ejemplo {
    public static void main(String[] args) throws Exception {
        Trevol trevol = Trevol.builder().apiKey(System.getenv("TREVOL_API_KEY")).build(); // tvl_test_… → trevol.environment() == TEST

        InvoiceBatchInput entrada = InvoiceBatchInput.fromJson("""
            {
              "invoices": [
                {
                  "customer": {
                    "document_type": "31",
                    "document_number": "900123456",
                    "name": "COMERCIALIZADORA ANDINA SAS",
                    "person_type": "legal",
                    "email": "facturacion@comercializadoraandina.example",
                    "address": "Calle 72 # 10-34, Oficina 501",
                    "municipality_code": "11001"
                  },
                  "items": [
                    {
                      "code": "LIC-ANUAL",
                      "description": "Licencia anual de software",
                      "quantity": "2",
                      "unit_price": "150000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    },
                    {
                      "code": "SOP-MES",
                      "description": "Soporte técnico mensual",
                      "quantity": "1",
                      "unit_price": "80000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    }
                  ],
                  "payment": {
                    "form": "credit",
                    "term_days": 30
                  },
                  "notes": [
                    "Gracias por su compra"
                  ],
                  "external_id": "VENTA-2026-000124",
                  "idempotency_key": "VENTA-2026-000124"
                },
                {
                  "external_id": "VENTA-2026-000125",
                  "idempotency_key": "VENTA-2026-000125",
                  "customer": {
                    "final_consumer": true
                  },
                  "items": [
                    {
                      "description": "Soporte técnico mensual",
                      "quantity": "0",
                      "unit_price": "80000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
            """);
        var resultado = trevol.invoiceBatches().createInvoiceBatch(entrada)
                // .idempotencyKey("VENTA-2026-000123") // opcional: si falta, el SDK pone una y la repite en los reintentos
                .execute();
        System.out.println(resultado);
    }
}

```

#### C#

```csharp
using System;
using System.Threading.Tasks;
using Trevol;
using Trevol.Generado.Model;

public static class Ejemplo
{
    public static async Task Main()
    {
        var trevol = new TrevolClient(Environment.GetEnvironmentVariable("TREVOL_API_KEY")); // tvl_test_… → trevol.Environment == TrevolEnvironment.Test

        var entrada = TrevolJson.Deserialize<InvoiceBatchInput>("""
            {
              "invoices": [
                {
                  "customer": {
                    "document_type": "31",
                    "document_number": "900123456",
                    "name": "COMERCIALIZADORA ANDINA SAS",
                    "person_type": "legal",
                    "email": "facturacion@comercializadoraandina.example",
                    "address": "Calle 72 # 10-34, Oficina 501",
                    "municipality_code": "11001"
                  },
                  "items": [
                    {
                      "code": "LIC-ANUAL",
                      "description": "Licencia anual de software",
                      "quantity": "2",
                      "unit_price": "150000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    },
                    {
                      "code": "SOP-MES",
                      "description": "Soporte técnico mensual",
                      "quantity": "1",
                      "unit_price": "80000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    }
                  ],
                  "payment": {
                    "form": "credit",
                    "term_days": 30
                  },
                  "notes": [
                    "Gracias por su compra"
                  ],
                  "external_id": "VENTA-2026-000124",
                  "idempotency_key": "VENTA-2026-000124"
                },
                {
                  "external_id": "VENTA-2026-000125",
                  "idempotency_key": "VENTA-2026-000125",
                  "customer": {
                    "final_consumer": true
                  },
                  "items": [
                    {
                      "description": "Soporte técnico mensual",
                      "quantity": "0",
                      "unit_price": "80000",
                      "taxes": [
                        {
                          "code": "01",
                          "rate": "19"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
            """);
        var resultado = await trevol.InvoiceBatches.CreateInvoiceBatchAsync(
            invoiceBatchInput: entrada
            // , idempotencyKey: "VENTA-2026-000123" // opcional: si falta, el SDK pone una y la repite en los reintentos
        );
        Console.WriteLine(TrevolJson.Serialize(resultado));
    }
}

```

#### Go

```go
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	trevol "github.com/trevol-si/trevol-go"
	"github.com/trevol-si/trevol-go/generado"
)

func main() {
	ctx := context.Background()
	c, err := trevol.NewClient(os.Getenv("TREVOL_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	var entrada generado.InvoiceBatchInput
	cuerpo := `{
  "invoices": [
    {
      "customer": {
        "document_type": "31",
        "document_number": "900123456",
        "name": "COMERCIALIZADORA ANDINA SAS",
        "person_type": "legal",
        "email": "facturacion@comercializadoraandina.example",
        "address": "Calle 72 # 10-34, Oficina 501",
        "municipality_code": "11001"
      },
      "items": [
        {
          "code": "LIC-ANUAL",
          "description": "Licencia anual de software",
          "quantity": "2",
          "unit_price": "150000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        },
        {
          "code": "SOP-MES",
          "description": "Soporte técnico mensual",
          "quantity": "1",
          "unit_price": "80000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        }
      ],
      "payment": {
        "form": "credit",
        "term_days": 30
      },
      "notes": [
        "Gracias por su compra"
      ],
      "external_id": "VENTA-2026-000124",
      "idempotency_key": "VENTA-2026-000124"
    },
    {
      "external_id": "VENTA-2026-000125",
      "idempotency_key": "VENTA-2026-000125",
      "customer": {
        "final_consumer": true
      },
      "items": [
        {
          "description": "Soporte técnico mensual",
          "quantity": "0",
          "unit_price": "80000",
          "taxes": [
            {
              "code": "01",
              "rate": "19"
            }
          ]
        }
      ]
    }
  ]
}`
	if err := json.Unmarshal([]byte(cuerpo), &entrada); err != nil {
		log.Fatal(err)
	}

	resultado, _, err := c.InvoiceBatchesAPI.CreateInvoiceBatch(ctx).
		InvoiceBatchInput(entrada).
		// IdempotencyKey("VENTA-2026-000123"). // opcional: si falta, el SDK pone una y la repite en los reintentos
		Execute()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resultado)
}

```

#### Ruby

```ruby
require 'trevol'

trevol = Trevol::Client.new # lee TREVOL_API_KEY

resultado = trevol.invoice_batches.create_invoice_batch(
  {
    invoices: [
      {
        customer: {
          document_type: '31',
          document_number: '900123456',
          name: 'COMERCIALIZADORA ANDINA SAS',
          person_type: 'legal',
          email: 'facturacion@comercializadoraandina.example',
          address: 'Calle 72 # 10-34, Oficina 501',
          municipality_code: '11001'
        },
        items: [
          {
            code: 'LIC-ANUAL',
            description: 'Licencia anual de software',
            quantity: '2',
            unit_price: '150000',
            taxes: [{ code: '01', rate: '19' }]
          },
          {
            code: 'SOP-MES',
            description: 'Soporte técnico mensual',
            quantity: '1',
            unit_price: '80000',
            taxes: [{ code: '01', rate: '19' }]
          }
        ],
        payment: { form: 'credit', term_days: 30 },
        notes: ['Gracias por su compra'],
        external_id: 'VENTA-2026-000124',
        idempotency_key: 'VENTA-2026-000124'
      },
      {
        external_id: 'VENTA-2026-000125',
        idempotency_key: 'VENTA-2026-000125',
        customer: { final_consumer: true },
        items: [
          {
            description: 'Soporte técnico mensual',
            quantity: '0',
            unit_price: '80000',
            taxes: [{ code: '01', rate: '19' }]
          }
        ]
      }
    ]
  },
  # idempotency_key: 'VENTA-2026-000123' # opcional: si falta, el SDK pone una y la repite en los reintentos
)
pp resultado.to_hash

```

#### Respuesta 202

```json
{
  "id": "ib_7d2c4e1f9a0b3c5d6e8f1a2b3c4d5e6f",
  "object": "invoice_batch",
  "environment": "test",
  "status": "processing",
  "created_at": "2026-11-24T09:15:02-05:00",
  "completed_at": null,
  "counts": {
    "total": 2,
    "queued": 1,
    "pending": 0,
    "sending": 0,
    "accepted": 0,
    "rejected": 0,
    "error": 0,
    "processing": 0,
    "contingency": 0,
    "failed": 1,
    "replayed": 0
  },
  "items": [
    {
      "index": 0,
      "idempotency_key": "VENTA-2026-000124",
      "status": "queued",
      "invoice": {
        "id": "inv_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b",
        "status": "pending",
        "number": "SETP990000124"
      },
      "error": null
    },
    {
      "index": 1,
      "idempotency_key": "VENTA-2026-000125",
      "status": "failed",
      "invoice": null,
      "error": {
        "code": "validation_error",
        "detail": "debe ser mayor que cero",
        "errors": [
          {
            "field": "items[0].quantity",
            "pointer": "/items/0/quantity",
            "message": "debe ser mayor que cero"
          }
        ]
      }
    }
  ]
}
```

## Los lotes de los últimos 30 días

`GET /v1/invoice_batches` · `listInvoiceBatches`

**Parámetros**

| Nombre | En | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- | --- |
| `limit` | consulta | entero |  |  |
| `starting_after` | consulta | texto |  |  |
| `status` | consulta | `processing` \| `completed` |  |  |
| `created_from` | consulta | texto |  |  |
| `created_to` | consulta | texto |  |  |

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 200 | {object: list, data, has_more, next_cursor} (objeto) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`GET /v1/invoice_batches` (`listInvoiceBatches`)

#### cURL

```bash
curl "https://api.trevol.si/v1/invoice_batches?limit=100" \
  -H "Authorization: Bearer $TREVOL_API_KEY"
```

#### Node.js

```javascript
import { Trevol } from '@trevol/sdk';

const trevol = new Trevol(); // lee TREVOL_API_KEY

for await (const item of trevol.paginate((cursor) => trevol.invoiceBatches.listInvoiceBatches({ limit: 100, startingAfter: cursor }))) {
  console.log(item.id);
}
```

#### Python

```python
from trevol import Trevol

trevol = Trevol()  # lee TREVOL_API_KEY

for item in trevol.paginate(lambda cursor: trevol.invoice_batches.list_invoice_batches(limit=100, starting_after=cursor)):
    print(item.id)
```

#### PHP

```php
<?php

use Trevol\Trevol;

require __DIR__ . '/vendor/autoload.php';

$trevol = new Trevol(getenv('TREVOL_API_KEY')); // tvl_test_… → $trevol->environment === 'test'

foreach ($trevol->paginate(fn (?string $cursor) => $trevol->invoiceBatches->listInvoiceBatches(limit: 100, starting_after: $cursor)) as $item) {
    echo $item->getId(), PHP_EOL;
}

```

#### Java

```java
import si.trevol.Trevol;
import si.trevol.generado.model.InvoiceBatchList;

public class Ejemplo {
    public static void main(String[] args) throws Exception {
        Trevol trevol = Trevol.builder().apiKey(System.getenv("TREVOL_API_KEY")).build(); // tvl_test_… → trevol.environment() == TEST

        for (var item : trevol.paginate(
                cursor -> trevol.invoiceBatches().listInvoiceBatches().limit(100).startingAfter(cursor).execute(),
                InvoiceBatchList::getData)) {
            System.out.println(item.getId());
        }
    }
}

```

#### C#

```csharp
using System;
using System.Threading.Tasks;
using Trevol;

public static class Ejemplo
{
    public static async Task Main()
    {
        var trevol = new TrevolClient(Environment.GetEnvironmentVariable("TREVOL_API_KEY")); // tvl_test_… → trevol.Environment == TrevolEnvironment.Test

        await foreach (var item in trevol.PaginateAsync(cursor => trevol.InvoiceBatches.ListInvoiceBatchesAsync(limit: 100, startingAfter: cursor)))
        {
            Console.WriteLine(item.Id);
        }
    }
}

```

#### Go

```go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	trevol "github.com/trevol-si/trevol-go"
	"github.com/trevol-si/trevol-go/generado"
)

func main() {
	ctx := context.Background()
	c, err := trevol.NewClient(os.Getenv("TREVOL_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	for item, err := range trevol.Paginate(ctx, func(cursor *string) (*generado.InvoiceBatchList, error) {
		r := c.InvoiceBatchesAPI.ListInvoiceBatches(ctx).Limit(100)
		if cursor != nil {
			r = r.StartingAfter(*cursor)
		}
		l, _, err := r.Execute()
		return l, err
	}) {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(item.GetId())
	}
}

```

#### Ruby

```ruby
require 'trevol'

trevol = Trevol::Client.new # lee TREVOL_API_KEY

trevol.paginate { |cursor| trevol.invoice_batches.list_invoice_batches(limit: 100, starting_after: cursor) }.each do |item|
  puts item.id
end

```

#### Respuesta 200

```json
{
  "object": "list",
  "has_more": false,
  "next_cursor": null,
  "data": [
    {
      "id": "ib_7d2c4e1f9a0b3c5d6e8f1a2b3c4d5e6f",
      "object": "invoice_batch",
      "environment": "test",
      "status": "completed",
      "created_at": "2026-11-24T09:15:02-05:00",
      "completed_at": "2026-11-24T09:15:40-05:00",
      "counts": {
        "total": 1,
        "queued": 0,
        "pending": 0,
        "sending": 0,
        "accepted": 1,
        "rejected": 0,
        "error": 0,
        "processing": 0,
        "contingency": 0,
        "failed": 0,
        "replayed": 0
      },
      "items": [
        {
          "index": 0,
          "idempotency_key": "VENTA-2026-000124",
          "status": "accepted",
          "invoice": {
            "id": "inv_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b",
            "status": "accepted",
            "number": "SETP990000124"
          },
          "error": null
        }
      ]
    }
  ]
}
```

[Probar en el Playground](https://platform.trevol.si/playground?op=listInvoiceBatches)

## Un lote, con el estado actual de cada factura

`GET /v1/invoice_batches/{id}` · `retrieveInvoiceBatch`

**Parámetros**

| Nombre | En | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- | --- |
| `id` | ruta | texto | sí |  |

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 200 | El lote ([InvoiceBatch](/docs/api/objetos#InvoiceBatch)) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`GET /v1/invoice_batches/{id}` (`retrieveInvoiceBatch`)

#### cURL

```bash
curl "https://api.trevol.si/v1/invoice_batches/ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b" \
  -H "Authorization: Bearer $TREVOL_API_KEY"
```

#### Node.js

```javascript
import { Trevol } from '@trevol/sdk';

const trevol = new Trevol(); // lee TREVOL_API_KEY

const resultado = await trevol.invoiceBatches.retrieveInvoiceBatch({
  id: 'ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b'
});
console.log(resultado);
```

#### Python

```python
from trevol import Trevol

trevol = Trevol()  # lee TREVOL_API_KEY

resultado = trevol.invoice_batches.retrieve_invoice_batch(
    id="ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b",
)
print(resultado)
```

#### PHP

```php
<?php

use Trevol\Trevol;

require __DIR__ . '/vendor/autoload.php';

$trevol = new Trevol(getenv('TREVOL_API_KEY')); // tvl_test_… → $trevol->environment === 'test'

$resultado = $trevol->invoiceBatches->retrieveInvoiceBatch(
    id: 'ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b',
);
echo $resultado, PHP_EOL;

```

#### Java

```java
import si.trevol.Trevol;

public class Ejemplo {
    public static void main(String[] args) throws Exception {
        Trevol trevol = Trevol.builder().apiKey(System.getenv("TREVOL_API_KEY")).build(); // tvl_test_… → trevol.environment() == TEST

        var resultado = trevol.invoiceBatches().retrieveInvoiceBatch("ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b").execute();
        System.out.println(resultado);
    }
}

```

#### C#

```csharp
using System;
using System.Threading.Tasks;
using Trevol;

public static class Ejemplo
{
    public static async Task Main()
    {
        var trevol = new TrevolClient(Environment.GetEnvironmentVariable("TREVOL_API_KEY")); // tvl_test_… → trevol.Environment == TrevolEnvironment.Test

        var resultado = await trevol.InvoiceBatches.RetrieveInvoiceBatchAsync(id: "ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b");
        Console.WriteLine(TrevolJson.Serialize(resultado));
    }
}

```

#### Go

```go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	trevol "github.com/trevol-si/trevol-go"
)

func main() {
	ctx := context.Background()
	c, err := trevol.NewClient(os.Getenv("TREVOL_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	resultado, _, err := c.InvoiceBatchesAPI.RetrieveInvoiceBatch(ctx, "ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b").Execute()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resultado)
}

```

#### Ruby

```ruby
require 'trevol'

trevol = Trevol::Client.new # lee TREVOL_API_KEY

resultado = trevol.invoice_batches.retrieve_invoice_batch(
  'ib_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b'
)
pp resultado.to_hash

```

#### Respuesta 200

```json
{
  "id": "ib_7d2c4e1f9a0b3c5d6e8f1a2b3c4d5e6f",
  "object": "invoice_batch",
  "environment": "test",
  "status": "completed",
  "created_at": "2026-11-24T09:15:02-05:00",
  "completed_at": "2026-11-24T09:15:40-05:00",
  "counts": {
    "total": 1,
    "queued": 0,
    "pending": 0,
    "sending": 0,
    "accepted": 1,
    "rejected": 0,
    "error": 0,
    "processing": 0,
    "contingency": 0,
    "failed": 0,
    "replayed": 0
  },
  "items": [
    {
      "index": 0,
      "idempotency_key": "VENTA-2026-000124",
      "status": "accepted",
      "invoice": {
        "id": "inv_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b",
        "status": "accepted",
        "number": "SETP990000124"
      },
      "error": null
    }
  ]
}
```

[Probar en el Playground](https://platform.trevol.si/playground?op=retrieveInvoiceBatch)
