Agent mode API

Agent mode endpoints

Structured extraction plus semantic reasoning with agent_definition parameters.

Txt-to-JSON · Agent mode

Txt / HTML / XML to JSON with Agent mode

Endpoint

POSThttps://www.claix.dev/agent/txt-json

Agent 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)

FieldTypeRequiredDescription
contentTextYesThe text, HTML, or XML to transform. Not a file upload: the payload itself as a form text part.
schema_idText (UUID)YesID 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

TypeExample use casesNotes
Plain textRaw emails, logs, pasted contracts, textual CSV, unrendered MarkdownAnalyzed as-is; Markdown syntax is not interpreted.
HTMLWeb pages, DOM fragments, HTML emails, rendered invoicesThe model reads tags and visible text; JavaScript is not executed.
XMLRSS/Atom feeds, SOAP, e-invoices, legacy API responsesNode 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, content may also be sent as a text File, but a string form field is the usual pattern.

3. Step-by-step request

  1. Obtain your API key.
  2. Create a txt-json schema and copy its schema_id.
  3. POST to https://www.claix.dev/agent/txt-json.
  4. Send auth via x-api-key or Authorization: Bearer.
  5. Build multipart/form-data with content and schema_id.
  6. 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."
  }
}
FieldTypeDescription
successbooleanAlways true when HTTP is 200.
schema_utilizadostringName of the schema used for extraction.
total_registrosnumberNumber of records in data.
dataarrayObjects extracted from the main schema (same as extraction mode).
agent_dataobjectTyped 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ódigoCategoría¿Reintentar?
200Éxito
400Error del cliente (documento o datos mal formados)No, corrige la petición primero
401Error de autenticaciónNo, corrige las credenciales primero
404Recurso no encontradoNo, corrige el schema_id primero
405Método HTTP incorrectoNo, corrige el método primero
413Archivo o texto extraído demasiado grandeNo, reduce el tamaño primero
422Sin datos extraíblesNo, revisa el documento/schema primero
500Error interno del servidorSí, con precaución
502Fallo del servicio de IASí, recomendado con backoff

Request examples

curl -X POST "https://www.claix.dev/agent/txt-json" \
  -H "x-api-key: <TU_API_KEY>" \
  -F "content=<html><body><h1>Factura F-2026-00456</h1><p>Total: 1284.50 EUR</p></body></html>" \
  -F "schema_id=b980cfe7-61ef-4a5a-9724-881c8a5541e2"