Brazilian Federal Revenue API to query CPF and CNPJ in real time
At CPF.CNPJ, we simplify and streamline access to essential information about individuals and companies.
The challenge: accessing Federal Revenue data directly and legally
Brazil's Federal Revenue (Receita Federal) maintains the official CPF and CNPJ databases, but it does not provide a unified public query API for system integration. The common alternatives — web forms with captcha, data scraping and portals with usage limits — are fragile, unstable and legally risky for operations that need to validate documents at scale.
Companies running KYC (Know Your Customer), KYB (Know Your Business) and compliance processes need reliable data at the source: CPF registration status, CNPJ status, ownership structure (QSA) and CNAE codes. When this data comes from stale copies or scraping subject to blocks, the result is stalled onboarding, false positives and regulatory exposure.
CPF.CNPJ solves this by offering an API layer that delivers official Federal Revenue CPF and CNPJ data programmatically, in real time (D+0), with no captcha and no scraping. A single REST integration covers both individuals and companies, with the reliability required by onboarding, credit and anti-fraud flows.
How the CPF.CNPJ API solves it
1. CPF and CNPJ in a single API
One integration covers both documents. For CPF, the API returns the registration status (Regular, Suspended, Cancelled, Pending Regularization, Null, Cancelled for Multiplicity or Deceased Holder) and the official name linked to the document.
For CNPJ, the API delivers registration status (Active, Closed, Unfit, Suspended, Null), corporate name, trade name, opening date, company size, primary and secondary CNAE codes, address and the ownership and management structure (QSA). All sourced from the official Federal Revenue base.
2. REST and JSON, easy to integrate
The API is RESTful and responds in JSON, with no proprietary SDK dependency. Any language capable of making an HTTP request can consume the data, cutting integration time to minutes for backend flows, ETLs and batch jobs.
The response structure is stable and documented, letting you map fields directly into your KYC/KYB decision engine without fragile HTML parsing.
3. Token authentication and real-time data (D+0)
Authentication is token-based, with no captcha, digital certificate or date of birth required. The token identifies the application and the contracted package on each request.
Queries reflect the current state of the Federal Revenue databases (D+0), ensuring that onboarding, credit and compliance decisions use the most recent registration status available at the official source.
4. LGPD compliance
Data access is structured for legitimate use in fraud prevention, registration validation and fulfillment of legal obligations, with processing aligned to Brazil's LGPD (Law 13.709/2018).
This lets financial institutions, fintechs, marketplaces and regulated companies validate CPF and CNPJ at the official source without resorting to scraping or informal databases of dubious origin.
How to integrate
Integration is a single REST call authenticated by token. The example below queries a CPF and a CNPJ against the official Federal Revenue base and returns the registration status in JSON:
# CPF query against Federal Revenue
curl -X GET "https://api.cpfcnpj.com.br/YOUR_TOKEN/9/00000000000"
# CNPJ query (status, QSA, CNAE) against Federal Revenue
curl -X GET "https://api.cpfcnpj.com.br/YOUR_TOKEN/6/00000000000000"
# Response (simplified example)
# {
# "status": 1,
# "document": "00000000000000",
# "registration_status": "ACTIVE",
# "company_name": "EXAMPLE COMPANY LTDA",
# "opening_date": "2015-03-10",
# "main_cnae": "62.01-5-01",
# "qsa": [ { "name": "EXAMPLE PARTNER", "role": "Managing Partner" } ]
# }For endpoint details, query packages, status codes and examples in other languages, see the full documentation at https://www.cpfcnpj.com.br/dev/.
Why use the CPF.CNPJ API
- Official source: Data pulled directly from the Federal Revenue CPF and CNPJ databases.
- D+0 real time: Registration status updated to reflect the current state of the official source.
- 99.9% uptime: Availability designed for critical onboarding and compliance flows.
- CPF and CNPJ in one API: A single REST integration covers both individuals and companies.
