Txt-to-JSON · Agent mode
Txt / HTML / XML to JSON with Agent mode
Endpoint
https://www.claix.dev/agent/txt-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) and agent_data (typed inference). The schema must have is_agent_mode enabled.
This endpoint receives a content field with already processed plain text, HTML, or XML and returns a single JSON object matching a txt-json schema.
Unlike doc-json, no file is uploaded: the payload is the content itself in a multipart form. Auth, schema checks, usage logs, and optional context window behavior match the other child functions.
Public URLs (Claix domain): extraction at POST https://www.claix.dev/api/txt-json; Agent mode at POST https://www.claix.dev/agent/txt-json. Never expose the raw Supabase URL to end clients.
Designed for server-to-server integrations. Do not call it from an end-user browser: it requires a secret API key.
1. Authentication
Every request must include your API key.
Option A — Dedicated header (recommended):
x-api-key: <YOUR_API_KEY>
Option B — Standard Authorization header:
Authorization: Bearer <YOUR_API_KEY>
If both are sent, x-api-key takes priority.
Before processing content, the system validates the API key and account status. Failures return 401.
2. Request format
HTTP method: POST · Content-Type: multipart/form-data (required)
| Field | Type | Required | Description |
|---|---|---|---|
| content | Text | Yes | The text, HTML, or XML to transform. Not a file upload: the payload itself as a form text part. |
| schema_id | Text (UUID) | Yes | ID of a txt-json schema previously created on your account. |
Field names must be exactly content and schema_id.
Schema requirement
schema_id must reference a txt-json schema. Other schema types return 400.
Supported content types in content
| Type | Example use cases | Notes |
|---|---|---|
| Plain text | Raw emails, logs, pasted contracts, textual CSV, unrendered Markdown | Analyzed as-is; Markdown syntax is not interpreted. |
| HTML | Web pages, DOM fragments, HTML emails, rendered invoices | The model reads tags and visible text; JavaScript is not executed. |
| XML | RSS/Atom feeds, SOAP, e-invoices, legacy API responses | Node structure is used to locate fields. |
Content requirements
- Content cannot be empty (whitespace only).
- Max 300,000 characters. Larger payloads return 413 before calling the model.
- As a fallback,
contentmay also be sent as a textFile, but a string form field is the usual pattern.
3. Step-by-step request
- Obtain your API key.
- Create a
txt-jsonschema and copy itsschema_id. - POST to https://www.claix.dev/agent/txt-json.
- Send auth via
x-api-keyorAuthorization: Bearer. - Build
multipart/form-datawithcontentandschema_id. - Verify HTTP 200 before treating the call as successful.
4. Request examples
See the right-hand panel for cURL, JavaScript, Node.js, Python, PHP, and n8n examples.
5. Successful response
200 OK · Content-Type: application/json
{
"success": true,
"schema_utilizado": "Contratos legales",
"total_registros": 1,
"data": [
{
"parte_a": "Inmobiliaria Norte S.L.",
"parte_b": "Carlos Méndez",
"fecha_firma": "2026-03-01"
}
],
"agent_data": {
"clausula_penalizacion": true,
"tipo_renovacion": "automatica",
"resumen_contrato": "Arrendamiento con renovación automática y cláusula de penalización por impago."
}
}| 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). |
| agent_data | object | Typed Agent Mode answers per agent_definition (booleans, numbers, strings). |
6. Error codes
{
"error": "Descripción legible del problema.",
"detalle": "Información técnica adicional (solo presente en algunos casos)."
}400 — Missing content or schema_id, body is not multipart, empty content, or schema is not type txt-json.
401 — Missing, invalid, or inactive API key, or suspended account.
404 — schema_id does not exist or does not belong to the account.
413 — Content exceeds 300,000 characters.
422 — No data matching the schema could be extracted.
502 — AI service failure. 405 — Method other than POST. 500 — Unexpected server error.
7. Error code summary
| Código | Categoría | ¿Reintentar? |
|---|---|---|
| 200 | Éxito | — |
| 400 | Error del cliente (documento o datos mal formados) | No, corrige la petición primero |
| 401 | Error de autenticación | No, corrige las credenciales primero |
| 404 | Recurso no encontrado | No, corrige el schema_id primero |
| 405 | Método HTTP incorrecto | No, corrige el método primero |
| 413 | Archivo o texto extraído demasiado grande | No, reduce el tamaño primero |
| 422 | Sin datos extraíbles | No, revisa el documento/schema primero |
| 500 | Error interno del servidor | Sí, con precaución |
| 502 | Fallo del servicio de IA | Sí, recomendado con backoff |