csv.check
Check a CSV against a target schema and return diagnostics and a normalized preview.
https://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.checkathttps://api.kanagu.dev/mcp- Markdown
- /docs/csv.check.md
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"
]
}
]
}
}
}{
"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"
]
}
]
}{
"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)requiredcolumns[].type"string" | "integer" | "number" | "boolean" | "date"requiredcolumns[].requiredbooleancolumns[].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
validbooleanrequiredencoding"utf-8" | "utf-16le" | "utf-16be" | "windows-1252" | "shift_jis" | "iso-2022-jp"requireddelimiter"," | ";" | "\t" | "|"requiredheaderbooleanrequiredrowsinteger (-9007199254740991 to 9007199254740991)required- Data records processed, excluding the header.
diagnosticsarray of objectrequireddiagnostics[].code"required" | "not_in_enum" | "regex_mismatch" | "invalid_type" | "missing_column" | "duplicate_column" | … (9 values)requireddiagnostics[].columnstringdiagnostics[].sourceColumninteger (-9007199254740991 to 9007199254740991)diagnostics[].rowsarray of integer (-9007199254740991 to 9007199254740991)required- One-based CSV record numbers, including the header when present.
parseErrorobjectparseError.codestringrequiredparseError.lineinteger (-9007199254740991 to 9007199254740991)requiredpreviewarray of objectrequired- The first ten data records. String previews are capped at 64 characters.
preview[].rowinteger (-9007199254740991 to 9007199254740991)requiredpreview[].valuesobjectrequired
Try it
Errors
Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.
| Status | Code and meaning |
|---|---|
| 400 | invalid_inputThe body does not match the request schema. The message names each field. |
| 400 | invalid_jsonThe body is missing or is not valid JSON. |
| 400 | invalid_idempotency_keyIdempotency-Key must be 1–128 visible ASCII characters. |
| 401 | invalid_api_keyThe Bearer key is missing, malformed, invalid or inactive. |
| 402 | free_allowance_exhaustedThis 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. |
| 404 | not_foundNo operation at this path. |
| 409 | idempotency_conflictThe Idempotency-Key was already used with a different body. |
| 413 | payload_too_largeJSON bodies may be at most 64 KiB. |
| 429 | trial_limitThe anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left. |
| 500 | internal_errorThe 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
}