# LatAm Tax ID Validator & CFDI Parser (`autoaugeo/latam-tax-id-validator-2766`) Actor

Checks format and check digits of Latin American tax IDs (CUIT, RUT, RFC, CURP, CPF, CNPJ, NIT, RUC) and parses CFDI invoice XML into JSON. Format and check digits only: it does not confirm an ID is registered or active. Independent of any tax authority. AI-assisted.

- **URL**: https://apify.com/autoaugeo/latam-tax-id-validator-2766.md
- **Developed by:** [Augeo auto](https://apify.com/autoaugeo) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

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

## LatAm Tax ID Validator + CFDI Parser

[English](#english) | [Español](#español)

### English

#### What it does

Validates Latin American tax IDs offline and parses the header of Mexican CFDI 3.3 / 4.0 invoices. Each input item produces exactly one dataset row, and each row is one billable `result` event. A bad item never crashes the run: it returns a row with `valid: false` and a `reason`.

It runs pure computation: no website is read and no network request is made.

#### Important limits (please read)

- **Format and check digits only.** The Actor does not confirm that an ID is registered or active with any tax authority, and it is not tax, legal or accounting advice.
- For CFDI, it extracts fields and checks the RFC check digits. It does **not** verify the SAT seal or certificate and does not query SAT, so a parsed CFDI is not proof that the invoice is valid or stamped.

#### Supported IDs

| Country | `country` | Types | What is checked |
|---|---|---|---|
| Argentina | `AR` | `cuit`, `cuil` | 11 digits, type prefix (20, 23, 24, 27, 30, 33, 34), mod-11 check digit |
| Chile | `CL` | `rut` | 6-8 digit body, mod-11 check digit (0-9 or K) |
| Mexico | `MX` | `rfc`, `curp` | RFC 12/13 characters, date part, check character; CURP 18 characters, date, sex, state code, check digit |
| Brazil | `BR` | `cpf`, `cnpj` | CPF 11 digits with two check digits; CNPJ 14 characters (numeric and alphanumeric) with two check digits |
| Colombia | `CO` | `nit` | digits plus DIAN check digit |
| Peru | `PE` | `ruc` | 11 digits, prefix (10, 15, 17, 20), check digit |

With `type: "auto"` (the default) the type is detected from the country and the length of the value. Dots, hyphens, slashes and spaces are ignored.

#### Input

```json
{
  "ids": [
    {"country": "AR", "type": "auto", "value": "20-12345678-6"},
    {"country": "BR", "type": "auto", "value": "529.982.247-25"},
    {"country": "AR", "type": "cuit", "value": "20-12345678-0"}
  ],
  "cfdi_xml": []
}
```

- `ids`: array of `{country, type, value}`.
- `cfdi_xml`: optional array of CFDI XML strings.
- Up to 10,000 items per run (IDs and CFDIs together); extra items are ignored and the log says so.

The prefilled example uses only synthetic IDs made for testing.

#### Output

One row per input item. Example for an ID:

```json
{
  "kind": "id",
  "index": 2,
  "input": "20-12345678-0",
  "country": "AR",
  "type": "cuit",
  "normalized": "20123456780",
  "valid": false,
  "reason": "check digit mismatch",
  "check_digit_expected": "6",
  "check_digit_found": "0",
  "flags": []
}
```

CFDI rows have `kind: "cfdi"`, `valid`, `reason` (when invalid), `version`, `serie`, `folio`, `fecha`, `subtotal`, `total`, `moneda`, `tipo_de_comprobante`, `emisor`, `receptor` (each with an RFC check), `uuid`, `fecha_timbrado`, `concept_count`, `warnings` and `seal_verified: false`.

#### Pricing

Pay per result: one `result` event is charged for each item pushed to the dataset, valid or not. The current price per result is the one shown on this Actor's Store page.

#### Privacy

The author does not store the inputs. Run data (input, dataset) is kept by Apify under its own run-data retention rules; see Apify's documentation and your account settings.

#### Disclosures

- Independent tool, not affiliated with SAT, AFIP/ARCA, SII, Receita Federal, DIAN, SUNAT or Mercado Pago. Those names are used only to describe what the tool does.
- This Actor and its README are AI-assisted.

### Español

#### Qué hace

Valida identificadores fiscales de Latinoamérica sin conexión y lee el encabezado de facturas CFDI 3.3 / 4.0 de México. Cada ítem de entrada genera exactamente una fila en el dataset, y cada fila es un evento `result` cobrado. Un ítem inválido no rompe la ejecución: devuelve una fila con `valid: false` y un `reason`.

Es cálculo puro: no se lee ningún sitio web ni se hace ninguna conexión de red.

#### Límites importantes

- **Solo formato y dígitos verificadores.** El Actor no confirma que un ID esté registrado ni activo ante ninguna autoridad fiscal, y no es asesoramiento fiscal, legal ni contable.
- En CFDI extrae campos y verifica los dígitos del RFC. **No** verifica el sello ni el certificado del SAT ni consulta al SAT, así que un CFDI leído no prueba que la factura sea válida ni esté timbrada.

#### IDs soportados

| País | `country` | Tipos | Qué se verifica |
|---|---|---|---|
| Argentina | `AR` | `cuit`, `cuil` | 11 dígitos, prefijo (20, 23, 24, 27, 30, 33, 34), dígito verificador módulo 11 |
| Chile | `CL` | `rut` | cuerpo de 6 a 8 dígitos, dígito verificador módulo 11 (0-9 o K) |
| México | `MX` | `rfc`, `curp` | RFC de 12/13 caracteres, fecha, carácter verificador; CURP de 18 caracteres, fecha, sexo, estado, dígito verificador |
| Brasil | `BR` | `cpf`, `cnpj` | CPF de 11 dígitos con dos verificadores; CNPJ de 14 caracteres (numérico y alfanumérico) con dos verificadores |
| Colombia | `CO` | `nit` | dígitos más dígito verificador de la DIAN |
| Perú | `PE` | `ruc` | 11 dígitos, prefijo (10, 15, 17, 20), dígito verificador |

Con `type: "auto"` (por defecto) el tipo se detecta por el país y el largo del valor. Se ignoran puntos, guiones, barras y espacios.

#### Entrada

```json
{
  "ids": [
    {"country": "AR", "type": "auto", "value": "20-12345678-6"},
    {"country": "BR", "type": "auto", "value": "529.982.247-25"},
    {"country": "AR", "type": "cuit", "value": "20-12345678-0"}
  ],
  "cfdi_xml": []
}
```

- `ids`: lista de `{country, type, value}`.
- `cfdi_xml`: lista opcional de XML CFDI como texto.
- Hasta 10.000 ítems por ejecución (IDs y CFDI en conjunto); los sobrantes se ignoran y el log lo indica.

El ejemplo precargado usa solo IDs sintéticos hechos para pruebas.

#### Salida

Una fila por ítem. Las filas de ID traen `kind`, `index`, `input`, `country`, `type`, `normalized`, `valid`, `reason`, `check_digit_expected`, `check_digit_found` y `flags`. Las filas CFDI traen `kind: "cfdi"`, `valid`, `reason` (si es inválido), `version`, `serie`, `folio`, `fecha`, `subtotal`, `total`, `moneda`, `tipo_de_comprobante`, `emisor`, `receptor` (cada uno con su verificación de RFC), `uuid`, `fecha_timbrado`, `concept_count`, `warnings` y `seal_verified: false`.

#### Precio

Pago por resultado: se cobra un evento `result` por cada ítem enviado al dataset, sea válido o no. El precio vigente por resultado es el que figura en la página de este Actor en la Store.

#### Privacidad

El autor no almacena las entradas. Los datos de la ejecución (entrada, dataset) los conserva Apify según su propia política de retención; consultá su documentación y la configuración de tu cuenta.

#### Avisos

- Herramienta independiente, sin afiliación con SAT, AFIP/ARCA, SII, Receita Federal, DIAN, SUNAT ni Mercado Pago. Esos nombres se usan solo para describir lo que hace la herramienta.
- Este Actor y su README fueron elaborados con asistencia de IA.

# Actor input Schema

## `ids` (type: `array`):

List of objects {country, type, value}. country: AR, CL, MX, BR, CO or PE. type: auto (default), cuit, cuil, rut, rfc, curp, cpf, cnpj, nit or ruc. value: the ID, with or without dots, hyphens or spaces. Up to 10,000 items per run (IDs and CFDIs together).

## `cfdi_xml` (type: `array`):

List of CFDI 3.3 / 4.0 XML documents, each one as a string. The header, issuer, receiver and stamp data are extracted and both RFCs are checked. The SAT seal is NOT verified.

## Actor input object example

```json
{
  "ids": [
    {
      "country": "AR",
      "type": "auto",
      "value": "20-12345678-6"
    },
    {
      "country": "CL",
      "type": "auto",
      "value": "12.345.678-5"
    },
    {
      "country": "MX",
      "type": "rfc",
      "value": "XAXX010101000"
    },
    {
      "country": "BR",
      "type": "auto",
      "value": "529.982.247-25"
    },
    {
      "country": "BR",
      "type": "auto",
      "value": "11.222.333/0001-81"
    },
    {
      "country": "CO",
      "type": "nit",
      "value": "1234567896"
    },
    {
      "country": "PE",
      "type": "ruc",
      "value": "20123456786"
    },
    {
      "country": "AR",
      "type": "cuit",
      "value": "20-12345678-0"
    }
  ],
  "cfdi_xml": []
}
```

# Actor output Schema

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

No description

# 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 = {
    "ids": [
        {
            "country": "AR",
            "type": "auto",
            "value": "20-12345678-6"
        },
        {
            "country": "CL",
            "type": "auto",
            "value": "12.345.678-5"
        },
        {
            "country": "MX",
            "type": "rfc",
            "value": "XAXX010101000"
        },
        {
            "country": "BR",
            "type": "auto",
            "value": "529.982.247-25"
        },
        {
            "country": "BR",
            "type": "auto",
            "value": "11.222.333/0001-81"
        },
        {
            "country": "CO",
            "type": "nit",
            "value": "1234567896"
        },
        {
            "country": "PE",
            "type": "ruc",
            "value": "20123456786"
        },
        {
            "country": "AR",
            "type": "cuit",
            "value": "20-12345678-0"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("autoaugeo/latam-tax-id-validator-2766").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 = { "ids": [
        {
            "country": "AR",
            "type": "auto",
            "value": "20-12345678-6",
        },
        {
            "country": "CL",
            "type": "auto",
            "value": "12.345.678-5",
        },
        {
            "country": "MX",
            "type": "rfc",
            "value": "XAXX010101000",
        },
        {
            "country": "BR",
            "type": "auto",
            "value": "529.982.247-25",
        },
        {
            "country": "BR",
            "type": "auto",
            "value": "11.222.333/0001-81",
        },
        {
            "country": "CO",
            "type": "nit",
            "value": "1234567896",
        },
        {
            "country": "PE",
            "type": "ruc",
            "value": "20123456786",
        },
        {
            "country": "AR",
            "type": "cuit",
            "value": "20-12345678-0",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("autoaugeo/latam-tax-id-validator-2766").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 '{
  "ids": [
    {
      "country": "AR",
      "type": "auto",
      "value": "20-12345678-6"
    },
    {
      "country": "CL",
      "type": "auto",
      "value": "12.345.678-5"
    },
    {
      "country": "MX",
      "type": "rfc",
      "value": "XAXX010101000"
    },
    {
      "country": "BR",
      "type": "auto",
      "value": "529.982.247-25"
    },
    {
      "country": "BR",
      "type": "auto",
      "value": "11.222.333/0001-81"
    },
    {
      "country": "CO",
      "type": "nit",
      "value": "1234567896"
    },
    {
      "country": "PE",
      "type": "ruc",
      "value": "20123456786"
    },
    {
      "country": "AR",
      "type": "cuit",
      "value": "20-12345678-0"
    }
  ]
}' |
apify call autoaugeo/latam-tax-id-validator-2766 --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,autoaugeo/latam-tax-id-validator-2766"
        }
    }
}
```

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/olmgipUIeYVefwKnA/builds/Fj9A4blFGObGCcI0r/openapi.json
