Temporary context window

Temporary context window

Ask questions about a persisted document after extraction with window_context enabled.

Temporary Context Window

Ask questions about a persisted document

Endpoint

POSThttps://www.claix.dev/window-context/{document_id}

This endpoint answers questions about a document already extracted with window_context enabled. The document_id is in the URL (returned by the extraction call) and the questions go in a simple JSON body.

Public URL: POST https://www.claix.dev/window-context/{document_id}. Never expose the raw Supabase URL.

Designed for server-to-server integrations. 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>

The system checks that the key exists and is active, and that the account is not suspended. Failures return 401.

2. Request format

HTTP method: POST · Content-Type: application/json

document_id (UUID) is part of the path. The body has a single field:

FieldTypeRequiredDescription
questionsarray of stringsYesQuestions to answer using only the persisted markdown. Max 5 per turn. Max 400 characters per question.
{
  "questions": [
    "What is the exact penalty for early cancellation?",
    "Which company is listed as the tenant, and what is its tax ID?"
  ]
}
  • At least 1 question; at most 5.
  • Each string must have content (not whitespace only).
  • The document must belong to the API key account and must not have expired.

3. Step-by-step request

  1. Extract a file with window_context: true and save the document_id from the response.
  2. Obtain your API key.
  3. POST to https://www.claix.dev/window-context/<document_id>.
  4. Send { "questions": ["..."] } as JSON.
  5. Check HTTP 200 and read ia_response.

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

{
  "user_ask": [
    "¿Cuál es la penalización exacta por cancelación anticipada?",
    "¿Qué empresa figura como arrendataria y cuál es su CIF?"
  ],
  "ia_response": [
    "El 15 % del importe restante del contrato.",
    "Inversiones Delta S.L., CIF B12345678"
  ]
}
FieldTypeDescription
user_askarray of stringsThe questions you sent, in the same order.
ia_responsearray of string or nullAnswers aligned 1:1 with user_ask. If the fact is not in the document, the value is JSON null — not a sentence.

6. Error codes

{
  "error": "Descripción legible del problema.",
  "detalle": "Información técnica adicional (solo presente en algunos casos)."
}

400 — Invalid document_id, malformed JSON, missing questions, empty array, more than 5 items, or a question longer than 400 characters.

401 — Missing, invalid, or inactive API key, or suspended account.

404 — Document does not exist, does not belong to the account, or has expired.

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/window-context/3c7a9f21-4b8e-4d1a-9c6f-2e0d8a5b7c4f" \
  -H "x-api-key: <TU_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "questions": [
      "¿Cuál es la penalización exacta por cancelación anticipada?",
      "¿Qué empresa figura como arrendataria y cuál es su CIF?"
    ]
  }'