# Brazil B2B CNPJ, Partners (QSA) & CNAE Lead Enricher (`b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher`) Actor

Mathematical Modulo 11 validator and batch B2B company lead enricher for Brazilian CNPJs via BrasilAPI and OpenCNPJA. Extracts Razao Social, Nome Fantasia, Situacao Cadastral, CNAEs, Capital Social, Simples Nacional/MEI status, partners (QSA), and contact details.

- **URL**: https://apify.com/b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher.md
- **Developed by:** [Jesley Tassili de Oliveira Aguileira](https://apify.com/b2b-quant-apis) (community)
- **Categories:** AI, Lead generation, Business
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$15.00 / 1,000 brazilian cnpj & partners (qsa) lead enricheds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Brazil B2B CNPJ Company, Partners (QSA), CNAE & Simples Lead Enricher

**Batch Brazilian CNPJ Validator (Modulo 11) and B2B Corporate Lead Enricher.** Extracts official Receita Federal company registration data, Quadro de Sócios e Administradores (QSA / Partners & Directors), Primary and Secondary CNAEs, Share Capital (Capital Social), Simples Nacional / MEI tax status, and public contact information via **BrasilAPI** with automatic high-availability fallback to **OpenCNPJA**.

***

### Key Features (EN)

- **Zero-Cost Mathematical Modulo 11 Pre-Validation:** Calculates both CNPJ check digits using official Receita Federal weights (`[5,4,3,2,9,8,7,6,5,4,3,2]` and `[6,5,4,3,2,9,8,7,6,5,4,3,2]`) and rejects repeated-digit sequences (`11.111.111/1111-11`) before spending network bandwidth.
- **Dual-Provider Redundancy:** Queries `https://brasilapi.com.br/api/cnpj/v1/{cnpj}` as primary source and seamlessly fails over to `https://open.cnpja.com/office/{cnpj}` if rate-limited or unavailable.
- **Full Corporate Hierarchy (QSA):** Extracts partner names, qualification roles, entry dates, age brackets, and masked tax IDs (`sociosCount` + `qsa` array).
- **Tax & Sector Classification:** Captures Primary CNAE (`cnaePrincipalCodigo`, `cnaePrincipalDescricao`), Secondary CNAEs (`cnaesSecundarios`), `opcaoPeloSimples`, `opcaoPeloMei`, and `capitalSocialBRL`.
- **LLM & MCP Ready (`markdownCompanyDossier`):** Generates a clean Markdown corporate intelligence report for each CNPJ, ready for AI agents, RAG pipelines, and CRM enrichment.

***

### Recursos Principais (PT-BR)

- **Validação Matemática Módulo 11 Nativa:** Calcula de forma determinística os 2 dígitos verificadores do CNPJ e bloqueia sequências repetidas (`00.000.000/0000-00` a `99.999.999/9999-99`) antes de efetuar requisições de rede.
- **Alta Disponibilidade (BrasilAPI + OpenCNPJA):** Consulta primária na BrasilAPI com fallback imediato para OpenCNPJA, garantindo enriquecimento B2B contínuo sem necessidade de chaves pagas.
- **Quadro Societário Completo (QSA):** Mapeia todos os sócios e administradores, cargos/qualificações, faixas etárias e datas de entrada na sociedade.
- **Enquadramento Tributário e CNAE:** Identifica opção pelo Simples Nacional, MEI, Porte da Empresa, Natureza Jurídica, Capital Social em Reais (BRL) e atividades econômicas (CNAE Fiscal principal e secundários).
- **Dossiê Corporativo em Markdown (`markdownCompanyDossier`):** Entrega um relatório estruturado pronto para consumo por agentes de IA (MCP Server), automações de vendas B2B, KYC/Compliance e CRMs (HubSpot, Pipedrive, Salesforce).

***

### Input Parameters

| Field | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `cnpjs` | `array` (stringList) | `["00.000.000/0001-91", "33.000.167/0001-01"]` | List of Brazilian CNPJ numbers (formatted or raw digits) to validate and enrich. |
| `includeSecondaryCnaes` | `boolean` | `true` | Include all secondary economic activities (`cnaesSecundarios`) in the dataset and dossier. |
| `timeoutSeconds` | `integer` | `15` | HTTP timeout in seconds per API request (3 to 60s). |
| `maxResults` | `integer` | `100` | Maximum number of CNPJs to process in a single run. |

***

### Output Example

```json
{
  "cnpj": "00000000000191",
  "cnpjFormatted": "00.000.000/0001-91",
  "isValidMod11": true,
  "status": "ENRICHED",
  "dataSource": "BrasilAPI",
  "razaoSocial": "BANCO DO BRASIL SA",
  "nomeFantasia": "DIRECAO GERAL",
  "situacaoCadastral": "ATIVA",
  "cnaePrincipalCodigo": "6421200",
  "cnaePrincipalDescricao": "Bancos comerciais",
  "capitalSocialBRL": 120000000000.0,
  "opcaoPeloSimples": false,
  "opcaoPeloMei": false,
  "uf": "DF",
  "municipio": "BRASILIA",
  "sociosCount": 10,
  "qsa": [
    {
      "nomeSocio": "TARCIANA PAULA GOMES MEDEIROS",
      "qualificacaoSocio": "Presidente",
      "faixaEtaria": "41 a 50 anos",
      "dataEntradaSociedade": "2023-01-16",
      "identificadorDeSocio": "2",
      "cnpjCpfDoSocio": "***456789**"
    }
  ],
  "markdownCompanyDossier": "# Dossiê Corporativo B2B — BANCO DO BRASIL SA (00.000.000/0001-91)..."
}
```

# Actor input Schema

## `cnpjs` (type: `array`):

List of Brazilian CNPJ numbers to validate and enrich.

## `includeSecondaryCnaes` (type: `boolean`):

Include all secondary economic activities (CNAEs Secundários) in the output record and markdown dossier.

## `timeoutSeconds` (type: `integer`):

HTTP timeout in seconds for each API request to BrasilAPI and OpenCNPJA.

## `maxResults` (type: `integer`):

Maximum number of CNPJ records to process in a single execution.

## Actor input object example

```json
{
  "cnpjs": [
    "00.000.000/0001-91",
    "33.000.167/0001-01"
  ],
  "includeSecondaryCnaes": true,
  "timeoutSeconds": 15,
  "maxResults": 100
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "cnpjs": [
        "00.000.000/0001-91",
        "33.000.167/0001-01"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "cnpjs": [
        "00.000.000/0001-91",
        "33.000.167/0001-01",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "cnpjs": [
    "00.000.000/0001-91",
    "33.000.167/0001-01"
  ]
}' |
apify call b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b-quant-apis/brazil-b2b-cnpj-qsa-lead-enricher"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Kr5QgLYu0nZO7Aeh4/builds/7UAWfJZdk1BzRQ8Ba/openapi.json
