//Use Cases

CPF and CNPJ API for E-commerce: Reducing Chargebacks and Fraud

At CPF.CNPJ, we simplify and streamline access to essential information about individuals and companies.

View packages

The Challenge: Fraud and Chargebacks in Brazilian E-commerce

Brazilian e-commerce lost R$ 3.8 billion to fraud in 2024, representing 1.42% of the sector total revenue. Identity fraud (cloned, stolen or nonexistent CPF/CNPJ) accounts for 68% of these losses, surpassing card fraud. The problem is structural: 47% of Brazilian e-commerce stores perform no CPF validation on the invoice, creating a massive vulnerability that fraudsters exploit with automated bots that test thousands of fake CPFs/CNPJs daily.

Chargebacks (purchase disputes) are the direct financial consequence: each chargeback costs the e-commerce store 2.5-3.5x the transaction value when we consider lost product, banking fees (R$ 60-120 per chargeback), dispute costs and possible banning by the acquirer when the rate exceeds 1%. Stores with a rate above 1.5% face severe penalties: an increase in MDR (acquirer fee) from 3% to 5-7%, or even blocking of receivables by the acquirer until the situation is resolved.

For B2B and marketplace sales, the problem is amplified: sales to a CNPJ represent tickets 8-15x larger (R$ 2,500-15,000 vs R$ 320 average B2C), but fraud with a cloned or deregistered CNPJ generates proportional losses. Marketplaces suffer reputational damage when fraudulent sellers register with a nonexistent CNPJ, sell counterfeit products and disappear, leaving buyers without reimbursement and the platform held liable in court. Identity validation must be instantaneous (during checkout), automated (without friction for the legitimate customer) and integrated with the NF-e issuance.

How the CPF.CNPJ API Solves It

1. Real-Time Validation at Checkout

The API allows real-time CPF/CNPJ validation during checkout, before processing payment. When the customer fills in the purchase form (cart), the frontend captures the CPF/CNPJ and makes an asynchronous call to the API that returns in 0.4-2 seconds with official validation from the Receita Federal. The system checks whether the document exists, is regular, and cross-references the declared name with the official name using a similarity algorithm (Levenshtein + phonetic metaphors).

If the CPF/CNPJ is invalid or irregular (Cancelled, Suspended, Null for CPF; Deregistered, Unfit, Suspended for CNPJ), checkout blocks the transaction instantly with a clear message: "The CPF provided is irregular. Check your data or use another CPF". This prevents 87% of fraud attempts with fake documents, which would represent guaranteed chargebacks. For legitimate customers with a name discrepancy (nicknames, abbreviations), the system offers an option to review manually before blocking.

2. Automated NF-e Issuance and Tax Compliance

Brazilian legislation (Law 12,741/2012 and SINIEF Adjustment 07/05) requires a valid CPF/CNPJ on electronic invoices. An NFe with a nonexistent CPF is rejected by SEFAZ with code 239 ("Invalid recipient CPF"), forcing the e-commerce store to reissue manually or cancel the sale, generating operational cost and customer dissatisfaction. The API prevents this problem by validating the CPF/CNPJ before issuance.

Integration with issuance systems (Bling, Omie, Tiny ERP, SAP) enables an automated flow: after the payment is approved, the system generates an NF-e pre-populated with official Receita Federal data obtained via the API. Full name, address (when available) and registration status are inserted automatically, eliminating typing errors that cause SEFAZ rejection. The NF-e rejection rate drops from 12-18% to less than 2%, accelerating billing and delivery. Savings: R$ 8-15 per reissued NF-e avoided.

3. Protection against B2B and Marketplace Fraud

For B2B sales (companies buying from an e-commerce store), CNPJ validation is critical. The API returns complete data: legal name, registration status, opening date, size (ME, EPP, large company), economic activity (CNAE), shareholding structure (when available), and special status. This data feeds a risk decision engine: CNPJs opened less than 6 months ago receive a higher risk score and may require manual approval or advance payment for the first purchase.

Marketplaces use CNPJ validation to onboard sellers: before approving a seller registration, the system validates the CNPJ against the Receita Federal and cross-references it with fraud blacklists. If the CNPJ is Deregistered (extinct company), Unfit (does not file tax returns), or appears in fraud databases, the registration is rejected automatically. This prevents fraudulent sellers that would harm the platform reputation. Periodic (monthly) validation of active sellers detects CNPJs that changed status and triggers a review.

Real Cases: KaBuM! and MelhorEnvio

KaBuM!, the largest technology e-commerce in Latin America with billions in annual GMV, faced a high chargeback rate that generated millions in losses annually. Fraud analysis revealed that 72% of chargebacks involved irregular or nonexistent CPFs on the invoice. The acquirer threatened to increase the MDR if the rate did not drop below 1% within 120 days, which would represent a significant additional cost.

Implementing real-time CPF validation via API during checkout reduced fraud attempts by 84% in the first month. The system automatically blocks nonexistent, irregular CPFs, or those with a name discrepancy above 40%. The chargeback rate dropped to 0.7% in 90 days, avoiding penalties from the acquirer. Annual savings of millions in chargeback reduction and avoided MDR penalties. ROI above 8,000% considering the investment in API queries.

MelhorEnvio, the leading logistics and shipping platform for e-commerce processing millions of orders annually, faced a problem with fraudulent sellers using irregular CNPJs: hundreds of registered sellers used a cloned or deregistered CNPJ, generated millions in irregular operations, and disappeared without reimbursing customers. The platform was sued in several cases (joint liability) with convictions totaling millions of reais.

Automatic CNPJ validation in seller registration via API blocks irregular CNPJs before activation. The implemented system automatically rejected thousands of registration attempts with an invalid CNPJ in the first months. Monthly validation of active sellers detected hundreds of CNPJs that changed to Unfit or Deregistered status, generating automatic suspension until resolution. A 91% reduction in fraud complaints on the platform. Annual savings in avoided lawsuits and reputational protection.

Expected Metrics and ROI

  • 84-91% reduction in fraud attemptsAutomatic blocking of irregular CPF/CNPJ prevents fraudulent transactions
  • 0.5-1.2pp reduction in chargebacksThe rate drops from 1.5-2% to 0.3-0.8%, avoiding MDR penalties
  • R$ 45-180 savings per chargeback avoidedConsiders product + fees + operational dispute cost
  • 88% reduction in NF-e rejectionsOfficial data eliminates typing errors that cause SEFAZ rejection
  • R$ 8-15 savings per NF-e not rejectedEliminates manual reissuance rework
  • 2-4 hours of operational savings/dayAutomation of validation and NF-e issuance frees up the team
  • ROI of 3,500-8,700%E-commerce 50k orders/month: investment R$ 900k/year vs savings R$ 31.5-78M/year
  • Marketplace reputational protectionBlocking fraudulent sellers prevents lawsuits and brand damage
CPF.CNPJ - Planos e serviços de consulta

Automate your registration system in a few steps

Exclusive discounts on postpaid plan! Request a commercial proposal now!

Conheça os pacotes