AutomationFlowsWeb Scraping › Look Up Brazilian Company Data by Cnpj with Forms and Minha Receita API

Look Up Brazilian Company Data by Cnpj with Forms and Minha Receita API

ByEximiaAI @eximiaai on n8n.io

This workflow hosts an n8n form that accepts a Brazilian CNPJ, validates and normalizes the input, then queries the public Minha Receita API to fetch company registration details and displays either a formatted results page or an error page with a link back to the form. Receives…

Event trigger★★★★☆ complexity16 nodesForm TriggerFormHTTP Request
Web Scraping Trigger: Event Nodes: 16 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #16995 — we link there as the canonical source.

This workflow follows the Form → Form Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "4tjCc9KAJEf8gkp5",
  "name": "Brazilian Company Lookup",
  "tags": [],
  "nodes": [
    {
      "id": "0a31b32a-db82-43d9-bebe-e27295bdbbb9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 480,
        "height": 864,
        "content": "## Brazilian Company Lookup\n\n### How it works\n\nThis workflow collects a Brazilian CNPJ through a form, prepares the API URL, cleans the submitted CNPJ value, and validates it before making a lookup request. If the CNPJ passes validation, it queries an external company data API and displays the returned information through form response screens. If validation fails, it routes the user to an error or retry form path.\n\n### Setup steps\n\n- Configure the form trigger fields so users can submit a CNPJ value in the expected field name.\n- Review the Set URL node and set the correct API base URL for the Brazilian company lookup service.\n- If the lookup API requires authentication, add the required credentials or headers to the Send API Request node.\n- Check the If node conditions to ensure they match the desired CNPJ validation rules, such as cleaned length and numeric format.\n- Customize the form response nodes with the messages and fields you want users to see for success and validation failure paths.\n\n### Customization\n\nYou can adjust the CNPJ cleaning expression, validation condition, API endpoint, and the success/error form pages to fit different lookup providers or display formats."
      },
      "typeVersion": 1
    },
    {
      "id": "e014cd42-0454-4751-ae81-e14976b60f72",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 576,
        "content": "## Capture and prepare input\n\nThe left-side starting cluster receives the submitted form data, sets the API URL values, and normalizes the submitted CNPJ string for downstream validation."
      },
      "typeVersion": 1
    },
    {
      "id": "88b19a9c-9778-4bd7-adda-40d81118ecfe",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 704,
        "height": 576,
        "content": "## Validate and handle errors\n\nThis mid-canvas branch checks whether the cleaned CNPJ is valid and, on failure, sends the user through a nearby pair of form nodes for an error or retry response."
      },
      "typeVersion": 1
    },
    {
      "id": "d13a81e1-e673-4d35-81e4-bb691c479005",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1856,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 576,
        "content": "## Query company API\n\nThis isolated request node performs the company lookup by sending a GET request to the configured API endpoint when validation succeeds."
      },
      "typeVersion": 1
    },
    {
      "id": "6c99f941-514e-47ca-b2c2-a4d12d6d84af",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 496,
        "height": 576,
        "content": "## Present lookup results\n\nThe right-side form cluster displays the API lookup results through two closely placed form paths, likely covering returned company details or alternate response sections."
      },
      "typeVersion": 1
    },
    {
      "id": "b58606f8-3a6c-43ca-88f2-e20f7088c2af",
      "name": "When Form Submitted",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        608,
        240
      ],
      "parameters": {
        "options": {},
        "formTitle": "CNPJ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "CNPJ",
              "placeholder": "00.000.000/0000-00",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter a Brazilian CNPJ. Dots, slashes and hyphens are optional."
      },
      "typeVersion": 2.3
    },
    {
      "id": "03dd5285-fb9d-441a-a73b-1dfe47c9c848",
      "name": "Handle Form 1",
      "type": "n8n-nodes-base.form",
      "position": [
        2464,
        208
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "redirectUrl": "={{ $('Set API URL Parameters').item.json.url }}",
        "respondWith": "redirect"
      },
      "typeVersion": 2.3
    },
    {
      "id": "98cbc178-fe20-4560-a9ef-f059d009ffa3",
      "name": "Handle Form 2",
      "type": "n8n-nodes-base.form",
      "position": [
        2288,
        208
      ],
      "parameters": {
        "options": {
          "formTitle": "=About the company CNPJ {{ $json.cnpj }}: {{ $json.razao_social }}",
          "buttonLabel": "Finish",
          "formDescription": "=**Company Name**\n{{ $json.razao_social }}\n\n**Trade Name**\n{{ $json.nome_fantasia }}\n\n**Status**\n{{ $json.descricao_situacao_cadastral }}\n\n**Business Size**\n{{ $json.porte }}\n\n**Primary Activity**\n{{ $json.cnae_fiscal }} - {{ $json.cnae_fiscal_descricao }}\n\n**Legal Nature**\n{{ $json.natureza_juridica }}\n\n**Business Start Date**\n{{ $json.data_inicio_atividade }}\n\n**Main Partners**\n{{ $json.qsa.map(s => s.nome_socio).join(', ') }}\n\n**Phone**\n{{ $json.ddd_telefone_1 || 'Not available' }}\n\n**Email**\n{{ $json.email || 'Not available' }}\n\n**Address**\n{{ $json.descricao_tipo_de_logradouro }} {{ $json.logradouro }}, {{ $json.numero }}{{ $json.complemento ? ', ' + $json.complemento : '' }}\n{{ $json.bairro }}\n{{ $json.municipio }} - {{ $json.uf }}\nZIP Code: {{ $json.cep }}\n\n**Other Activities**\n{{ $json.cnaes_secundarios.map(c => '\u2022 ' + c.descricao).join('\\n') }}"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "9d3aa82c-c3cc-495e-8631-0bdb8df1b086",
      "name": "Handle Form",
      "type": "n8n-nodes-base.form",
      "position": [
        2464,
        384
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "redirectUrl": "={{ $('Set API URL Parameters').item.json.url }}",
        "respondWith": "redirect"
      },
      "typeVersion": 2.3
    },
    {
      "id": "8742ceaa-c177-4710-bc78-7382ade73be1",
      "name": "Handle Form 3",
      "type": "n8n-nodes-base.form",
      "position": [
        2288,
        384
      ],
      "parameters": {
        "options": {
          "formTitle": "=About the company CNPJ {{ $('When Form Submitted').item.json.CNPJ }}",
          "buttonLabel": "Finish",
          "formDescription": "=Error:{{ $json.error.message.slice(22,-4) }}\n"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "3e0f2985-4e2b-4cb0-88c7-bfde63bb1291",
      "name": "Set API URL Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dc5f25ff-443b-42b9-be1f-2299632c747c",
              "name": "url",
              "type": "string",
              "value": "REPLACE_WITH_PRODUCTION_FORM_URL"
            },
            {
              "id": "2c3806e7-5ef5-450a-a9cb-bc688b3e38cf",
              "name": "api_base_url",
              "type": "string",
              "value": "https://minhareceita.org/"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6e2bbd47-7f7e-4fb7-ba2b-414a3437023c",
      "name": "Fetch CNPJ Data",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        1936,
        224
      ],
      "parameters": {
        "url": "={{ $('Set API URL Parameters').item.json.api_base_url }}{{ $json.CNPJ }}",
        "options": {}
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "0d345c05-9ddb-4dca-a12f-354af2dd7f8b",
      "name": "Prepare CNPJ Format",
      "type": "n8n-nodes-base.set",
      "position": [
        1008,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a6529fe3-50a3-4f52-857e-26b649bea2da",
              "name": "CNPJ",
              "type": "string",
              "value": "={{ $('When Form Submitted').item.json.CNPJ.replace(/\\D/g, '') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dea841ea-0486-4e89-9249-faed236575e6",
      "name": "Check CNPJ Completeness",
      "type": "n8n-nodes-base.if",
      "position": [
        1248,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "925db7fb-60a5-410b-8fed-34c11afa102e",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.CNPJ }}",
              "rightValue": ""
            },
            {
              "id": "99f1300f-8cbe-42ad-bceb-686e0c999325",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.CNPJ.length }}",
              "rightValue": 14
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "87dcdb73-9023-4b88-a86a-3d31014d52e2",
      "name": "Handle Form 4",
      "type": "n8n-nodes-base.form",
      "position": [
        1712,
        448
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "redirectUrl": "={{ $('Set API URL Parameters').item.json.url }}",
        "respondWith": "redirect"
      },
      "typeVersion": 2.3
    },
    {
      "id": "cc825890-0724-4f01-8d36-c30bb7c53837",
      "name": "Handle Form 5",
      "type": "n8n-nodes-base.form",
      "position": [
        1536,
        448
      ],
      "parameters": {
        "options": {
          "formTitle": "=About the company CNPJ {{ $('When Form Submitted').item.json.CNPJ }}",
          "buttonLabel": "Finish",
          "formDescription": "=Error:Invalid format\n"
        }
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "39586ec3-f200-4251-8c37-6fc497f44136",
  "connections": {
    "Handle Form 2": {
      "main": [
        [
          {
            "node": "Handle Form 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Form 3": {
      "main": [
        [
          {
            "node": "Handle Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Form 5": {
      "main": [
        [
          {
            "node": "Handle Form 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch CNPJ Data": {
      "main": [
        [
          {
            "node": "Handle Form 2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Form 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare CNPJ Format": {
      "main": [
        [
          {
            "node": "Check CNPJ Completeness",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Form Submitted": {
      "main": [
        [
          {
            "node": "Set API URL Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API URL Parameters": {
      "main": [
        [
          {
            "node": "Prepare CNPJ Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check CNPJ Completeness": {
      "main": [
        [
          {
            "node": "Fetch CNPJ Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Form 5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow hosts an n8n form that accepts a Brazilian CNPJ, validates and normalizes the input, then queries the public Minha Receita API to fetch company registration details and displays either a formatted results page or an error page with a link back to the form. Receives…

Source: https://n8n.io/workflows/16995/ — original creator credit. Request a take-down →

More Web Scraping workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Web Scraping

This workflow allows you to import any workflow from a file or another n8n instance and map the credentials easily. A multi-form setup guides you through the entire process At the beginning you have t

Execute Command, Read Write File, HTTP Request +3
Web Scraping

LDX hub All Services Demo. Uses formTrigger, httpRequest, form, n8n-nodes-ldxhub. Event-driven trigger; 53 nodes.

Form Trigger, HTTP Request, Form +1
Web Scraping

This workflow provides a single n8n form that routes to five LDXhub services (StructFlow, RefineLoop, RenderOCR, CastDoc, and ExtractDoc) to run one-off document processing jobs and return the generat

Form Trigger, HTTP Request, Form +1
Web Scraping

N8n recently introduced folders and it has been a big improvement on workflow management on top of the tags.

HTTP Request, n8n, Form Trigger +1
Web Scraping

Git Commit. Uses github, n8n, formTrigger, httpRequest. Event-driven trigger; 34 nodes.

GitHub, n8n, Form Trigger +2