Skip to content
CSV validation

csv.check

Check a CSV against a target schema and return diagnostics and a normalized preview.

POSThttps://api.kanagu.dev/v1/csv/check
Price
$0.03 per successful call
Without a key
10 free calls per IP per UTC day, shared by REST and MCP.
MCP tool
csv.check at https://api.kanagu.dev/mcp
curl https://api.kanagu.dev/v1/csv/check \
  -H "Content-Type: application/json" \
  -d '{"text":"invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown","columns":[{"name":"invoice_id","type":"string","required":true,"regex":"^INV-[0-9]{5}$"},{"name":"issued_on","type":"date","locale":"de-DE","required":true},{"name":"amount","type":"number","locale":"de-DE","required":true},{"name":"status","type":"string","enum":["open","paid"]}]}'
curl https://api.kanagu.dev/v1/csv/check \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown","columns":[{"name":"invoice_id","type":"string","required":true,"regex":"^INV-[0-9]{5}$"},{"name":"issued_on","type":"date","locale":"de-DE","required":true},{"name":"amount","type":"number","locale":"de-DE","required":true},{"name":"status","type":"string","enum":["open","paid"]}]}'
const res = await fetch("https://api.kanagu.dev/v1/csv/check", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "text": "invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown",
    "columns": [
      {
        "name": "invoice_id",
        "type": "string",
        "required": true,
        "regex": "^INV-[0-9]{5}$"
      },
      {
        "name": "issued_on",
        "type": "date",
        "locale": "de-DE",
        "required": true
      },
      {
        "name": "amount",
        "type": "number",
        "locale": "de-DE",
        "required": true
      },
      {
        "name": "status",
        "type": "string",
        "enum": [
          "open",
          "paid"
        ]
      }
    ]
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "csv.check",
    "arguments": {
      "text": "invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown",
      "columns": [
        {
          "name": "invoice_id",
          "type": "string",
          "required": true,
          "regex": "^INV-[0-9]{5}$"
        },
        {
          "name": "issued_on",
          "type": "date",
          "locale": "de-DE",
          "required": true
        },
        {
          "name": "amount",
          "type": "number",
          "locale": "de-DE",
          "required": true
        },
        {
          "name": "status",
          "type": "string",
          "enum": [
            "open",
            "paid"
          ]
        }
      ]
    }
  }
}
Request body
{
  "text": "invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown",
  "columns": [
    {
      "name": "invoice_id",
      "type": "string",
      "required": true,
      "regex": "^INV-[0-9]{5}$"
    },
    {
      "name": "issued_on",
      "type": "date",
      "locale": "de-DE",
      "required": true
    },
    {
      "name": "amount",
      "type": "number",
      "locale": "de-DE",
      "required": true
    },
    {
      "name": "status",
      "type": "string",
      "enum": [
        "open",
        "paid"
      ]
    }
  ]
}
Response · 200
{
  "valid": false,
  "encoding": "utf-8",
  "delimiter": ";",
  "header": true,
  "rows": 3,
  "diagnostics": [
    {
      "code": "invalid_type",
      "column": "issued_on",
      "rows": [
        3
      ]
    },
    {
      "code": "invalid_type",
      "column": "amount",
      "rows": [
        4
      ]
    },
    {
      "code": "not_in_enum",
      "column": "status",
      "rows": [
        4
      ]
    }
  ],
  "preview": [
    {
      "row": 2,
      "values": {
        "invoice_id": "INV-00812",
        "issued_on": "2026-11-21",
        "amount": 1242.5,
        "status": "paid"
      }
    },
    "… 2 more"
  ]
}

Request body

application/json

columnsarray of objectrequired
Target columns, in source order for headerless files.
columns[].namestring (max 64 chars)required
columns[].type"string" | "integer" | "number" | "boolean" | "date"required
columns[].requiredboolean
columns[].enumarray of string
Allowed trimmed source values.
columns[].regexstring (max 256 chars)
RE2 pattern searched within the trimmed source value.
columns[].localestring (max 40 chars)
BCP 47 number or date locale, default en-US.
columns[].dateOrder"YMD" | "DMY" | "MDY"
Override date component order.
delimiter"," | ";" | "\t" | "|"
Auto-detect by default.
encoding"utf-8" | "utf-16le" | "utf-16be" | "windows-1252" | "shift_jis" | "iso-2022-jp"
Raw file encoding. Auto-detects BOM, UTF-8, and Windows-1252.
headerboolean
Auto-detect by matching names in the first record.

