Excel-to-JSON · Agent mode
Excel / CSV to JSON with Agent mode
Endpoint
https://claix.dev/agent/excel-jsonAgent mode active
This endpoint runs structured extraction from the main schema first, then a reasoning phase with agent_definition. The response includes data[] (extraction), agent_data (typed inference), and log_id. The schema must have is_agent_mode enabled.
This endpoint accepts a tabular file (.xlsx or .csv) and returns it transformed into JSON with the exact structure you define via a schema. The file columns do not need to match schema property names literally: the system automatically recognizes synonyms, abbreviations, translations, and variants.
It is intended for server-to-serverintegrations (backends, scripts, n8n/Zapier/Make). It must not be called from an end user's browser because it requires a secret API key.
1. Authentication
Every request must include your API key. It is a personal server credential, distinct from any session token, and should be handled with the same care as a database password.
Option A — Dedicated header (recommended):
x-api-key: <YOUR_API_KEY>
Option B — Standard Authorization header:
Authorization: Bearer <YOUR_API_KEY>
Either one is sufficient. If you send both, x-api-key takes priority.
Before processing the file, the system validates that:
- The API key exists and is active.
- The associated account is active (not suspended).
If validation fails, the request is rejected with 401 without processing the file.
2. Request format
| Field | Type | Required | Description |
|---|---|---|---|
| file | Binary file | Yes | Excel (.xlsx) or CSV (.csv). Must be the file itself, not a path or URL. |
| schema_id | Text (UUID) | Yes | Identifier of the excel-json schema created in your account. |
| space_id | Text (UUID) | No | Optional. Knowledge space the stored document is attached to. Must belong to the same account as the API key. It only takes effect when the schema has the context window enabled, which is when the document is stored. You can then query the whole space with POST /space-context/{space_id}. |
Method: POST · Content-Type: multipart/form-data
Field names must be exactly file and schema_id. The schema must be of the Excel → JSON type; if you send one of the opposite type, you will receive 400.
File requirements:
- Formats: .xlsx, .csv.
- At least one header row and one data row.
- If there are multiple sheets, only the first is processed.
3. How to build the request
- Have your API key and the correct schema_id ready.
- Build a POST request to the endpoint URL.
- Add the authentication header.
- Send
multipart/form-datawithfileandschema_id. - Check the HTTP status code: only 200 indicates success.
4. Request examples
See the panel on the right for examples in cURL, JavaScript, Node.js, Python, PHP, and n8n. You can switch languages with the selector at the top and copy the code directly.
5. Successful response format
200 OK · Content-Type: application/json
{
"success": true,
"schema_utilizado": "Inventario Q3",
"total_registros": 2,
"data": [
{ "sku": "SKU-001", "stock": 120, "precio": 19.99 },
{ "sku": "SKU-002", "stock": 45, "precio": 34.5 }
],
"agent_data": {
"stock_critico": true,
"productos_bajo_minimo": 1,
"resumen_inventario": "Un producto por debajo del umbral mínimo de stock."
},
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}| Field | Type | Description |
|---|---|---|
| success | boolean | Always true when HTTP is 200. |
| schema_utilizado | string | Name of the schema used for extraction. |
| total_registros | number | Number of records in data. |
| data | array | Objects extracted from the main schema (same as extraction mode). If source verification is enabled on the schema, each property is { value, source }. |
| agent_data | object | Typed Agent Mode answers per agent_definition (booleans, numbers, strings). If source verification is enabled on the schema, each field is { value, source }. |
| log_id | string (UUID) | UUID of this call’s usage_logs row. Present on success and on most authenticated errors. |
Every response includes log_id (the UUID of the usage_logs row) when the log could be stored. It also appears on most errors after the request is authenticated. Use it to find the call in the logs panel.
If source verification is enabled on the schema, each extracted property (and each agent_data field in Agent mode) becomes { "value": ..., "source": "..." } instead of a bare value. source is required: it cites the evidence (page, paragraph, cell, quoted snippet, image region, or the second / second range in audio). If there is no evidence, source is exactly requires_human_revision. If source verification is off, the format is unchanged.
Example with source verification enabled:
{
"success": true,
"schema_utilizado": "Contratos",
"total_registros": 1,
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34",
"data": [
{
"persona contratada": {
"value": "Gael Anaya",
"source": "página 1, párrafo 1"
}
}
],
"agent_data": {
"salario": {
"value": 55000,
"source": "página 2, cláusula retributiva"
},
"es_parcial": {
"value": false,
"source": "requires_human_revision"
}
}
}6. Error codes
{
"error": "Descripción legible del problema.",
"detalle": "Información técnica adicional (solo presente en algunos casos).",
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}400 — Invalid request: missing file or schema_id, incorrect multipart, corrupt file, no data rows, or schema of the wrong type.
401 — Authentication failed: key missing, nonexistent, deactivated, or account suspended.
404 — schema_id does not exist or does not belong to your account.
422 — File read but no matches with the schema.
502 — AI service failure (transient; retry with backoff).
405 — Method other than POST. · 500 — Internal error.
7. Code summary
| Code | Category | Retry? |
|---|---|---|
| 200 | Success | — |
| 400 | Client error (malformed data) | No — fix the request first |
| 401 | Authentication error | No — fix credentials first |
| 404 | Resource not found | No — fix schema_id first |
| 405 | Incorrect HTTP method | No — fix the method first |
| 422 | No matches found | No — review data/schema first |
| 500 | Internal server error | Yes, with caution |
| 502 | AI service failure | Yes, recommended with backoff |
8. Best practices
- Validate the HTTP status code before reading data.
- Only columns with a real match in the schema appear.
- Retry automatically only on 500 and 502, never on 4xx unless the request changes.
- Save
mapa_columnasfor traceability during testing. - Do not include your API key in frontend code or public repositories.