> ## 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.

# Validate CSV

> Preflight: validate CSV headers against a saved mapping — via the gu1 batch import API for high-volume data loading, with examples for validate csv use cases.

## Endpoint

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

## Overview

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

**Response:** JSON with `ok: true` or `ok: false` plus error details (`missingCsvColumns`, etc.). Uses HTTP **200** even when validation fails — check **`ok`**.

For mappings with **`target === user_event`**, the API also validates **each data row** after headers pass (mapping, enum values, required identifiers). Other targets still validate headers only.

## Authentication

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

## Form fields

| Field       | Required | Description        |
| ----------- | -------- | ------------------ |
| `file`      | Yes      | CSV file           |
| `mappingId` | Yes      | Saved mapping UUID |

## Success — headers only (transaction, entity\_\*)

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

## Success — user events (all rows valid)

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

## Row validation failure — user events

When one or more rows fail mapping validation:

```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"
    }
  ]
}
```

Use this preflight before import. With **`batchErrorHandling: continue_collect_errors`** on [Import user events](/en/api-reference/bulk-imports/import-user-events), invalid rows are skipped and recorded in the job failures CSV; with **`rollback_all`**, the import request returns **`400`**.

See also: [Bulk imports overview](/en/api-reference/bulk-imports/overview).
