SunatEmitirCPE
Description
Section titled “Description”Issues an Electronic Payment Receipt (CPE) to SUNAT: invoice (code 01) or boleta (code 03). The node builds the XML in UBL 2.1 format, digitally signs it inside the UBLExtensions, packages it into a ZIP file and sends it over SOAP (the sendBill operation) to SUNAT or to the OSE configured in the credential. When done, it reads the CDR (acknowledgment receipt) that states whether the document was accepted, observed or rejected.
The boleta can also be reported in bulk through the daily summary node. This node sends it individually, which is valid in the beta environment or for low issuance volumes.
Configuration
Section titled “Configuration”| Field | Type | Required | Description |
|---|---|---|---|
| credentials_id | credentials | Yes | SUNAT credential (certificate + SOL user) |
| cpe | json | No | Receipt in JSON: tipo (01 invoice, 03 boleta), serie, numero, receptor, items (with valorUnitario excluding IGV). If left empty, the input data from the previous node is used. The issuer comes from the credential. |
Credentials
Section titled “Credentials”This module requires a sunat credential type with the following fields:
- Certificate (.p12): the issuer’s digital certificate
- Certificate password
- Issuer RUC (11 digits)
- SOL user and SOL password: SUNAT Clave SOL credentials
- Mode: direct (to SUNAT) or OSE (Electronic Services Operator)
- OSE URL, if mode is OSE
- Environment: beta (testing) or production
Output
Section titled “Output”{ "id": "F001-125", "tipo": "01", "serie": "F001", "numero": 125, "estado": "accepted", "codigo": "0", "descripcion": "La Factura numero F001-125, ha sido aceptada", "notas": [], "total": 118, "igv": 18, "hash": "AbCdEf123...", "xml": "...", "cdrXml": "..."}Usage Example
Section titled “Usage Example”{ "credentials_id": "cred-sunat-prod", "cpe": { "tipo": "01", "serie": "F001", "numero": 125, "receptor": { "tipoDoc": "6", "numDoc": "20123456789", "razonSocial": "Cliente SAC" }, "items": [ { "descripcion": "Consulting service", "cantidad": 1, "valorUnitario": 100, "igv": 18 } ] }}- The document only becomes valid once the CDR returns status accepted (or observed). If SUNAT rejects it, the node returns an error.
- IGV is calculated at 18% on the unit value excluding tax.
- The signed XML is persisted before sending, so it can be audited or retried even if the send fails.
- For high-volume boletas, use SunatResumenBoletas instead of issuing them one by one.
Related Nodes
Section titled “Related Nodes”- SunatEmitirNota - Issue a credit or debit note
- SunatRepresentacion - Generate the printable representation with QR
- SunatResumenBoletas - Report boletas through the daily summary