> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gu1.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Validar CSV

> Preflight: validar cabeceras del CSV contra un mapeo guardado — mediante la API de importación masiva de gu1 para alto volumen, con ejemplos para validate csv.

## Endpoint

```
POST https://api.gu1.ai/batch-import/validate-csv
```

## Descripción

**Content-Type:** `multipart/form-data`.

**Respuesta:** JSON con `ok: true/false`. HTTP **200** incluso si falla — revisar **`ok`**.

Para mapeos con **`target === user_event`**, la API también valida **cada fila de datos** tras pasar cabeceras (mapeo, enums, identificadores requeridos). Otros targets siguen validando solo cabeceras.

## Autenticación

```bash theme={null}
Authorization: Bearer TU_API_KEY
```

## Campos del formulario

| Campo       | Obligatorio | Descripción    |
| ----------- | ----------- | -------------- |
| `file`      | Sí          | CSV            |
| `mappingId` | Sí          | UUID del mapeo |

## Éxito — solo cabeceras (transaction, entity\_\*)

```json theme={null}
{
  "ok": true,
  "target": "transaction"
}
```

## Éxito — eventos de usuario (todas las filas válidas)

```json theme={null}
{
  "ok": true,
  "target": "user_event",
  "validRowCount": 42,
  "invalidRowCount": 0
}
```

## Fallo de filas — eventos de usuario

Si una o más filas fallan validación de mapeo:

```json theme={null}
{
  "ok": false,
  "code": "ROW_VALIDATION",
  "message": "Some rows failed mapping validation",
  "validRowCount": 40,
  "invalidRowCount": 2,
  "rowErrors": [
    {
      "code": "UNMAPPED_EVENT_TYPE",
      "row": 5,
      "field": "eventType",
      "value": "CIERRE_SESION_INACTIVIDAD"
    }
  ]
}
```

Usá este preflight antes de importar. Con **`batchErrorHandling: continue_collect_errors`** en [Importar eventos](/es/api-reference/bulk-imports/import-user-events), las filas inválidas se omiten y quedan en el CSV de fallos del job; con **`rollback_all`**, el import devuelve **`400`**.

Ver también: [Importaciones masivas](/es/api-reference/bulk-imports/overview).
