### Factura API - JSON Examples Source: https://docs.apisunat.pe/integracion/facturacion-electronica/factura Examples of JSON payloads for different types of invoices. ```APIDOC ## Factura API - JSON Examples ### Description This section provides JSON examples for various invoice types supported by the API. ### Invoice Types - **Factura Simple:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-simple) - **Factura al Crédito:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-al-credito) - **Factura Exonerada:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-exonerada) - **Factura con Detracción:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-detraccion) - **Factura de Exportación:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-de-exportacion) - **Factura con Placa Vehicular:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-placa-vehicular) - **Factura con Anticipos:** [Link](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-anticipos) ``` -------------------------------- ### POST /api/v3/dispatches Source: https://docs.apisunat.pe/integracion/guias-de-remision/remitente Creates a new electronic dispatch guide (Guía de Remisión Remitente) in the sandbox environment. ```APIDOC ## POST /api/v3/dispatches ### Description Creates a new electronic dispatch guide (Guía de Remisión Remitente) by sending the required document details. ### Method POST ### Endpoint https://sandbox.apisunat.pe/api/v3/dispatches ### Request Body - **documento** (string) - Required - Type of document (e.g., "guia_remision_remitente") - **serie** (string) - Required - Series of the document - **numero** (string) - Required - Document number - **fecha_de_emision** (string) - Required - Date of issuance - **hora_de_emision** (string) - Required - Time of issuance - **modalidad_de_transporte** (string) - Required - Transport modality code - **motivo_de_traslado** (string) - Required - Reason for transfer code - **fecha_inicio_de_traslado** (string) - Required - Start date of transfer - **destinatario_tipo_de_documento** (string) - Required - Recipient document type - **destinatario_numero_de_documento** (string) - Required - Recipient document number - **destinatario_denominacion** (string) - Required - Recipient name - **destinatario_direccion** (string) - Required - Recipient address - **punto_de_partida_ubigeo** (string) - Required - Departure location ubigeo - **punto_de_partida_direccion** (string) - Required - Departure address - **punto_de_llegada_ubigeo** (string) - Required - Arrival location ubigeo - **punto_de_llegada_direccion** (string) - Required - Arrival address - **peso_bruto_total** (string) - Required - Total gross weight - **peso_bruto_unidad_de_medida** (string) - Required - Unit of measurement for weight - **numero_de_bultos** (integer) - Required - Number of packages - **documentos_relacionados** (array) - Optional - Related documents - **transportista** (object) - Required - Carrier information - **conductores** (array) - Required - Driver information - **vehiculos** (array) - Required - Vehicle information - **items** (array) - Required - List of items being transported ### Request Example { "documento": "guia_remision_remitente", "serie": "T001", "numero": "1", "fecha_de_emision": "2025-12-17", "hora_de_emision": "17:22:00", "modalidad_de_transporte": "02", "motivo_de_traslado": "01", "fecha_inicio_de_traslado": "2025-12-17", "destinatario_tipo_de_documento": "6", "destinatario_numero_de_documento": "20609286696", "destinatario_denominacion": "EMPRESA SOCIEDAD ANONIMA CERRADA", "destinatario_direccion": "Cal. General Mendiburu Nro. 855", "punto_de_partida_ubigeo": "150132", "punto_de_partida_direccion": "AV. LURIGANCHO NRO. 626 AZCARRUZ BAJO - SAN JUAN DE LURIGANCHO", "punto_de_llegada_ubigeo": "150122", "punto_de_llegada_direccion": "Cal. General Mendiburu Nro. 855", "peso_bruto_total": "1.9", "peso_bruto_unidad_de_medida": "KGM", "numero_de_bultos": 1, "items": [] } ### Response #### Success Response (200) - **success** (boolean) - Status of the request - **message** (string) - Confirmation message - **payload** (object) - Contains hash, xml link, and cdr link #### Response Example { "success": true, "message": "Guía de Remision T001-1 generado correctamente", "payload": { "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-FF01-123.xml", "cdr": "https://apisunat.pe/R-20123456789-01-FF01-123.xml" } } ``` -------------------------------- ### POST /api/v1/gr-transportista Source: https://docs.apisunat.pe/integracion/guias-de-remision/transportista Registers a new transport guide in the system. ```APIDOC ## POST /api/v1/gr-transportista ### Description Registers a new transport guide (GR Transportista) by sending a JSON payload containing transport, vehicle, driver, and cargo details. ### Method POST ### Endpoint https://api.lucode.pe/api/v1/gr-transportista ### Request Body - **numeracion** (string) - Required - Document numbering - **fecha_emision** (string) - Required - Date of issuance - **hora_emision** (string) - Required - Time of issuance - **observaciones** (array) - Optional - List of observations - **documentos_relacionados** (array) - Optional - Related documents - **numero_ruc_transportista** (string) - Required - RUC of the carrier - **denominacion_transportista** (string) - Required - Name of the carrier - **items** (array) - Required - List of items being transported - **ubigeo_punto_partida** (string) - Required - Ubigeo of the departure point - **direccion_punto_partida** (string) - Required - Address of the departure point - **ubigeo_punto_llegada** (string) - Required - Ubigeo of the arrival point - **direccion_punto_llegada** (string) - Required - Address of the arrival point - **numero_placa_vehiculo_principal** (string) - Required - License plate of the main vehicle - **fecha_inicio_traslado** (string) - Required - Start date of transport - **peso_bruto_total_carga** (string) - Required - Total gross weight of the cargo ### Request Example { "numeracion": "string", "fecha_emision": "string", "hora_emision": "string", "numero_ruc_transportista": "string", "denominacion_transportista": "string", "items": [], "ubigeo_punto_partida": "string", "direccion_punto_partida": "string", "ubigeo_punto_llegada": "string", "direccion_punto_llegada": "string", "numero_placa_vehiculo_principal": "string", "fecha_inicio_traslado": "string", "peso_bruto_total_carga": "string" } ``` -------------------------------- ### API Response Examples Source: https://docs.apisunat.pe/integracion/facturacion-electronica/boleta/boleta-inafecta Various response payloads for successful and failed requests. ```json { "success": true, "message": "Boleta B001-123 emitida correctamente", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucode.pe/20123456789-03-B001-123.xml", "cdr": "http://api.lucode.pe/R-20123456789-03-B001-123.xml", "pdf": { "ticket": "http://api.lucode.pe/pdf/ticket/20123456789-03-B001-123", "a4": "http://api.lucode.pe/pdf/a4/20123456789-03-B001-123" } } } ``` ```json { "success": true, "message": "Boleta B001-123 emitida correctamente", "payload": { "estado": "PENDIENTE", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucode.pe/20123456789-03-B001-123.xml", "cdr": null, "pdf": { "ticket": "http://api.lucode.pe/pdf/ticket/20123456789-03-B001-123" } } } ``` ```json { "success": false, "message": "ERROR: Documento B001-123 fue emitido anteriormente" } ``` ```json { "success": false, "message": "JSON no estructurado correctamente (Validación capa 01)", "payload": { "documento": [ "El campo documento es requerido." ] } } ``` ```json { "success": false, "message": "Error en la autenticación, token no válido." } ``` -------------------------------- ### API Response Examples Source: https://docs.apisunat.pe/integracion/guias-de-remision/remitente Common response payloads for successful requests and various error scenarios. ```json { "success": true, "message": "Guía de Remision T001-1 generado correctamente", "payload": { "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-FF01-123.xml", "cdr": "https://apisunat.pe/R-20123456789-01-FF01-123.xml", } } ``` ```json { "success": false, "message": "Error en la autenticación, token no válido." } ``` ```json { "success": false, "message": "ERROR: Documento T001-123 fue emitido anteriormente" } ``` ```json { "success": false, "message": "JSON no estructurado correctamente (Validación capa 01)", "payload": { "documento": [ "El campo documento es requerido." ] } } ``` -------------------------------- ### GET /api/v1/sunat/rce Source: https://docs.apisunat.pe/sunat/reporte-compras Obtiene el reporte de compras detallado filtrado por periodo y otros parámetros opcionales. ```APIDOC ## GET /api/v1/sunat/rce ### Description Obtiene el reporte de compras detallado filtrado por periodo y otros parámetros opcionales. ### Method GET ### Endpoint https://dev.apisunat.pe/api/v1/sunat/rce ### Parameters #### Query Parameters - **period** (string) - Required - Año y mes (ej. 202502) - **page** (integer) - Optional - Número de página - **start_date** (string) - Optional - Fecha de inicio (yyyy-mm-dd) - **end_date** (string) - Optional - Fecha de fin (yyyy-mm-dd) - **document_type** (string) - Optional - Tipo de comprobante (01: Factura, 03: Boletas, 07: Notas de Crédito, 08: Notas de Débito) - **document_ruc** (string) - Optional - RUC del emisor del comprobante ### Request Example GET https://dev.apisunat.pe/api/v1/sunat/rce?period=202512&page=1 Authorization: Bearer ``` -------------------------------- ### POST /api/v3/daily-summary Source: https://docs.apisunat.pe/integracion/facturacion-electronica/anular-comprobante/anular-boleta Endpoint para procesar la anulación de boletas a través de un resumen diario. ```APIDOC ## POST https://sandbox.apisunat.pe/api/v3/daily-summary ### Description Este endpoint permite anular boletas mediante el envío de un resumen diario. Requiere un token de autorización en el encabezado. ### Method POST ### Endpoint https://sandbox.apisunat.pe/api/v3/daily-summary ### Request Body - **documento** (string) - Required - Debe ser "resumen_diario" - **documentos_afectados** (array) - Required - Lista de documentos a anular ### Request Example { "documento": "resumen_diario", "documentos_afectados": [ { "accion_resumen": "anular", "documento": "boleta", "serie": "B001", "numero": "1" } ] } ### Response #### Success Response (200) - **success** (boolean) - Indica si la solicitud fue procesada - **message** (string) - Mensaje informativo - **payload** (object) - Detalles del estado del documento #### Response Example { "success": true, "message": "Factura F001-123 emitida correctamente", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucode.pe/20123456789-01-FF01-123.xml", "cdr": "http://api.lucode.pe/R-20123456789-01-FF01-123.xml" } } ``` -------------------------------- ### Respuestas de éxito y estados de procesamiento Source: https://docs.apisunat.pe/integracion/facturacion-electronica/nota-de-credito/anular-operacion Ejemplos de respuestas exitosas indicando si el comprobante fue aceptado, está pendiente o fue rechazado por SUNAT. ```json { "success": true, "message": "El comprobante fue enviado y aceptado por SUNAT.", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-07-F001-123.xml", "cdr": "https://apisunat.pe/R-20123456789-07-F001-123.xml", "pdf": { "ticket": "https://apisunat.pe/pdf/ticket/20123456789-07-F001-123", "a4": "https://apisunat.pe/pdf/a4/20123456789-07-F001-123" } } } ``` ```json { "success": true, "message": "El comprobante aún está siendo procesado por SUNAT, consulte su estado en unos minutos.", "payload": { "estado": "PENDIENTE", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-07-F001-123.xml", "cdr": null, "pdf": { "ticket": "https://apisunat.pe/pdf/ticket/20123456789-07-F001-123", "a4": "https://apisunat.pe/pdf/a4/20123456789-07-F001-123" } } } ``` ```json { "success": true, "message": "El comprobante presenta errores o datos incorrectos", "payload": { "estado": "RECHAZADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-07-F001-123.xml", "cdr": "https://apisunat.pe/R-20123456789-07-F001-123.xml", "pdf": { "ticket": null, "a4": null } } } ``` -------------------------------- ### Successful Boleta Emission (Pending) Source: https://docs.apisunat.pe/integracion/facturacion-electronica/boleta/boleta-sin-documento Response indicating successful boleta emission with state 'PENDIENTE'. Includes hash, XML, and PDF ticket links, but CDR is null. ```json { "success": true, "message": "Boleta B001-123 emitida correctamente", "payload": { "estado": "PENDIENTE", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucosunat.pe/20123456789-03-B001-123.xml", "cdr": null, "pdf": { "ticket": "http://api.lucosunat.pe/pdf/ticket/20123456789-03-B001-123" } } } ``` -------------------------------- ### Guías de Remisión - Transportista Source: https://docs.apisunat.pe/integracion/guias-de-remision API endpoint for managing Guías de Remisión Transportista (Carrier's Shipping Guides). ```APIDOC ## POST /guias-de-remision/transportista ### Description Endpoint to create or manage Carrier's Shipping Guides. ### Method POST ### Endpoint /guias-de-remision/transportista ### Parameters #### Request Body - **documento** (string) - Required - Specifies the type of document, e.g., `guia_remision_transportista`. - **serie** (string) - Required - Document series number (4 characters). - **numero** (integer) - Required - Document sequential number, must be unique for the document type. - **fecha_de_emision** (string) - Required - Date of emission in `yyyy-mm-dd` format. - **hora_de_emision** (string) - Required - Time of emission in `HH:mm` format (24-hour). - **tipo_transporte** (string) - Required - Type of transport. `01` for public transport, `02` for private transport. - **motivo_traslado** (string) - Required - Reason for transfer. Examples: `01` (sale), `02` (purchase), `06` (return). - **motivo_traslado_descripcion** (string) - Optional - Description for the reason of transfer, required if 'others' is selected for `motivo_traslado` (max 100 characters). - **peso_bruto_total** (decimal) - Required - Total gross weight in kilograms (12,3 format). ### Request Example { "documento": "guia_remision_transportista", "serie": "T002", "numero": 67890, "fecha_de_emision": "2023-10-27", "hora_de_emision": "11:00", "tipo_transporte": "02", "motivo_traslado": "04", "peso_bruto_total": 200.750 } ### Response #### Success Response (200) - **status** (string) - Indicates the success status of the operation. - **message** (string) - A message confirming the operation. #### Response Example { "status": "success", "message": "Guía de remisión transportista created successfully." } ``` -------------------------------- ### POST /api/v3/documents Source: https://docs.apisunat.pe/integracion/facturacion-electronica/boleta/boleta-gratuita Issue a free invoice (Boleta Gratuita) by providing the necessary document details. ```APIDOC ## POST /api/v3/documents ### Description This endpoint allows you to issue a free invoice (Boleta Gratuita) by submitting the required document information. ### Method POST ### Endpoint https://sandbox.apisunat.pe/api/v3/documents ### Headers - **Authorization** (string) - Required - Bearer token for authentication. Obtain your unique token from the APISUNAT portal. ### Request Body - **documento** (string) - Required - Type of document, e.g., "boleta". - **serie** (string) - Required - Document series, e.g., "B001". - **numero** (integer) - Required - Document number, e.g., 123. - **fecha_de_emision** (string) - Required - Emission date in YYYY-MM-DD format, e.g., "2025-01-03". - **hora_de_emision** (string) - Optional - Emission time in HH:MM:SS format, e.g., "19:40:00". - **moneda** (string) - Required - Currency code, e.g., "PEN". - **tipo_operacion** (string) - Required - Operation type code, e.g., "0101". - **cliente_tipo_de_documento** (string) - Required - Customer's document type, e.g., "6" for RUC. - **cliente_numero_de_documento** (string) - Required - Customer's document number, e.g., "20123456789". - **cliente_denominacion** (string) - Required - Customer's name or company name, e.g., "EMPRESA DE SERVICIOS S.A.C". - **cliente_direccion** (string) - Required - Customer's address, e.g., "AV. SAN MARTIN - LIMA". - **items** (array) - Required - Array of items included in the invoice. - **unidad_de_medida** (string) - Required - Unit of measurement for the item, e.g., "NIU". - **descripcion** (string) - Required - Description of the item, e.g., "Nombre del producto". - **cantidad** (string) - Required - Quantity of the item, e.g., "1". - **valor_unitario** (string) - Required - Unit value of the item, e.g., "234". - **porcentaje_igv** (string) - Required - IGV percentage, e.g., "0". - **codigo_tipo_afectacion_igv** (string) - Required - IGV affectation code, e.g., "21". - **nombre_tributo** (string) - Required - Tax name, e.g., "GRA". - **total** (string) - Required - Total amount of the invoice, e.g., "0". ### Request Example ```json { "documento": "boleta", "serie": "B001", "numero": 123, "fecha_de_emision": "2025-01-03", "hora_de_emision": "19:40:00", "moneda": "PEN", "tipo_operacion": "0101", "cliente_tipo_de_documento": "6", "cliente_numero_de_documento": "20123456789", "cliente_denominacion": "EMPRESA DE SERVICIOS S.A.C", "cliente_direccion": "AV. SAN MARTIN - LIMA", "items": [ { "unidad_de_medida": "NIU", "descripcion": "Nombre del producto", "cantidad": "1", "valor_unitario": "234", "porcentaje_igv": "0", "codigo_tipo_afectacion_igv": "21", "nombre_tributo": "GRA" } ], "total": "0" } ``` ### Response #### Success Response (200 OK) - **success** (boolean) - Indicates if the operation was successful. - **message** (string) - A message describing the result of the operation. - **payload** (object) - Contains details about the issued document. - **estado** (string) - The status of the document, e.g., "PENDIENTE". - **hash** (string) - The hash of the document. - **xml** (string) - URL to the XML representation of the document. - **cdr** (string or null) - URL to the CDR (Constancia de Recepción), if available. - **pdf** (object) - Contains PDF related information. - **ticket** (string) - URL to the PDF ticket. #### Response Example (Success) ```json { "success": true, "message": "Boleta B001-123 emitida correctamente", "payload": { "estado": "PENDIENTE", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucode.pe/20123456789-03-B001-123.xml", "cdr": null, "pdf": { "ticket": "http://app.apisunat.pe/pdf/ticket/20123456789-03-B001-123" } } } ``` #### Error Responses - **400 Bad Request**: Returned for invalid or duplicate documents, or improperly structured JSON. - **message** (string) - Error message. - **payload** (object, optional) - Details about validation errors. - **field_name** (array) - Array of error messages for a specific field. #### Response Example (400 Bad Request - Document Duplicate) ```json { "success": false, "message": "ERROR: Documento B001-123 fue emitido anteriormente" } ``` #### Response Example (400 Bad Request - Missing Fields) ```json { "success": false, "message": "JSON no estructurado correctamente (Validación capa 01)", "payload": { "documento": [ "El campo documento es requerido." ] } } ``` - **401 Permission Denied**: Returned if the authentication token is invalid. - **success** (boolean) - Always false for errors. - **message** (string) - Error message indicating authentication failure. #### Response Example (401 Permission Denied) ```json { "success": false, "message": "Error en la autenticación, token no válido." } ``` ``` -------------------------------- ### Guías de Remisión - Remitente Source: https://docs.apisunat.pe/integracion/guias-de-remision API endpoint for managing Guías de Remisión Remitente (Sender's Shipping Guides). ```APIDOC ## POST /guias-de-remision/remitente ### Description Endpoint to create or manage Sender's Shipping Guides. ### Method POST ### Endpoint /guias-de-remision/remitente ### Parameters #### Request Body - **documento** (string) - Required - Specifies the type of document, e.g., `guia_remision_remitente`. - **serie** (string) - Required - Document series number (4 characters). - **numero** (integer) - Required - Document sequential number, must be unique for the document type. - **fecha_de_emision** (string) - Required - Date of emission in `yyyy-mm-dd` format. - **hora_de_emision** (string) - Required - Time of emission in `HH:mm` format (24-hour). - **tipo_transporte** (string) - Required - Type of transport. `01` for public transport, `02` for private transport. - **motivo_traslado** (string) - Required - Reason for transfer. Examples: `01` (sale), `02` (purchase), `06` (return). - **motivo_traslado_descripcion** (string) - Optional - Description for the reason of transfer, required if 'others' is selected for `motivo_traslado` (max 100 characters). - **peso_bruto_total** (decimal) - Required - Total gross weight in kilograms (12,3 format). ### Request Example { "documento": "guia_remision_remitente", "serie": "T001", "numero": 12345, "fecha_de_emision": "2023-10-27", "hora_de_emision": "10:30", "tipo_transporte": "01", "motivo_traslado": "01", "peso_bruto_total": 150.500 } ### Response #### Success Response (200) - **status** (string) - Indicates the success status of the operation. - **message** (string) - A message confirming the operation. #### Response Example { "status": "success", "message": "Guía de remisión remitente created successfully." } ``` -------------------------------- ### Catálogos de Referencia Source: https://docs.apisunat.pe/api-servicio/plataforma-de-confirmacion-del-rhe-y-fe Definiciones de los códigos estándar utilizados en la plataforma para la clasificación de comprobantes, pedidos, estados y motivos de disconformidad. ```APIDOC ## Catálogos de Referencia ### Códigos CPE | Cod | Descripción | |---|---| | 01 | Factura | | 02 | Recibo por Honorarios | ### Indicador de tipo de pedido | Cod | Descripción | |---|---| | C | Compras | | V | ventas | ### Código de estado | Cod | Descripción | Disponible para | |---|---|---| | 01 | PENDIENTE | Compras | | 02 | DISCONFORME | Ventas | | 03 | SUBSANADO | Compras | | 06 | PENDIENTE POR REINICIO | Compras | ### Motivos de disconformidad | Cod | Descripción | |---|---| | 1 | Plazo de pago acordado | | 2 | Monto neto pendiente de pago | | 3 | Reclamo respecto de bienes adquiridos o servicios prestados | ``` -------------------------------- ### POST /api/v1/sunat/comprobante Source: https://docs.apisunat.pe/sunat/consulta-comprobante This endpoint allows you to query a comprobante from SUNAT. ```APIDOC ## POST /api/v1/sunat/comprobante ### Description This endpoint allows you to query a comprobante from SUNAT. ### Method POST ### Endpoint https://dev.apisunat.pe/api/v1/sunat/comprobante ### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer ` ### Request Body - **tipo_comprobante** (string) - Required - The type of comprobante. - **ruc_emisor** (string) - Required - The RUC of the issuer. - **serie** (string) - Required - The serie of the comprobante. - **numero** (string) - Required - The number of the comprobante. ### Request Example ```json { "tipo_comprobante": "01", "ruc_emisor": "20100030838", "serie": "FLU1", "numero": "74647" } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### POST /api/v3/documents Source: https://docs.apisunat.pe/integracion/facturacion-electronica/boleta/boleta-descuento-item Emisión de una boleta electrónica con descuentos aplicados a nivel de ítem. ```APIDOC ## POST https://sandbox.apisunat.pe/api/v3/documents ### Description Emite una boleta electrónica enviando los datos del documento, cliente e ítems, incluyendo la posibilidad de aplicar descuentos por cada ítem. ### Method POST ### Endpoint https://sandbox.apisunat.pe/api/v3/documents ### Parameters #### Request Body - **documento** (string) - Required - Tipo de documento (ej. "boleta") - **serie** (string) - Required - Serie del documento - **numero** (integer) - Required - Número correlativo - **fecha_de_emision** (string) - Required - Fecha en formato YYYY-MM-DD - **hora_de_emision** (string) - Optional - Hora en formato HH:MM:SS - **moneda** (string) - Required - Código de moneda (ej. "PEN") - **tipo_operacion** (string) - Required - Código de operación SUNAT - **cliente_tipo_de_documento** (string) - Required - Tipo de documento del cliente - **cliente_numero_de_documento** (string) - Required - Número de documento del cliente - **cliente_denominacion** (string) - Required - Nombre o razón social del cliente - **cliente_direccion** (string) - Required - Dirección del cliente - **items** (array) - Required - Lista de productos - **total** (string) - Required - Monto total del documento ### Request Example { "documento": "boleta", "serie": "B001", "numero": 123, "fecha_de_emision": "2025-01-03", "moneda": "PEN", "tipo_operacion": "0101", "cliente_tipo_de_documento": "1", "cliente_numero_de_documento": "75413811", "cliente_denominacion": "NOMBRE DEL CLIENTE", "cliente_direccion": "AV. SAN MARTIN - LIMA", "items": [ { "unidad_de_medida": "NIU", "descripcion": "Nombre del producto", "cantidad": "2", "valor_unitario": "234.125457", "porcentaje_igv": "18", "codigo_tipo_afectacion_igv": "10", "nombre_tributo": "IGV", "descuentos": [ { "monto": "5.00", "codigo": "00" } ] } ], "total": "546.64" } ### Response #### Success Response (200) - **success** (boolean) - Estado de la operación - **message** (string) - Descripción del resultado - **payload** (object) - Datos del documento emitido (estado, hash, xml, cdr, pdf) #### Response Example { "success": true, "message": "Boleta B001-123 emitida correctamente", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "http://api.lucode.pe/20123456789-03-B001-123.xml", "cdr": "http://api.lucode.pe/R-20123456789-03-B001-123.xml", "pdf": { "ticket": "http://api.lucode.pe/pdf/ticket/20123456789-03-B001-123" } } } ``` -------------------------------- ### Factura API - General Information Source: https://docs.apisunat.pe/integracion/facturacion-electronica/factura Information about available environments and how to obtain API tokens. For more details on API usage, please visit the configuration page. ```APIDOC ## Factura API - General Information ### Description Each RUC has a unique token for both Test and Production environments. For more details on API usage, please visit the configuration page. ### Endpoint [Configuration API Documentation Link](https://docs.apisunat.pe/integracion/facturacion-electronica/configuracion-api) ### Environments - **Pruebas (Test)** - **Producción (Production)** ### Authentication Each RUC is provided with a unique token for accessing both environments. ``` -------------------------------- ### POST /api/v3/documents Source: https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-anticipos Endpoint para registrar y enviar documentos electrónicos a SUNAT. ```APIDOC ## POST https://sandbox.apisunat.pe/api/v3/documents ### Description Envía un comprobante electrónico (factura) para su validación y procesamiento por SUNAT. Requiere autenticación mediante un token de organización. ### Method POST ### Endpoint https://sandbox.apisunat.pe/api/v3/documents ### Request Body - **documento** (string) - Tipo de documento (ej. "factura") - **serie** (string) - Serie del documento - **numero** (integer) - Número del documento - **fecha_de_emision** (string) - Fecha en formato YYYY-MM-DD - **fecha_de_vencimiento** (string) - Fecha en formato YYYY-MM-DD - **moneda** (string) - Código de moneda (ej. "USD") - **tipo_operacion** (string) - Código de tipo de operación - **cliente_tipo_de_documento** (string) - Tipo de documento del cliente - **cliente_numero_de_documento** (string) - Número de documento del cliente - **cliente_denominacion** (string) - Nombre o razón social del cliente - **items** (array) - Lista de productos o servicios - **anticipos** (array) - Lista de anticipos aplicados - **total** (string) - Monto total - **cuotas** (array) - Información de cuotas de pago ### Request Example { "documento": "factura", "serie": "F001", "numero": 10, "fecha_de_emision": "2026-04-07", "moneda": "USD", "items": [], "anticipos": [], "total": "264.21" } ### Response #### Success Response (200) - **success** (boolean) - Indica si la solicitud fue procesada - **message** (string) - Descripción del estado - **payload** (object) - Detalles del documento (estado, hash, enlaces a XML/CDR/PDF) #### Response Example { "success": true, "message": "El comprobante fue enviado y aceptado por SUNAT.", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-B001-123.xml" } } ``` -------------------------------- ### Authorization Header Source: https://docs.apisunat.pe/integracion/facturacion-electronica/boleta/boleta-sin-documento Include the 'Authorization' header with your unique token for authentication. Obtain your token from the app.apisunat.pe portal. ```powershell header 'Authorization: Bearer {TOKEN}' ``` -------------------------------- ### Respuestas de estado de comprobante Source: https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-placa-vehicular Ejemplos de respuestas exitosas indicando si el comprobante fue aceptado, está pendiente o fue rechazado. ```json { "success": true, "message": "El comprobante fue enviado y aceptado por SUNAT.", "payload": { "estado": "ACEPTADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-B001-123.xml", "cdr": "https://apisunat.pe/R-20123456789-01-B001-123.xml", "pdf": { "ticket": "https://apisunat.pe/pdf/ticket/20123456789-03-B001-123", "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123" } } } ``` ```json { "success": true, "message": "El comprobante aún está siendo procesado por SUNAT, consulte su estado en unos minutos.", "payload": { "estado": "PENDIENTE", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-B001-123.xml", "cdr": null, "pdf": { "ticket": "https://apisunat.pe/pdf/ticket/20123456789-01-B001-123", "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123" } } } ``` ```json { "success": true, "message": "El comprobante presenta errores o datos incorrectos", "payload": { "estado": "RECHAZADO", "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=", "xml": "https://apisunat.pe/20123456789-01-B001-123.xml", "cdr": "https://apisunat.pe/R-20123456789-01-B001-123.xml", "pdf": { "ticket": "https://apisunat.pe/pdf/ticket/20123456789-01-B001-123", "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123" } } } ```