create_invoice
Issue a Peru electronic CPE (comprobante de pago electrónico) — FACTURA (B2B, buyer RUC) or BOLETA (B2C consumer) — declared to SUNAT. Two backends (auto-selected from your credential header, or force with "provider"): NUBEFACT (headers x-nubefact-ruta = your unique full RUTA URL e.g. https://api.nubefact.com/api/v1/<hash>, AND x-nubefact-token = your account TOKEN; free DEMO at www.nubefact.com) or APISUNAT (PSE cloud; headers x-apisunat-persona-id + x-apisunat-persona-token + x-apisunat-ruc = your 11-digit issuer RUC; free self-signup at apisunat.com with a DEV persona for testing). Both keep your SUNAT credentials in your own provider account; this server forwards them per-request and stores nothing. The same credentials switch to production at the account level, so this server reports mode "nubefact-account"/"apisunat-account" honestly rather than guessing demo vs production. ⚠️ NUMBERING IS MERCHANT-MANAGED: this server is stateless and does NOT track sequences — YOU must supply "serie" (e.g. F001 for facturas, B001 for boletas) and the next sequential "numero" yourself; reusing a numero is rejected by SUNAT, skipping one leaves a gap. Give item prices WITH IGV included (precio_unitario) — this server computes valor_unitario, subtotal, IGV (18%) and totals for you.
Parameters13
| provider | string | optional | Optional. Which backend OSE/PSE to issue through. Omit to auto-detect from your credential header (x-nubefact-ruta -> nubefact; x-apisunat-persona-id -> apisunat; default nubefact). |
| comprobante_type | string | required | factura = B2B invoice (buyer must have an 11-digit RUC); boleta = B2C consumer receipt (buyer DNI or none). Determines the tipo_de_comprobante and the required serie prefix (F.../B...). |
| serie | string | required | Document series, exactly 4 chars. FACTURA starts with F (e.g. F001); BOLETA starts with B (e.g. B001). Merchant-defined; must exist in your Nubefact account. |
| numero | integer | required | Sequential correlative number YOU manage (this server is stateless and does not track it). No leading zeros; 1 to 8 digits. Reusing a numero is rejected by SUNAT. |
| customer_document_type | string | optional | Buyer document type. RUC (11 digits) is REQUIRED for factura. DNI (8 digits) is typical for boleta. Defaults: factura->RUC, boleta->DNI. |
| customer_document_number | string | required | Buyer RUC (11 digits) or DNI (8 digits). For a factura this must be a valid 11-digit RUC. |
| customer_name | string | required | Buyer legal name / full name (razón social o nombre completo). |
| customer_address | string | optional | Buyer address (dirección). Recommended for factura; optional for boleta. |
| customer_email | string | optional | Optional buyer email — Nubefact emails the CPE to the buyer when provided. |
| items | array | required | Line items. Each price is the UNIT price INCLUDING IGV in PEN (soles); this server derives the untaxed value, IGV and totals. |
| igv_percent | number | optional | IGV rate percent. Default 18 (Peru standard). Only change if you know the item is under a special rate. |
| sunat_transaction | integer | optional | SUNAT transaction type (sunat_transaction). Default 1 (VENTA INTERNA). Other codes are for special operations (exportación, detracción, etc.). |
| fecha_de_emision | string | optional | Optional emission date DD-MM-AAAA. Defaults to today (America/Lima). SUNAT expects the current date. |
Raw schema
{
"type": "object",
"properties": {
"provider": {
"type": "string",
"enum": [
"nubefact",
"apisunat"
],
"description": "Optional. Which backend OSE/PSE to issue through. Omit to auto-detect from your credential header (x-nubefact-ruta -> nubefact; x-apisunat-persona-id -> apisunat; default nubefact)."
},
"comprobante_type": {
"type": "string",
"enum": [
"factura",
"boleta"
],
"description": "factura = B2B invoice (buyer must have an 11-digit RUC); boleta = B2C consumer receipt (buyer DNI or none). Determines the tipo_de_comprobante and the required serie prefix (F.../B...)."
},
"serie": {
"type": "string",
"description": "Document series, exactly 4 chars. FACTURA starts with F (e.g. F001); BOLETA starts with B (e.g. B001). Merchant-defined; must exist in your Nubefact account."
},
"numero": {
"type": "integer",
"minimum": 1,
"description": "Sequential correlative number YOU manage (this server is stateless and does not track it). No leading zeros; 1 to 8 digits. Reusing a numero is rejected by SUNAT."
},
"customer_document_type": {
"type": "string",
"enum": [
"RUC",
"DNI"
],
"description": "Buyer document type. RUC (11 digits) is REQUIRED for factura. DNI (8 digits) is typical for boleta. Defaults: factura->RUC, boleta->DNI."
},
"customer_document_number": {
"type": "string",
"description": "Buyer RUC (11 digits) or DNI (8 digits). For a factura this must be a valid 11-digit RUC."
},
"customer_name": {
"type": "string",
"description": "Buyer legal name / full name (razón social o nombre completo)."
},
"customer_address": {
"type": "string",
"description": "Buyer address (dirección). Recommended for factura; optional for boleta."
},
"customer_email": {
"type": "string",
"description": "Optional buyer email — Nubefact emails the CPE to the buyer when provided."
},
"items": {
"type": "array",
"minItems": 1,
"description": "Line items. Each price is the UNIT price INCLUDING IGV in PEN (soles); this server derives the untaxed value, IGV and totals.",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "Product/service description (descripción)."
},
"price": {
"type": "number",
"description": "Unit price INCLUDING 18% IGV, in PEN (soles)."
},
"quantity": {
"type": "number",
"description": "Quantity (cantidad). Default 1."
},
"unit": {
"type": "string",
"enum": [
"product",
"service"
],
"description": "product -> unidad_de_medida NIU, service -> ZZ. Default product."
},
"code": {
"type": "string",
"description": "Optional internal product/service code (codigo)."
}
},
"required": [
"description",
"price"
]
}
},
"igv_percent": {
"type": "number",
"description": "IGV rate percent. Default 18 (Peru standard). Only change if you know the item is under a special rate."
},
"sunat_transaction": {
"type": "integer",
"description": "SUNAT transaction type (sunat_transaction). Default 1 (VENTA INTERNA). Other codes are for special operations (exportación, detracción, etc.)."
},
"fecha_de_emision": {
"type": "string",
"description": "Optional emission date DD-MM-AAAA. Defaults to today (America/Lima). SUNAT expects the current date."
}
},
"required": [
"comprobante_type",
"serie",
"numero",
"customer_document_number",
"customer_name",
"items"
]
}