> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cucu.bo/llms.txt
> Use this file to discover all available pages before exploring further.

# Previsualizar factura

> POST /api/v1/invoices/preview: montos, IVA, XML y validaciones de una factura sin emitirla.

Mismo body, misma API Key y mismo tenant que [emitir](https://docs.cucu.bo/api/create-invoice.md), pero **no emite**: no numera, no guarda nada y no
habla con el SIN. Sirve para mostrar el total antes de cobrar, probar un request contra las reglas del SIN y ver cómo
queda un precio final cuando la company está en SIAT v3 (IVA transparente). Se puede llamar las veces que haga falta.

```http theme={"system"}
POST https://sandbox.cucu.bo/api/v1/invoices/preview
X-API-Key: sk_test_...
Content-Type: application/json
```

El body es un [`CreateInvoiceRequest`](https://docs.cucu.bo/api/create-invoice#request-body) completo (incluido `priceBasis` si aplica).

## Response

| Campo | Tipo | Descripción |
| - | - | - |
| `data.siatVersion` | string | `v2` o `v3`, según la company del punto de venta |
| `data.priceBasis` | string | Sólo v3: `GROSS` (precio final) o `NET` con el que se interpretó `priceUnit` |
| `data.documentSectorType` / `data.siatModality` | int | Sector y modalidad con los que se emitiría |
| `data.valid` | boolean | `true` si todas las validaciones pasan: emitir con este body debería aceptarse |
| `data.amounts.amountTotal` | number | Lo que paga el comprador (v2 y v3) |
| `data.amounts.amountNet` / `amountIva` / `amountToPay` | number | Sólo v3: total precio neto, IVA (13 %, HALF-UP) y monto a pagar |
| `data.amounts.amountRequested` / `amountDifference` | number | Sólo v3 `GROSS`: lo que pediste y la diferencia (ej. Bs 100,00 → 99,99, `-0.01`) |
| `data.items[]` | array | Por ítem: `priceUnitRequested` (lo que mandaste), `priceUnit` (lo que viaja al SIN: neto en v3), `subtotal` |
| `data.validations[]` | array | `rule`, `ok`, `detail`: XSD oficial del SIN de ese documento y versión, fórmulas (`subTotal`, `iva`, `montoaPagar`), sector autorizado |
| `data.notes[]` | array | Avisos en lenguaje simple (número/CUF/CUFD provisorios, diferencia de centavos, etc.) |
| `data.xmlPreview` | string | El XML que se mandaría (sin firma; CUF y número provisorios) |

Errores: los mismos que la emisión (`400` body inválido o punto de venta inexistente, `401` sin API Key, `422`
`SECTOR_NOT_AUTHORIZED` / `SECTOR_NOT_SUPPORTED` / `SIAT_V3_NO_DISPONIBLE`). Ver [errores](https://docs.cucu.bo/errors).

## Ejemplo (company en v3, precio final 100)

```json theme={"system"}
{
  "success": true,
  "data": {
    "siatVersion": "v3",
    "priceBasis": "GROSS",
    "valid": true,
    "amounts": { "amountTotal": 99.99, "amountNet": 88.49, "amountIva": 11.50, "amountToPay": 99.99,
                 "amountRequested": 100.00, "amountDifference": -0.01, "amountLiteral": "Noventa y Nueve 99/100 Bolivianos" },
    "items": [ { "line": 1, "priceUnitRequested": 100.00, "priceUnit": 88.49, "subtotal": 88.49 } ],
    "validations": [
      { "rule": "XSD oficial del SIN (xsd/v3/computarized/facturaComputarizadaCompraVenta.xsd)", "ok": true, "detail": "estructura válida (la firma se valida al emitir)" },
      { "rule": "iva = totalPrecioNeto × 0.13 (HALF-UP)", "ok": true, "detail": "88.49 × 0.13 = 11.50" }
    ],
    "notes": [ "Nada se emitió: número de factura y CUF son provisorios.",
               "El precio final pedido no es representable al centavo en v3: se cobraría 99.99 (diferencia -0.01)." ]
  }
}
```

En MCP es la tool [`previsualizarFactura`](https://docs.cucu.bo/mcp/herramientas-facturacion#previsualizarfactura), con el mismo JSON que `crearFactura`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.