Disclosure: I built the Apify actor used in this workflow (cairolabs/brazil-company-due-diligence). It is pay-per-event: US$0.10 per company report, plus whatever Apify itself bills you for usage. Everything else here is standard n8n nodes, and the workflow JSON is pasted at the end of this post so you can adapt it to any other API.
What it does
You give it a list of Brazilian CNPJs (supplier, client or partner tax IDs). For each one it gets back a report built from public sources: the Receita Federal registration (status, opening date, partners, CNAE, address), the federal sanctions lists CEIS and CNEP, and optionally public contract awards from PNCP. Each report has a riskLevel of LOW, MEDIUM or HIGH. If any company comes back HIGH, you get an email listing the flags.
HIGH currently means one of: registration status is not ATIVA, or an active CEIS/CNEP sanction on that exact CNPJ. MEDIUM covers expired sanctions, sanctions on another branch with the same CNPJ root, or a company opened less than a year ago.
Manual Trigger → CNPJ list (Code) → Build actor input (Code) → HTTP Request (Apify) → IF riskLevel == HIGH → Send Email
└→ No Op
Step by step
1. Apify token. Create an Apify account and copy your API token (Settings → Integrations). In n8n, create a Header Auth credential: name Authorization, value Bearer <your token>. Using a header keeps the token out of the URL and out of execution logs.
2. The CNPJ list. The CNPJ list Code node just returns one item per CNPJ:
const cnpjs = ['33000167000101', '00000000000191'];
return cnpjs.map(cnpj => ({ json: { cnpj } }));
To use Google Sheets instead, replace it with a Google Sheets → Get row(s) node and make sure the column is called cnpj. Punctuation is fine (33.000.167/0001-01); the next node strips it.
3. One run for the whole list. Calling the actor once per row works, but each call starts a container. The Build actor input node collapses all rows into a single input:
const cnpjs = $input.all()
.map(i => String(i.json.cnpj ?? '').replace(/\D/g, ''))
.filter(c => c.length === 14);
return [{ json: { cnpjs, maxItems: cnpjs.length, includePublicContracts: true, contractsMonthsBack: 12 } }];
maxItems is the actor’s cost cap (default 100), so setting it to the list length means you never pay for more than you sent.
4. HTTP Request to Apify.
- Method:
POST - URL:
https://api.apify.com/v2/acts/cairolabs~brazil-company-due-diligence/run-sync-get-dataset-items - Authentication: Generic → Header Auth (the credential from step 1)
- Body: JSON,
{{ JSON.stringify($json) }} - Options → Timeout: 300000 ms
run-sync-get-dataset-items waits for the run and returns the dataset as a JSON array, and n8n turns each array element into its own item. Apify caps synchronous runs at 300 seconds, so for long lists either split them into batches (Loop Over Items) or switch to the async runs endpoint and fetch the dataset afterwards.
Each item looks like this (trimmed):
{
"cnpj": "33000167000101",
"cnpjFormatted": "33.000.167/0001-01",
"found": true,
"riskLevel": "LOW",
"summary": "LOW risk. PETROLEO BRASILEIRO S A PETROBRAS: ATIVA; 60.1 years old; no CEIS/CNEP sanctions; ...",
"riskFlags": [],
"company": { "legalName": "...", "status": "ATIVA", "openingDate": "1966-09-28", "partners": [ ... ] },
"sanctions": { ... },
"publicContracts": { ... },
"fetchedAt": "..."
}
Each flag in riskFlags has code, severity and message. Invalid or not-found CNPJs come back with found: false and an error field (INVALID_CNPJ_CHECK_DIGITS, NOT_FOUND, …), with no riskLevel, so they take the false branch of the IF.
5. IF node. String condition: {{ $json.riskLevel }} equals HIGH.
6. Alert. The true branch goes to Send Email (SMTP). Subject HIGH risk: {{ $json.cnpjFormatted }} {{ $json.company.legalName }}, body:
{{ $json.summary }}
Flags:
{{ $json.riskFlags.map(f => `- [${f.severity}] ${f.code}: ${f.message}`).join('\n') }}
Swap it for Slack, Gmail or Telegram if you prefer; the expressions are the same.
7. Make it recurring. Replace the Manual Trigger with a Schedule Trigger (e.g. every Monday) to re-check your active suppliers weekly.
Cost and limits
- US$0.10 per company report (only charged for CNPJs that produce a report), plus Apify platform usage.
- The data comes from public sources. It is a first screening step, not a legal opinion or a full KYC.
- The actor rate-limits itself (
maxConcurrency,delayMs) to be polite to the public APIs. Keep those low.
Workflow JSON: at the end of this post (n8n-due-diligence-workflow.json). Import it, replace the two REPLACE_ME credentials, edit the CNPJ list and the email addresses.
Questions and feedback on the flags are welcome, especially if you have a case the current rules miss.