Txt-to-JSON
Extract Txt / HTML / XML into JSON
Endpoint
https://claix.dev/api/txt-jsonThis 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)
| 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. |
| 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}. |
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://claix.dev/api/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
Status: 200 OK · Content-Type: application/json
{
"success": true,
"schema_utilizado": "Facturas HTML",
"total_registros": 1,
"data": [
{
"numero_factura": "F-2026-00456",
"importe_total": 1284.50,
"moneda": "EUR"
}
],
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}| Field | Type | Description |
|---|---|---|
| success | boolean | Always true when HTTP status is 200. |
| schema_utilizado | string | Name (not id) of the schema that was applied. |
| total_registros | number | Always 1: the full content is treated as a single data source. |
| data | array of objects | Exactly one object with your schema keys. Missing values are null. If source verification is enabled on the schema, each property is { value, source }. |
| document_id | string (UUID) · optional | Present only when window_context is enabled on the schema: persisted document id for follow-up queries. |
| 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": "Facturas de Proveedores",
"total_registros": 1,
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34",
"data": [
{
"numero_factura": {
"value": "F-2026-00456",
"source": "página 1, párrafo 2"
},
"importe_total": {
"value": 1284.50,
"source": "página 1, línea de totales"
},
"moneda": {
"value": null,
"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
| Code | Category | Retry? |
|---|---|---|
| 200 | Success | — |
| 400 | Client error (malformed document or 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 |
| 413 | File or extracted text too large | No — reduce size first |
| 422 | No extractable data | No — review document/schema first |
| 500 | Internal server error | Yes, with caution |
| 502 | AI service failure | Yes, recommended with backoff |