Brazilian CNPJ Data Enrichment using Google Sheets and Public API - n8n Workflow

Use this efficient n8n workflow template to automate Brazilian company data lookup (CNPJ) using the free MinhaReceita API and automatically enrich corresponding rows in Google Sheets. Scalable and robust n8n automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Sales and Business Intelligence Analysts: Need up-to-date cadastral data for Brazilian firms.
Compliance and Legal Teams: Requiring official CNPJ information (e.g., status, legal nature).
Data Operations Specialists: Looking for robust, scalable n8n templates for external API integration and batch processing.
Anyone self-hosting n8n: Seeking a reliable n8n workflow to manage and enrich large datasets.

Overview

Managing and enriching large lists of identifiers, especially for specific regions like Brazil, often requires manual lookups or expensive enterprise tools. This powerful n8n workflow solves this by providing a robust, free solution for CNPJ data enrichment. Utilizing the MinhaReceita.org public API, this n8n automation efficiently reads hundreds of CNPJs from a Google Sheet, fetches comprehensive official data (including contact details, corporate name, legal status, and address), and writes the enriched data back to the correct rows. This n8n workflow drastically reduces manual data entry time and ensures your business data is accurate and up-to-date, making it an essential n8n template for data processing in the region.

How it Works

The process begins with the 'Execute Workflow Manually' n8n trigger. After execution starts, the workflow initializes necessary variables, including your Telegram ID and the MinhaReceita API base URL, using the 'Settings' n8n node.


  1. Data Acquisition: The 'Get All CNPJs in Sheet' n8n node connects to the specified Google Sheet. Crucially, it filters the data, reading only rows where the 'razaosocial' (corporate name) column is empty, ensuring that only records needing enrichment are processed.

  2. Batch Processing: The list of pending CNPJs is then passed to the 'Loop CNPJs' n8n node, which splits the workload into manageable batches (100 items per batch, by default) to enhance performance and manage API limits.

  3. API Enrichment: For each item in the batch, the 'Send API Request' n8n node performs an HTTP GET request to the MinhaReceita API, using the specific CNPJ number from the current item. The API returns over 40 fields of detailed company information.

  4. Data Update: The 'Update CNPJ Info in Sheet' Google Sheets n8n node takes the newly retrieved data and performs an update operation on the Google Sheet. It uses the rownumber metadata captured by the initial Google Sheets n8n node to ensure the updated information is written exactly to the correct row in the spreadsheet.

  5. Completion Notification: Once all batches are processed and the loop is complete, the workflow passes through a 'Limit' n8n node and finally triggers the 'Notify When Finish' Telegram n8n node, sending a single confirmation message that the entire n8n workflow execution is concluded.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON code and paste it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. Google Sheets Credentials: Click on the 'Get All CNPJs in Sheet' n8n node and the 'Update CNPJ Info in Sheet' n8n node. You must set up or select an existing Google Sheets OAuth2 API credential. Ensure the service account has read/write access to your target spreadsheet.

  3. Spreadsheet Setup: Configure the Document ID and Sheet Name within both Google Sheets n8n nodes to point to your specific sheet containing the CNPJ list.

  4. Telegram Configuration: In the 'Settings' n8n node, replace YOURTELEGRAMID with your actual Telegram Chat ID. In the 'Notify When Finish' n8n node, set up or select your Telegram API credentials.

  5. Activate: Save and activate the n8n workflow. Since it uses a manual n8n trigger, run it whenever you need to enrich your data.

Node Details

This n8n workflow template uses several key n8n node types to achieve its goal:

Execute Workflow Manually (n8n trigger): The starting point for the n8n workflow. It initiates the data processing task immediately upon manual execution.
Set (Settings n8n node): Defines configuration variables like telegramid and the apibaseurl for centralized management of external resources.
Google Sheets (Get All CNPJs in Sheet): Function: Reads data from the spreadsheet. Key Configuration: Uses the 'Read' operation and applies a filter based on an empty 'razaosocial' column to select only unprocessed CNPJs.
Split In Batches (Loop CNPJs): Function: Manages the iterative nature of the n8n workflow by chunking the list of CNPJs into batches of 100 before processing them via the API.
HTTP Request (Send API Request): Function: Contacts the external MinhaReceita API. Key Configuration: Dynamically builds the URL using expressions: ={{ $('Settings').item.json.apibaseurl }}{{ $json.cnpj }}.
Google Sheets (Update CNPJ Info in Sheet): Function: Writes the enriched data back into the sheet. Key Configuration: Uses the 'Update' operation and matches the row using the dynamic row_number received from the first Google Sheets n8n node, ensuring precise data replacement.
Limit: Ensures the subsequent 'Notify When Finish' n8n node only receives one item, preventing message spam.
Telegram (Notify When Finish): Function: Sends a confirmation message via Telegram once the complete bulk operation of this n8n workflow is finished.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Brazilian Full Stack Developer passionate about making automation accessible to everyone. I create free n8n workflows that solve real problems - from NASA space content to marketing automation. Proving that powerful automation doesn't need to be expensive or complicated. Teaching through templates, one node at a time.

Featured*