# Brazil CNPJ Situação Change Monitor (honest monthly lag) (`plym-actor-factory/brazil-cnpj-situacao-change-monitor`) Actor

Watch a list of Brazilian CNPJs and emit typed situação cadastral / material change events from Receita Federal dados abertos (or equivalent open-data mirror). Honest monthly official lag — not a CNPJ dump, not paid Serasa.

- **URL**: https://apify.com/plym-actor-factory/brazil-cnpj-situacao-change-monitor.md
- **Developed by:** [Daniel Witney](https://apify.com/plym-actor-factory) (community)
- **Categories:** Automation, AI, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 situação change delivereds

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 CNPJ Situação Change Monitor (honest monthly lag)

Watch a **list of Brazilian CNPJs** (suppliers, merchants, customers) and receive **typed situação cadastral / material change events** when official Receita Federal **dados abertos** (or an equivalent open-data mirror of the same dump) shows Ativa → Baixada / Inapta / Suspensa / Nula — or optional CNAE / endereço flips. **Not** another bulk CNPJ enrichment dump. **Not** paid Serasa / Serpro.

**Honest title:** official RFB refresh is **monthly**. Detection latency ≈ your schedule + RFB publish lag. This is **not** intra-day Serasa Monitora.

### Value proposition

- **Watchlist × snapshot diff** → `SITUACAO_ATIVA`, `SITUACAO_BAIXADA`, `SITUACAO_INAPTA`, `SITUACAO_SUSPENSA`, `SITUACAO_NULA`, optional `CNAE_CHANGED` / `ENDERECO_CHANGED`.
- Official / public open data only (RFB dados abertos CC-BY layout; live path uses a public open-data–derived per-CNPJ lookup with the **same monthly lag**). **No paid Serasa / Serpro API.**
- **Pay only for unique delivered change events.** First observation stores a baseline (no charge). Quiet months ≈ $0.
- Durable KVS checkpoint + `event_uid` dedupe. Events carry `as_of` for honest open-data dating.

### PRODUCTION USE (required for real monitoring)

> **Store default ≠ product.** Schema defaults use `sourceMode=fixture` so Apify Store daily auto-tests leave a non-empty health dataset **without** calling open-data mirrors. That fixture path only writes a non-billable `RUN_STATUS` / `FIXTURE_HEALTH` row. It is **not** CNPJ monitoring.

For **production monitoring** you **must**:

1. Set **`sourceMode` = `live`**
2. Provide your `cnpjNumbers` watchlist
3. Schedule runs **after** each monthly RFB publish (or weekly catch-up) with fair-use `requestPaceMs`
4. Optionally set `rfbOpenDataMonth` (YYYY-MM) so events / `RUN_STATUS` document the dump you are aligning to

Official references:

- [Cadastro Nacional da Pessoa Jurídica — CNPJ (dados.gov.br)](https://dados.gov.br/dados/conjuntos-dados/cadastro-nacional-da-pessoa-juridica---cnpj) (CC-BY, monthly)
- [RFB CNPJ metadados / layout PDF](https://www.gov.br/receitafederal/dados/cnpj-metadados.pdf)
- RFB open-data file host: `arquivos.receitafederal.gov.br` (Estabelecimentos\*.zip)

### Data limitations (read before buying)

- **Monthly lag (honest).** RFB dados abertos are published about **once a month**. This Actor does **not** claim same-day Serasa-class alerts.
- Live lookups use a **public open-data–derived** HTTP API that mirrors the RFB dump (not paid Serpro Consulta CNPJ). Mirror freshness tracks the monthly dump — document `as_of` / `rfbOpenDataMonth`.
- **First run** stores baselines only — you will not be charged for “current state” snapshots.
- Invalid CNPJs (check digits) are skipped with no charge.
- Fair-use pacing applies; large books need longer `maxRunSeconds` or chunked runs.
- We cite Receita Federal / dados.gov.br as the data origin. This Actor is not affiliated with or endorsed by RFB.

### Apify Store daily auto-test / default input

| Field | Default |
|-------|---------|
| `cnpjNumbers` | `["00000000000191","60746948000112"]` |
| `signalGroups` | `situacao`, `cnae`, `endereco` |
| `sourceMode` | `fixture` |
| `emitFixtureDemoEvents` | `false` |
| `maxRunSeconds` | `55` |
| `maxEvents` | `500` |

On that path the Actor **SUCCEEDS** quickly, pushes exactly one `RUN_STATUS` / `FIXTURE_HEALTH` row (`billable: false`), and does **not** charge `situacao-change-delivered`.

### Input (summary)

| Field | Notes |
|-------|--------|
| `cnpjNumbers` | Watchlist (required) |
| `signalGroups` | `situacao`, `cnae`, `endereco` |
| `sourceMode` | `fixture` (default) or `live` |
| `emitFixtureDemoEvents` | Default **false** |
| `rfbOpenDataMonth` | Optional YYYY-MM `as_of` hint |
| `maxRunSeconds` / `maxEvents` | Budgets |
| `resumeFromCheckpoint` | Default true |
| `requestPaceMs` | Fair-use delay (default 400) |

#### Production example

```json
{
  "cnpjNumbers": ["00000000000191", "60746948000112"],
  "signalGroups": ["situacao", "cnae", "endereco"],
  "sourceMode": "live",
  "rfbOpenDataMonth": "2026-08",
  "maxRunSeconds": 120,
  "requestPaceMs": 400,
  "resumeFromCheckpoint": true
}
```

### Output

#### Change events (billable under PPE)

Typed rows include: `cnpj`, `razao_social`, `event_type`, `event_subtype`, `changed_fields`, `previous_value`, `new_value`, `effective_date`, `as_of`, `evidence`, `summary`, `source_url`, `event_uid`, `billable: true`.

#### RUN\_STATUS (never billed)

Every successful run pushes one health row (`FIXTURE_HEALTH` | `MONITOR_IDLE` | `CATCHUP_COMPLETE` | `HEALTH_OK`) including `as_of` when known.

### Pricing

Pay-per-event: **`situacao-change-delivered`** at **$0.02** per delivered unique change event ($20 / 1,000). Single tier (see `docs/monetization.md` and ADR 0010). Health / baseline / duplicate / fixture rows are never charged.

### Local development

```bash
cd actors/brazil-cnpj-situacao-change-monitor
npm install
npm test
npm run build
## Store-safe fixture health:
apify run -p
## Demo typed events locally:
## set input emitFixtureDemoEvents=true (still sourceMode=fixture)
```

### Attribution

Data originates from the **Receita Federal do Brasil (RFB)** CNPJ dados abertos (CC-BY) / dados.gov.br. Live path may use a public open-data–derived mirror of that dump. Not an official RFB product. Not Serasa Experian.

# Actor input Schema

## `cnpjNumbers` (type: `array`):

Brazilian CNPJs to monitor (14 digits; punctuation optional). Invalid entries are skipped with no charge.

## `signalGroups` (type: `array`):

Which change groups to evaluate: situacao, cnae, endereco. Default: all.

## `maxRunSeconds` (type: `integer`):

Wall-clock budget for this scheduled poll.

## `maxEvents` (type: `integer`):

Stop after this many unique change events are delivered (does not include RUN\_STATUS).

## `resumeFromCheckpoint` (type: `boolean`):

If true, resume CNPJ snapshots and seen event\_uids from the default Key-Value Store.

## `sourceMode` (type: `string`):

fixture = local/CI / Apify Store daily auto-test default (no network; emits RUN\_STATUS only unless emitFixtureDemoEvents=true). live = public RFB open-data–derived per-CNPJ lookup (honest monthly lag; not paid Serpro/Serasa).

## `emitFixtureDemoEvents` (type: `boolean`):

When sourceMode=fixture, if true push fabricated change events from local fixtures (unit/local demos only). Default false so Store daily auto-tests never emit fake change events or charge situacao-change-delivered. Production: leave false and use sourceMode=live.

## `rfbOpenDataMonth` (type: `string`):

Optional YYYY-MM label for the official RFB monthly dump this run is aligned to (documented on events / RUN\_STATUS). Does not download multi-GB ZIPs.

## `maxTotalChargeUsd` (type: `number`):

Optional soft budget hint for delivered change events. Platform ACTOR\_MAX\_TOTAL\_CHARGE\_USD also applies when set.

## `requestPaceMs` (type: `integer`):

Minimum delay between outbound public HTTP requests (fair-use pacing).

## Actor input object example

```json
{
  "cnpjNumbers": [
    "00000000000191",
    "60746948000112"
  ],
  "signalGroups": [
    "situacao",
    "cnae",
    "endereco"
  ],
  "maxRunSeconds": 55,
  "maxEvents": 500,
  "resumeFromCheckpoint": true,
  "sourceMode": "fixture",
  "emitFixtureDemoEvents": false,
  "requestPaceMs": 400
}
```

# Actor output Schema

## `OUTPUT` (type: `string`):

JSON summary: delivered, charged, runStatus, checkpoint, stats, as\_of / honest monthly lag

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("plym-actor-factory/brazil-cnpj-situacao-change-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("plym-actor-factory/brazil-cnpj-situacao-change-monitor").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 '{}' |
apify call plym-actor-factory/brazil-cnpj-situacao-change-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plym-actor-factory/brazil-cnpj-situacao-change-monitor"
        }
    }
}
```

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/oSCiZUOpUllZAnADv/builds/aIiGbvSJ89xqYdz8T/openapi.json
