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

# Para agentes de IA

> Integra la facturación SIAT por REST /api/v3 o MCP desde un agente: descubrimiento, autenticación, emisión idempotente y diagnóstico.

* REST: sandbox `https://sandbox.cucu.bo/api/v3`, producción `https://api.cucu.bo/api/v3`. Envía `X-API-Key` y, para cuerpos JSON, `Content-Type: application/json`.
* OpenAPI: `GET /api/v3/openapi?format=json` en ambos hosts. MCP: `POST /mcp` en esos mismos hosts con `X-API-Key` ([conexión y ejemplos](https://docs.cucu.bo/mcp/para-agentes.md)).
* Errores REST: `success: false`, `error.code`, `error.traceId` y `error.docUrl`. Para validación, lee `error.errors[]` (`field`, `code`, `message`). Los campos fuera del esquema se rechazan con `400 VALIDATION_ERROR` y `UNKNOWN_FIELD`.
* `422 SIAT_REJECTED`: lee `data.diagnosis` y corrige los datos antes de emitir otra vez. [Catálogo de errores](https://docs.cucu.bo/errors.md).

## Inicio en cinco pasos

1. Consigue una [API Key de sandbox](https://docs.cucu.bo/authentication.md) y prueba `GET /api/v3/ping`.
2. Consulta [`GET /api/v3/points-of-sale`](https://docs.cucu.bo/api/companies). Guarda el `id` como `pointOfSaleId` y verifica `authorizedSectors`.
3. Consulta los [catálogos del SIN](https://docs.cucu.bo/api/catalogs.md) del emisor para obtener actividad, producto, unidad y método de pago.
4. Envía el cuerpo a [`POST /api/v3/invoices/preview`](https://docs.cucu.bo/api/preview-invoice) y revisa `data.valid` y `data.validations[]`.
5. [Emite con el mismo cuerpo](https://docs.cucu.bo/api/create-invoice.md) y una `Idempotency-Key` por venta. Reusa la clave y el cuerpo ante un timeout, guarda `data.id` y `data.cuf` y consulta `data.siatState`. [Ejemplo ejecutable](https://docs.cucu.bo/quickstart.md).


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