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://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), agent_data (typed inference), and log_id. 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://claix.dev/api/txt-json; Agent mode at POST https://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.
space_idText (UUID)NoOptional. 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}.

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://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."
  },
  "log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}
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). If source verification is enabled on the schema, each property is { value, source }.
agent_dataobjectTyped Agent Mode answers per agent_definition (booleans, numbers, strings). If source verification is enabled on the schema, each field is { value, source }.
log_idstring (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 — 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

CodeCategoryRetry?
200Success—
400Client error (malformed document or data)No — fix the request first
401Authentication errorNo — fix credentials first
404Resource not foundNo — fix schema_id first
405Incorrect HTTP methodNo — fix the method first
413File or extracted text too largeNo — reduce size first
422No extractable dataNo — review document/schema first
500Internal server errorYes, with caution
502AI service failureYes, recommended with backoff

Request examples

curl -X POST "https://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"