Then exactly one of these 2 shapes:

1. With text

textstring (max 5242880 chars)required
UTF-8 CSV text, at most 5 MiB.

2. With base64

base64string (base64, max 6990508 chars)required
File bytes as Base64, at most 5 MiB decoded.

Response

200 · application/json

validbooleanrequired
encoding"utf-8" | "utf-16le" | "utf-16be" | "windows-1252" | "shift_jis" | "iso-2022-jp"required
delimiter"," | ";" | "\t" | "|"required
headerbooleanrequired
rowsinteger (-9007199254740991 to 9007199254740991)required
Data records processed, excluding the header.
diagnosticsarray of objectrequired
diagnostics[].code"required" | "not_in_enum" | "regex_mismatch" | "invalid_type" | "missing_column" | "duplicate_column" | … (9 values)required
diagnostics[].columnstring
diagnostics[].sourceColumninteger (-9007199254740991 to 9007199254740991)
diagnostics[].rowsarray of integer (-9007199254740991 to 9007199254740991)required
One-based CSV record numbers, including the header when present.
parseErrorobject
parseError.codestringrequired
parseError.lineinteger (-9007199254740991 to 9007199254740991)required
previewarray of objectrequired
The first ten data records. String previews are capped at 64 characters.
preview[].rowinteger (-9007199254740991 to 9007199254740991)required
preview[].valuesobjectrequired

Try it

csv.check

$0.03/call

No key needed · 10 free calls per IP per day

Response

Run the request to see the live response here.

Errors

Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.

StatusCode and meaning
400invalid_input

The body does not match the request schema. The message names each field.

400invalid_json

The body is missing or is not valid JSON.

400invalid_idempotency_key

Idempotency-Key must be 1–128 visible ASCII characters.

401invalid_api_key

The Bearer key is missing, malformed, invalid or inactive.

402free_allowance_exhausted

This month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left.

404not_found

No operation at this path.

409idempotency_conflict

The Idempotency-Key was already used with a different body.

413payload_too_large

JSON bodies may be at most 64 KiB.

429trial_limit

The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.

500internal_error

The call failed on our side. It is not billed; retry with the same Idempotency-Key.

JSON Schema

