Context Window
Query a persisted document
Endpoint
https://claix.dev/document-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://claix.dev/document-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:
| Field | Type | Required | Description |
|---|---|---|---|
| questions | array of { question, format } | Yes | Typed questions answered from the persisted markdown only. Max 5. question: string ≤400 chars. format: string | int | boolean | timestamp | array. |
{
"questions": [
{ "question": "What is the exact penalty for early cancellation?", "format": "string" },
{ "question": "Which company is listed as the tenant, and what is its tax ID?", "format": "string" }
]
}- At least 1 question; at most 5.
- Each item must include
question(non-empty) andformatas one of:string,int,boolean,timestamp,array. - Each
ia_responseitem matches that type (ornullif missing or not safely typed). - The document must belong to the API key account and must not have expired.
3. Step-by-step request
- Extract a file with
window_context: trueand save thedocument_idfrom the response. - Obtain your API key.
- POST to
https://claix.dev/document-context/{document_id}. - Send
{ "questions": [{ "question": "...", "format": "string" }] }as JSON. - 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": [
{ "question": "¿Cuál es la penalización exacta por cancelación anticipada?", "format": "string" },
{ "question": "¿Qué empresa figura como arrendataria y cuál es su CIF?", "format": "string" }
],
"ia_response": [
"El 15 % del importe restante del contrato.",
"Inversiones Delta S.L., CIF B12345678"
],
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}| Field | Type | Description |
|---|---|---|
| user_ask | array of { question, format } | The questions you sent (with their format), in the same order. |
| ia_response | typed array | Answers 1:1 with user_ask, typed by format (string, int, boolean, timestamp, array) or null. With source verification, each item is { value, source }. |
| log_id | string (UUID) | UUID of this call’s usage_logs row. Present on success and on most authenticated errors. |
The response includes log_id when the usage_logs row could be stored.
If source verification is enabled on document queries, each ia_response item is { "value": ..., "source": "..." }. source quotes the phrases or snippets from the persisted plain-text content that support the answer. If there is no evidence, source is requires_human_revision.
Example with source verification enabled:
{
"user_ask": [
{ "question": "¿Cuál es la penalización exacta por cancelación anticipada?", "format": "string" }
],
"ia_response": [
{
"value": "El 15 % del importe restante del contrato.",
"source": "penalización del 15 % del importe restante en caso de cancelación anticipada"
}
],
"log_id": "7c2e1a90-4b3d-4f8a-9e21-6d5c8b0a1f34"
}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 — Invalid document_id, malformed JSON, missing questions, empty array, more than 5 items, a question longer than 400 characters, or a missing/invalid format (string | int | boolean | timestamp | array).
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
| 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 |