Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Finance, Invoices & Accounting

Finance, Invoices & Accounting

Create draft Moloni invoice-receipts with Portuguese NIF validation

Runs manually to check Portuguese NIF numbers and VAT rates, match or create the customer, and create a draft invoice-receipt in Moloni.

What it does

## Create draft invoice-receipts in Moloni with Portuguese NIF validation ### Who's it for Businesses in Portugal that invoice in Moloni and want to try its API from n8n. ### How it works 1. Sample payment data holds one payment: customer, NIF (Portuguese tax ID), amount with VAT and VAT rate. 2. The NIF is checked with the Portuguese check-digit rule. Without a valid NIF, the draft is made out to the final consumer (consumidor final). 3. The workflow gets a Moloni access token and confirms that each configured VAT tax_id has the right percentage. 4. It finds the customer by NIF, or creates it. 5. It creates a draft invoice-receipt (fatura-recibo) and shows its document ID. ### Setup 1. Create a Custom Auth credential with your Moloni API details and select it in Moloni: get access token: { "qs": { "client_id": "…", "client_secret": "…", "username": "…", "password": "…" } }. The developer ID and client secret are in Moloni under Configurações → Developers. 2. In Configuration, enter your company, document set, product, payment method, maturity date and language IDs, and the tax_id of each VAT rate in taxas_iva (the Moloni API …/getAll methods list them). 3. Edit Sample payment data and click Execute workflow, first on Moloni's demo account. ### Requirements - A Moloni account with API access. - Tested on n8n 2.41.6 (self-hosted) with a simulated Moloni API built from the official docs; not yet tested on a real Moloni account. ### Customization tips Replace the manual trigger with a Webhook or Form trigger. Field names are Portuguese: nome (name), valor (amount with VAT), taxa_iva (VAT rate). ### Full version The full version on Gumroad issues the final invoice right after a Stripe or webhook payment, emails the PDF, never duplicates invoices and alerts you by email when something fails. Em português: valida o NIF e cria um rascunho de fatura-recibo na Moloni.

The steps

  1. Run with sample data
  2. Sample payment data
  3. Configuration
  4. Prepare payment
  5. Validate payment and NIF
  6. Moloni: get access token
  7. Moloni: list VAT rates
  8. Check configured VAT rates
  9. Moloni: find customer by NIF
  10. Read customer search result
  11. Customer exists?
  12. Moloni: create customer
  13. Read created customer
  14. Build draft invoice-receipt

17 steps in total.

Similar automations