Request schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "columns": {
          "minItems": 1,
          "maxItems": 32,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "type": {
                "type": "string",
                "enum": [
                  "string",
                  "integer",
                  "number",
                  "boolean",
                  "date"
                ]
              },
              "required": {
                "default": false,
                "type": "boolean"
              },
              "enum": {
                "description": "Allowed trimmed source values.",
                "maxItems": 200,
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "regex": {
                "description": "RE2 pattern searched within the trimmed source value.",
                "type": "string",
                "maxLength": 256
              },
              "locale": {
                "description": "BCP 47 number or date locale, default en-US.",
                "type": "string",
                "maxLength": 40
              },
              "dateOrder": {
                "description": "Override date component order.",
                "type": "string",
                "enum": [
                  "YMD",
                  "DMY",
                  "MDY"
                ]
              }
            },
            "required": [
              "name",
              "type"
            ],
            "additionalProperties": false
          },
          "description": "Target columns, in source order for headerless files."
        },
        "delimiter": {
          "description": "Auto-detect by default.",
          "type": "string",
          "enum": [
            ",",
            ";",
            "\t",
            "|"
          ]
        },
        "encoding": {
          "description": "Raw file encoding. Auto-detects BOM, UTF-8, and Windows-1252.",
          "type": "string",
          "enum": [
            "utf-8",
            "utf-16le",
            "utf-16be",
            "windows-1252",
            "shift_jis",
            "iso-2022-jp"
          ]
        },
        "header": {
          "description": "Auto-detect by matching names in the first record.",
          "type": "boolean"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 5242880,
          "description": "UTF-8 CSV text, at most 5 MiB."
        }
      },
      "required": [
        "columns",
        "text"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "columns": {
          "minItems": 1,
          "maxItems": 32,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "type": {
                "type": "string",
                "enum": [
                  "string",
                  "integer",
                  "number",
                  "boolean",
                  "date"
                ]
              },
              "required": {
                "default": false,
                "type": "boolean"
              },
              "enum": {
                "description": "Allowed trimmed source values.",
                "maxItems": 200,
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "regex": {
                "description": "RE2 pattern searched within the trimmed source value.",
                "type": "string",
                "maxLength": 256
              },
              "locale": {
                "description": "BCP 47 number or date locale, default en-US.",
                "type": "string",
                "maxLength": 40
              },
              "dateOrder": {
                "description": "Override date component order.",
                "type": "string",
                "enum": [
                  "YMD",
                  "DMY",
                  "MDY"
                ]
              }
            },
            "required": [
              "name",
              "type"
            ],
            "additionalProperties": false
          },
          "description": "Target columns, in source order for headerless files."
        },
        "delimiter": {
          "description": "Auto-detect by default.",
          "type": "string",
          "enum": [
            ",",
            ";",
            "\t",
            "|"
          ]
        },
        "encoding": {
          "description": "Raw file encoding. Auto-detects BOM, UTF-8, and Windows-1252.",
          "type": "string",
          "enum": [
            "utf-8",
            "utf-16le",
            "utf-16be",
            "windows-1252",
            "shift_jis",
            "iso-2022-jp"
          ]
        },
        "header": {
          "description": "Auto-detect by matching names in the first record.",
          "type": "boolean"
        },
        "base64": {
          "type": "string",
          "minLength": 1,
          "maxLength": 6990508,
          "format": "base64",
          "contentEncoding": "base64",
          "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
          "description": "File bytes as Base64, at most 5 MiB decoded."
        }
      },
      "required": [
        "columns",
        "base64"
      ],
      "additionalProperties": false
    }
  ],
  "examples": [
    {
      "text": "invoice_id;issued_on;amount;status\r\nINV-00812;21.11.2026;1.242,50;paid\r\nINV-00813;31.11.2026;200,00;open\r\nINV-00814;23.11.2026;12,1,5;unknown",
      "columns": [
        {
          "name": "invoice_id",
          "type": "string",
          "required": true,
          "regex": "^INV-[0-9]{5}$"
        },
        {
          "name": "issued_on",
          "type": "date",
          "locale": "de-DE",
          "required": true
        },
        {
          "name": "amount",
          "type": "number",
          "locale": "de-DE",
          "required": true
        },
        {
          "name": "status",
          "type": "string",
          "enum": [
            "open",
            "paid"
          ]
        }
      ]
    }
  ],
  "type": "object"
}
Response schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "valid": {
      "type": "boolean"
    },
    "encoding": {
      "type": "string",
      "enum": [
        "utf-8",
        "utf-16le",
        "utf-16be",
        "windows-1252",
        "shift_jis",
        "iso-2022-jp"
      ]
    },
    "delimiter": {
      "type": "string",
      "enum": [
        ",",
        ";",
        "\t",
        "|"
      ]
    },
    "header": {
      "type": "boolean"
    },
    "rows": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Data records processed, excluding the header."
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "required",
              "not_in_enum",
              "regex_mismatch",
              "invalid_type",
              "missing_column",
              "duplicate_column",
              "unexpected_column",
              "extra_cells",
              "empty_csv"
            ]
          },
          "column": {
            "type": "string"
          },
          "sourceColumn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "description": "One-based CSV record numbers, including the header when present."
          }
        },
        "required": [
          "code",
          "rows"
        ],
        "additionalProperties": false
      }
    },
    "parseError": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "line": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "code",
        "line"
      ],
      "additionalProperties": false
    },
    "preview": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "row": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "values": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          }
        },
        "required": [
          "row",
          "values"
        ],
        "additionalProperties": false
      },
      "description": "The first ten data records. String previews are capped at 64 characters."
    }
  },
  "required": [
    "valid",
    "encoding",
    "delimiter",
    "header",
    "rows",
    "diagnostics",
    "preview"
  ],
  "additionalProperties": false
}