# Brazil Companies CNPJ: New Companies & B2B Leads (`allanmxr/brazil-companies-cnpj`) Actor

Brazilian companies from the Receita Federal registry (CNPJ): search by state, city, CNAE, size and status, or get companies opened in the last N days, with e-mail, phone, address, activities and partners (no CPF). Or enrich a list of CNPJs. No login or API key.

- **URL**: https://apify.com/allanmxr/brazil-companies-cnpj.md
- **Developed by:** [Allan Marcelino](https://apify.com/allanmxr) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 companies

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 Companies CNPJ: New Companies and B2B Leads from the Receita Federal

Get **Brazilian companies from the Receita Federal CNPJ registry** as clean B2B leads: search by state, city, CNAE activity, company size and registration status, or get the **companies opened in the last N days** across the whole country. Or paste a list of CNPJs and enrich it.

**Em português:** encontre **empresas brasileiras por CNPJ** com os dados abertos da Receita Federal: busca por UF, cidade, CNAE, porte, situação cadastral e **empresas abertas nos últimos dias** (lead quente), com e-mail, telefone, endereço, atividades e sócios (sem CPF). Ou consulte uma lista de CNPJs. Exemplos de busca: *empresas abertas esta semana em São Paulo*, *restaurantes novos em Barueri*, *empresas de TI (CNAE 62) abertas no último mês no Brasil*, *consulta CNPJ em lote*, *lista de empresas por CNAE e cidade*.

No login, no API key and no proxy needed.

### What you get that other CNPJ scrapers don't give you

- **New companies first.** `openedWithinDays` returns the newest companies first, nationwide or per city. A company that just opened is still choosing its accountant, bank, software and suppliers.
- **Filters applied before you pay.** City, CNAE (full code or prefix), size, MEI, head office or branch, *has e-mail* and *has phone* are all applied on our Receita index before a company is fetched. You only pay for the leads that match, never for rows you throw away.
- **Contactable leads only, if you want.** `onlyWithEmail` and `onlyWithPhone` skip companies without a usable e-mail or phone, and a company that turns out to have none is never charged.
- **No personal data, ever.** Partners come with name, role and entry date as published by the Receita, never with a CPF, not even masked. The CPF that the Receita writes into the legal name of sole proprietors is removed. MEIs and other one-person companies come without e-mail, phone and street address, because those belong to the owner.
- **No start fee.** One flat price per company delivered.
- **Honest freshness.** Every record says which monthly Receita snapshot it comes from (`dataSnapshot`), and the run log says the newest opening date in the snapshot.
- **Clean, flat output** in English with typed fields: dates as `YYYY-MM-DD`, phones as `+55...`, e-mail in lower case, share capital as a number.

### Use cases

- **Lead generation for new companies**: accountants, banks and fintechs, payment terminals, ERP and SaaS, insurance, office supplies, coworkings, marketing agencies
- **Market sizing** by CNAE and city (how many dental clinics in Campinas?)
- **CNPJ enrichment** of a CRM or spreadsheet (bulk CNPJ lookup)
- **Supplier and partner checks**: registration status, opening date, partners

### Input

| Field | Description |
|---|---|
| `mode` | `search` (default) or `lookup`. |
| `maxItems` | Maximum companies in the output (default 100), in both modes. |
| `cnpjs` | Lookup mode: CNPJs, formatted or digits only. |
| `states` | Search: states (UF). Empty with `openedWithinDays` up to 180 searches the whole country. |
| `cities` | Search: city names, accents optional. `Barueri` with one state chosen, or `São Paulo/SP`. |
| `cnaes` | Search: main activity, full 7 digit code (`6201501`, `6201-5/01`) or prefix (`62`, `5611`). |
| `openedWithinDays` | Search: companies opened in the last N days, newest first. |
| `openedFrom`, `openedTo` | Search: opening date range (instead of `openedWithinDays`). |
| `registrationStatus` | `active` (default), `suspended`, `unfit`, `closed`, `void`. |
| `companySizes` | `micro` (ME), `small` (EPP), `other`. Empty means all. |
| `mei` | `include` (default), `exclude` or `only`. |
| `establishmentType` | `all`, `headOffice` or `branch`. |
| `onlyWithEmail`, `onlyWithPhone` | Only companies with a usable e-mail / phone (never MEIs or one-person companies). |
| `includePartners` | Partners (QSA) with name, role, type and entry date. Default on. |
| `sources` | `opencnpj`, `minhareceita`, `brasilapi`, tried in this order for each CNPJ. |

#### Example: IT companies opened in the last 30 days in São Paulo state, with e-mail

```json
{
  "mode": "search",
  "states": ["SP"],
  "cnaes": ["62"],
  "openedWithinDays": 30,
  "mei": "exclude",
  "onlyWithEmail": true,
  "maxItems": 500
}
```

#### Example: enrich a list of CNPJs

```json
{
  "mode": "lookup",
  "cnpjs": ["33.000.167/0001-01", "00000000000191"]
}
```

### Output

One flat record per establishment (each branch has its own CNPJ):

```json
{
  "cnpj": "33000167000101",
  "cnpjFormatted": "33.000.167/0001-01",
  "legalName": "PETROLEO BRASILEIRO S A PETROBRAS",
  "tradeName": "PETROBRAS - EDISE",
  "status": "active",
  "statusDate": "2005-11-03",
  "statusReason": null,
  "openingDate": "1966-09-28",
  "ageDays": 21966,
  "isHeadOffice": true,
  "size": "other",
  "legalNatureCode": "2038",
  "legalNature": "Sociedade de Economia Mista",
  "mainActivityCode": "0600001",
  "mainActivity": "Extração de petróleo e gás natural",
  "secondaryActivities": [{"code": "1921700", "description": "Fabricação de produtos do refino de petróleo"}],
  "street": "AVENIDA REPUBLICA DO CHILE",
  "number": "65",
  "complement": null,
  "district": "CENTRO",
  "city": "RIO DE JANEIRO",
  "state": "RJ",
  "zipCode": "20031170",
  "fullAddress": "AVENIDA REPUBLICA DO CHILE, 65 - CENTRO - RIO DE JANEIRO/RJ - CEP 20031170",
  "phones": ["+552121660000"],
  "email": "cc-rfisc@petrobras.com.br",
  "shareCapital": 205431960490.52,
  "isSimples": null,
  "isMei": null,
  "partners": [{"name": "MAGDA MARIA DE REGINA CHAMBRIARD", "role": "Presidente", "type": "person", "since": "2024-06-07"}],
  "partnersCount": 8,
  "source": "opencnpj",
  "dataSnapshot": "2026-11",
  "fetchedAt": "2026-11-18T22:00:00+00:00"
}
```

`status`: `active`, `suspended`, `unfit` (inapta), `closed` (baixada), `void` (nula). `size`: `micro` (ME), `small` (EPP), `other`.

### Data sources and freshness

- The **search index** is built from the official [Receita Federal open data](https://arquivos.receitafederal.gov.br/) (Cadastro Nacional da Pessoa Jurídica), refreshed every month after the Receita publishes a new snapshot.
- Company details come from public APIs that serve the same registry: [OpenCNPJ](https://opencnpj.org) (with e-mail), [Minha Receita](https://minhareceita.org) and [BrasilAPI](https://brasilapi.com.br). If one is down or does not know a CNPJ, the next one is used. Only OpenCNPJ serves the e-mail.
- The Receita publishes the registry **once a month**, so the newest companies in a run are a few days to about five weeks old. A CNPJ opened after the last snapshot is not found yet.

### Pricing

Pay per company delivered (`company` event). No start fee, and CNPJs not found are not charged. Set **Max companies** or the run's maximum charge to control the cost.

### Privacy (LGPD)

The registry is public data published by the Receita Federal under the Brazilian access to information law. This Actor never outputs a CPF (partners, legal representatives, or the CPF inside a sole proprietor's legal name, masked or not), age ranges, or legal representatives.

For MEIs and other one-person companies (empresário individual, EIRELI, individual taxpayer, rural producer: legal natures 213-5, 230-5, 231-3, 401-4, 408-1, 409-0, 412-0) the registered e-mail, phone and street address are the owner's, so they are left empty: you get the company name, activity, opening date, district, city, state and ZIP code. Contact data is only delivered for companies with partners or a corporate structure. You are responsible for using the leads according to the LGPD (legitimate interest, opt-out on the first contact).

### FAQ

**Can I get every company in a state?** Yes, with `states` and no other filter, but large states have millions of establishments. Use `cnaes`, `cities` and `maxItems` to keep it focused.

**Why is a CNPJ opened yesterday missing?** The Receita has not published it yet; it will appear after the next monthly snapshot.

**Does it work for alphanumeric CNPJs?** Yes, the lookup validates the new alphanumeric format as well.

# Actor input Schema

## `mode` (type: `string`):

Search finds companies by state, city, CNAE, size, status and opening date (new companies are the hottest leads). Lookup enriches a list of CNPJs you already have.

## `maxItems` (type: `integer`):

Maximum number of companies in the output, in both modes (a longer CNPJ list is cut here). You only pay for companies delivered.

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

CNPJs to look up, formatted or digits only (33.000.167/0001-01 or 33000167000101). Duplicates are removed. Used only in lookup mode.

## `states` (type: `array`):

States to search. With cities, choose exactly one state or write the state after each city. Empty with a recent opening window (openedWithinDays up to 180) searches the whole country.

## `cities` (type: `array`):

City names as in the Receita registry, accents optional: "Barueri", "São Paulo/SP", "Rio de Janeiro/RJ". Empty means every city of the chosen states.

## `cnaes` (type: `array`):

Main activity of the company: a full 7 digit CNAE (6201501 or 6201-5/01) or a prefix of 2 to 6 digits (62 = IT services, 5611 = restaurants). Empty means every activity.

## `openedWithinDays` (type: `integer`):

Only companies opened in the last N days, newest first. Up to 180 days it also works nationwide. Note: the Receita publishes its registry once a month, so the newest companies are a few days to about 5 weeks old.

## `openedFrom` (type: `string`):

Opening date range start (use instead of openedWithinDays).

## `openedTo` (type: `string`):

Opening date range end.

## `registrationStatus` (type: `array`):

Situação cadastral at the Receita. Active is what you want for leads.

## `companySizes` (type: `array`):

Empty means every size.

## `mei` (type: `string`):

MEIs are about half of the new CNPJs. Their e-mail, phone and street address belong to the owner and are left empty (LGPD). Exclude them to get companies with partners and bigger budgets.

## `establishmentType` (type: `string`):

Each branch has its own CNPJ and address.

## `onlyWithEmail` (type: `boolean`):

Skip companies without an e-mail you can use. Applied on the index before fetching, so you only pay for contactable leads. MEIs and other one-person companies never count: their contact belongs to the owner (LGPD).

## `onlyWithPhone` (type: `boolean`):

Skip companies without a phone you can use. MEIs and other one-person companies never count (LGPD).

## `includePartners` (type: `boolean`):

Partner names and roles as published by the Receita. CPFs are never included, not even masked.

## `sources` (type: `array`):

Public APIs that serve the Receita Federal registry, tried in this order for every CNPJ. A source that blocks or does not know a CNPJ hands it to the next one. Keep all three for the best coverage.

## `proxyConfiguration` (type: `object`):

Leave empty: the Actor connects directly and only falls back to Apify datacenter proxy when a source blocks it.

## Actor input object example

```json
{
  "mode": "search",
  "maxItems": 50,
  "cnpjs": [
    "33.000.167/0001-01",
    "00000000000191"
  ],
  "states": [
    "SP"
  ],
  "cities": [
    "Barueri"
  ],
  "openedWithinDays": 60,
  "registrationStatus": [
    "active"
  ],
  "mei": "exclude",
  "establishmentType": "all",
  "onlyWithEmail": false,
  "onlyWithPhone": false,
  "includePartners": true,
  "sources": [
    "opencnpj",
    "minhareceita",
    "brasilapi"
  ]
}
```

# Actor output Schema

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

All companies in the default dataset.

# 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 = {
    "mode": "search",
    "maxItems": 50,
    "cnpjs": [
        "33.000.167/0001-01",
        "00000000000191"
    ],
    "states": [
        "SP"
    ],
    "cities": [
        "Barueri"
    ],
    "openedWithinDays": 60,
    "mei": "exclude"
};

// Run the Actor and wait for it to finish
const run = await client.actor("allanmxr/brazil-companies-cnpj").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 = {
    "mode": "search",
    "maxItems": 50,
    "cnpjs": [
        "33.000.167/0001-01",
        "00000000000191",
    ],
    "states": ["SP"],
    "cities": ["Barueri"],
    "openedWithinDays": 60,
    "mei": "exclude",
}

# Run the Actor and wait for it to finish
run = client.actor("allanmxr/brazil-companies-cnpj").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 '{
  "mode": "search",
  "maxItems": 50,
  "cnpjs": [
    "33.000.167/0001-01",
    "00000000000191"
  ],
  "states": [
    "SP"
  ],
  "cities": [
    "Barueri"
  ],
  "openedWithinDays": 60,
  "mei": "exclude"
}' |
apify call allanmxr/brazil-companies-cnpj --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,allanmxr/brazil-companies-cnpj"
        }
    }
}
```

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/OhguzpvSZFE4lSH7E/builds/wyU2fQSf8OtLWVf4h/openapi.json
