Ejemplos de facturas
Recetas listas para copiar y validadas ante SUNAT: solo cambia la API key, la serie y los datos del cliente por los tuyos. Los campos están explicados en Emitir una factura y en Emitir una boleta.
Descuentos, detracción y retención tienen su propia guía, y la factura al crédito con cuotas también (guía).
Factura en dólares
Sección titulada «Factura en dólares»Envía "currency": "USD" y los precios en dólares. Faktura calcula el IGV y los totales en esa moneda, y el importe en letras dice «DÓLARES AMERICANOS». No necesitas tipo de cambio, salvo que la factura lleve detracción.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9001" \ -d '{ "series": "F001", "currency": "USD", "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C." }, "items": [ { "description": "Licencia de software (anual)", "quantity": 1, "unit_price": 590 } ] }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9001']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'currency' => 'USD', 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', ], 'items' => [ [ 'description' => 'Licencia de software (anual)', 'quantity' => 1, 'unit_price' => 590, ], ], ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9001', }, body: JSON.stringify({ series: 'F001', currency: 'USD', customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.' }, items: [ { description: 'Licencia de software (anual)', quantity: 1, unit_price: 590, }, ], }),});const data = await response.json();Respuesta 201 Created (resumida):
{ "currency": "USD", "totals": { "taxed": "500.00", "exempt": "0.00", "unaffected": "0.00", "free": "0.00", "igv": "90.00", "icbper": "0.00", "total_taxes": "90.00", "discounts": "0.00", "charges": "0.00", "total": "590.00" }, "amount_in_words": "SON QUINIENTOS NOVENTA CON 00/100 DÓLARES AMERICANOS"}Precios sin IGV
Sección titulada «Precios sin IGV»Si tu sistema guarda los precios sin IGV, envía "price_includes_tax": false: Faktura suma el 18 % encima. Con true (por defecto), unit_price ya incluye el IGV.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9002" \ -d '{ "series": "F001", "price_includes_tax": false, "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C." }, "items": [ { "description": "Servicio de consultoría", "quantity": 10, "unit_price": 100, "unit_code": "HUR" } ] }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9002']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'price_includes_tax' => false, 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', ], 'items' => [ [ 'description' => 'Servicio de consultoría', 'quantity' => 10, 'unit_price' => 100, 'unit_code' => 'HUR', ], ], ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9002', }, body: JSON.stringify({ series: 'F001', price_includes_tax: false, customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.' }, items: [ { description: 'Servicio de consultoría', quantity: 10, unit_price: 100, unit_code: 'HUR', }, ], }),});const data = await response.json();Diez horas de S/ 100.00 sin IGV dan una base de S/ 1000.00 y un total de S/ 1180.00:
{ "totals": { "taxed": "1000.00", "exempt": "0.00", "unaffected": "0.00", "free": "0.00", "igv": "180.00", "icbper": "0.00", "total_taxes": "180.00", "discounts": "0.00", "charges": "0.00", "total": "1180.00" }}Ítems gravados, exonerados e inafectos en la misma factura
Sección titulada «Ítems gravados, exonerados e inafectos en la misma factura»Cada ítem lleva su igv_type. Sin él, el ítem es gravado. El IGV solo se calcula sobre los gravados. Qué productos están exonerados o inafectos lo decide la ley, no Faktura: consúltalo con tu contador.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9003" \ -d '{ "series": "F001", "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C." }, "items": [ { "description": "Laptop", "quantity": 1, "unit_price": 118 }, { "description": "Libro", "quantity": 2, "unit_price": 30, "igv_type": "exonerado" }, { "description": "Producto inafecto", "quantity": 1, "unit_price": 50, "igv_type": "inafecto" } ] }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9003']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', ], 'items' => [ ['description' => 'Laptop', 'quantity' => 1, 'unit_price' => 118], [ 'description' => 'Libro', 'quantity' => 2, 'unit_price' => 30, 'igv_type' => 'exonerado', ], [ 'description' => 'Producto inafecto', 'quantity' => 1, 'unit_price' => 50, 'igv_type' => 'inafecto', ], ], ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9003', }, body: JSON.stringify({ series: 'F001', customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.' }, items: [ { description: 'Laptop', quantity: 1, unit_price: 118 }, { description: 'Libro', quantity: 2, unit_price: 30, igv_type: 'exonerado', }, { description: 'Producto inafecto', quantity: 1, unit_price: 50, igv_type: 'inafecto', }, ], }),});const data = await response.json();Cada tipo va en su propio total y el IGV sale solo de la laptop:
{ "totals": { "taxed": "100.00", "exempt": "60.00", "unaffected": "50.00", "free": "0.00", "igv": "18.00", "icbper": "0.00", "total_taxes": "18.00", "discounts": "0.00", "charges": "0.00", "total": "228.00" }}Entregas gratuitas (muestras o regalos)
Sección titulada «Entregas gratuitas (muestras o regalos)»Un ítem gratuito no se cobra: unit_price es su valor referencial (con IGV, salvo que envíes price_includes_tax: false). Su valor sin IGV aparece en totals.free, pero no suma al total. Usa gratuito_exonerado o gratuito_inafecto si el bien regalado está exonerado o inafecto. Los ítems gratuitos no admiten descuentos.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9004" \ -d '{ "series": "F001", "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C." }, "items": [ { "description": "Caja de café 1 kg", "quantity": 5, "unit_price": 59 }, { "description": "Taza de regalo", "quantity": 1, "unit_price": 23.60, "igv_type": "gratuito" } ] }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9004']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', ], 'items' => [ [ 'description' => 'Caja de café 1 kg', 'quantity' => 5, 'unit_price' => 59, ], [ 'description' => 'Taza de regalo', 'quantity' => 1, 'unit_price' => 23.60, 'igv_type' => 'gratuito', ], ], ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9004', }, body: JSON.stringify({ series: 'F001', customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.' }, items: [ { description: 'Caja de café 1 kg', quantity: 5, unit_price: 59 }, { description: 'Taza de regalo', quantity: 1, unit_price: 23.60, igv_type: 'gratuito', }, ], }),});const data = await response.json();La taza aparece en free por su valor sin IGV (23.60 / 1.18 = 20.00) y el cliente paga solo el café:
{ "totals": { "taxed": "250.00", "exempt": "0.00", "unaffected": "0.00", "free": "20.00", "igv": "45.00", "icbper": "0.00", "total_taxes": "45.00", "discounts": "0.00", "charges": "0.00", "total": "295.00" }}Con orden de compra, guía de remisión y vencimiento
Sección titulada «Con orden de compra, guía de remisión y vencimiento»La orden de compra del cliente, las guías de remisión, las observaciones y la fecha de vencimiento viajan en el XML y aparecen en el PDF.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9005" \ -d '{ "series": "F001", "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C.", "address": "AV. LOS OLIVOS 123, LIMA" }, "items": [ { "description": "Cemento Portland tipo I (bolsa 42.5 kg)", "quantity": 100, "unit_price": 29.50, "unit_code": "BG" } ], "purchase_order": "OC-2026-001", "despatch_references": [ { "type": "09", "number": "T001-123" } ], "observations": "Entrega en almacén central", "due_date": "2026-12-15" }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9005']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', 'address' => 'AV. LOS OLIVOS 123, LIMA', ], 'items' => [ [ 'description' => 'Cemento Portland tipo I (bolsa 42.5 kg)', 'quantity' => 100, 'unit_price' => 29.50, 'unit_code' => 'BG', ], ], 'purchase_order' => 'OC-2026-001', 'despatch_references' => [['type' => '09', 'number' => 'T001-123']], 'observations' => 'Entrega en almacén central', 'due_date' => '2026-12-15', ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9005', }, body: JSON.stringify({ series: 'F001', customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.', address: 'AV. LOS OLIVOS 123, LIMA', }, items: [ { description: 'Cemento Portland tipo I (bolsa 42.5 kg)', quantity: 100, unit_price: 29.50, unit_code: 'BG', }, ], purchase_order: 'OC-2026-001', despatch_references: [{ type: '09', number: 'T001-123' }], observations: 'Entrega en almacén central', due_date: '2026-12-15', }),});const data = await response.json();{ "totals": { "taxed": "2500.00", "exempt": "0.00", "unaffected": "0.00", "free": "0.00", "igv": "450.00", "icbper": "0.00", "total_taxes": "450.00", "discounts": "0.00", "charges": "0.00", "total": "2950.00" }, "purchase_order": "OC-2026-001", "due_date": "2026-12-15"}Con fecha de emisión anterior (contingencia)
Sección titulada «Con fecha de emisión anterior (contingencia)»Si vendiste sin conexión, emite después con la fecha real de la venta en issue_date: hasta 3 días atrás, nunca una fecha futura. En este ejemplo la venta fue el 11 de noviembre y se emite el 13; usa siempre una fecha dentro de ese plazo.
curl -X POST https://faktura-test.cgallardo.me/v1/invoices \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-pedido-9006" \ -d '{ "series": "F001", "issue_date": "2026-11-11", "customer": { "doc_type": "RUC", "doc_number": "20100070970", "name": "CLIENTE S.A.C." }, "items": [ { "description": "Laptop", "quantity": 1, "unit_price": 118 } ] }'use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->withHeaders(['Idempotency-Key' => 'erp-pedido-9006']) ->post('https://faktura-test.cgallardo.me/v1/invoices', [ 'series' => 'F001', 'issue_date' => '2026-11-11', 'customer' => [ 'doc_type' => 'RUC', 'doc_number' => '20100070970', 'name' => 'CLIENTE S.A.C.', ], 'items' => [['description' => 'Laptop', 'quantity' => 1, 'unit_price' => 118]], ]);
$data = $response->json();const response = await fetch('https://faktura-test.cgallardo.me/v1/invoices', { method: 'POST', headers: { Authorization: 'Bearer sk_test_...', 'Content-Type': 'application/json', 'Idempotency-Key': 'erp-pedido-9006', }, body: JSON.stringify({ series: 'F001', issue_date: '2026-11-11', customer: { doc_type: 'RUC', doc_number: '20100070970', name: 'CLIENTE S.A.C.' }, items: [{ description: 'Laptop', quantity: 1, unit_price: 118 }], }),});const data = await response.json();{ "issue_date": "2026-11-11", "totals": { "taxed": "100.00", "exempt": "0.00", "unaffected": "0.00", "free": "0.00", "igv": "18.00", "icbper": "0.00", "total_taxes": "18.00", "discounts": "0.00", "charges": "0.00", "total": "118.00" }}