npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-apisunat

v0.1.0

Published

Nodo de n8n para API SUNAT: emite facturas, boletas, notas, guías de remisión y anulaciones en SUNAT (Perú) y recibe sus webhooks.

Readme

n8n-nodes-apisunat

Nodo de n8n para API SUNAT, la API de facturación electrónica para Perú. Emite facturas, boletas, notas de crédito y débito, retenciones, guías de remisión y anulaciones en SUNAT desde tus flujos de n8n, y recibe la respuesta de SUNAT por webhook.

API SUNAT arma el XML UBL 2.1, lo firma con tu certificado, lo envía a SUNAT y te devuelve el CDR y el PDF. Tú solo envías los datos de la venta en JSON.

Instalación

En n8n, ve a Settings → Community Nodes → Install y escribe n8n-nodes-apisunat.

En una instalación propia también puedes instalarlo con npm en la carpeta de nodos de n8n (~/.n8n/nodes):

npm install n8n-nodes-apisunat

Credenciales

  • API SUNAT API: tu clave de API del panel de API SUNAT. Las claves asu_test_ emiten en SUNAT beta sin consumir tu plan; las asu_live_ emiten comprobantes reales. Ver autenticación.
  • API SUNAT Webhook: el secreto whsec_ del webhook que creas en el panel, para el nodo API SUNAT Trigger.

Nodo API SUNAT

| Recurso | Operaciones | |---|---| | Document | Issue (factura, boleta, nota o retención), Get, Get Many, Download File (PDF, XML, ZIP o CDR), Resend, Query SUNAT, Send Email | | Void | Create (comunicación de baja o resumen diario), Get | | Guide | Issue (guía de remisión remitente), Get | | Calculation | Calculate (totales e IGV sin emitir) | | Account | Get (plan y consumo del mes) | | Issuer | Get, Get Many (RUC registrados) | | Catalog | Get (catálogos de SUNAT), Search Products (catálogo 25) |

Las operaciones que emiten (Issue y Void Create) piden un Idempotency Key. Usa un valor estable de tu sistema, por ejemplo {{ "venta-" + $json.id }}: si el flujo se repite, la API devuelve el mismo comprobante y nunca emite dos veces. Ver idempotencia.

El cuerpo de Issue es el mismo JSON de POST /documents. Por ejemplo, una factura:

{
  "documentType": "01",
  "currency": "PEN",
  "issueDate": "2026-10-27",
  "customer": { "documentType": "6", "documentNumber": "20100066603" },
  "items": [{ "description": "Consultoría octubre", "quantity": 1, "unitPrice": 1180 }]
}

Todos los campos están en la documentación de documentos y hay ejemplos de factura, boleta y guía de remisión.

Download File deja el archivo en un campo binario (data por defecto), listo para enviarlo por correo, guardarlo en Drive o adjuntarlo a WhatsApp.

Nodo API SUNAT Trigger

Inicia el flujo cuando SUNAT acepta, observa, rechaza o anula un documento.

  1. Agrega API SUNAT Trigger a tu flujo y copia su URL de producción.
  2. En el panel de API SUNAT, crea un webhook con esa URL en el mismo modo (Prueba o Producción) que tu clave, y elige sus eventos.
  3. Copia el secreto whsec_ en la credencial API SUNAT Webhook.

El nodo verifica la firma X-Apisunat-Signature (HMAC-SHA256 del cuerpo crudo) y rechaza con 401 los eventos sin firma válida o con más de 5 minutos de antigüedad. Los eventos que no elegiste se responden 200 y se ignoran. Con Only Live Mode también ignora los eventos de prueba. Ver webhooks.

Ejemplos de flujos

  • Venta pagada en tu tienda → API SUNAT · Issue → Download File (PDF) → enviar al cliente por correo o WhatsApp.
  • API SUNAT Trigger (document.rejected) → avisar a tu equipo por Slack con sunat.errorCode y sunat.errorMessage. Cada código tiene su explicación en errores de SUNAT.
  • Cierre de mes → Document · Get Many con filtro de fechas → hoja de cálculo para tu contador.

Enlaces

API SUNAT es un servicio de RANGEL TECHNOLOGIES E.I.R.L. (RUC 20614483459). No es la API oficial de SUNAT: se conecta a sus servicios por ti.

Licencia

MIT