Integrar VeriFactu en Node.js
· Equipo Factuneo
Emite facturas VeriFactu desde Node.js con fetch nativo: alta del emisor, emisión con idempotencia y webhook con Express. Sin XML ni SOAP a mano.
Integra VeriFactu en Node.js con fetch (nativo desde Node 18). Una llamada y tienes huella, QR y envío a la AEAT.
1. API key
Guarda tu API key en process.env.FACTUNEO_API_KEY.
2. Alta de emisor
const BASE = 'https://factuneo.es/api/v1'
const headers = {
'x-api-key': process.env.FACTUNEO_API_KEY,
'Content-Type': 'application/json',
}
await fetch(BASE + '/emisores', {
method: 'POST',
headers,
body: JSON.stringify({ nif: 'B12345678', nombreRazon: 'Mi Empresa SL', certMode: 'PROPIO' }),
})
3. Emitir factura
const res = await fetch(BASE + '/invoices', {
method: 'POST',
headers: { ...headers, 'Idempotency-Key': 'FAC-2026-0001' },
body: JSON.stringify({
emisorNif: 'B12345678',
numeroSerie: 'FAC-2026-0001',
fechaExpedicion: '2026-06-08',
tipoFactura: 'F1',
nombreRazonEmisor: 'Mi Empresa SL',
descripcionOperacion: 'Servicios',
baseImponible: 100.00,
cuotaIva: 21.00,
importeTotal: 121.00,
destinatarios: [{ nombreRazon: 'Cliente SA', nif: 'A28000024' }],
desglose: [{
claveRegimen: '01',
calificacionOperacion: 'S1',
tipoImpositivo: 21,
baseImponible: 100.00,
cuotaRepercutida: 21.00,
}],
}),
})
const factura = await res.json() // factura.huella, factura.qr, factura.estado
4. Webhook (Express)
app.post('/webhooks/factuneo', (req, res) => {
// verifica la firma HMAC-SHA256 con el secreto de tu cuenta
const { invoiceId, estado } = req.body
res.sendStatus(204)
})
Referencia completa en la documentación. ¿Eligiendo proveedor? Mira la comparativa.