Context window

Context window

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

Context Window · Add to space

Assign a document to a space

Endpoint

POSThttps://claix.dev/add-space

Assigns a persisted document that still has no space_id to an existing knowledge space. If the document already belongs to a space, the API returns 400.

Useful when you extracted the document without space_id and later want to group it for cross-document queries with POST /space-context/{space_id}.

Public URL: POST https://claix.dev/add-space. Never expose the direct Supabase URL.

This call is free: it is not billed and does not consume your extraction or context-window quota.

1. Authentication

Every request must include your API key. It is a personal server-side credential, different from any user session token.

Option A — Dedicated header (recommended):

x-api-key: <YOUR_API_KEY>

Option B — Standard Authorization header:

Authorization: Bearer <YOUR_API_KEY>

Either one is enough. If you send both, x-api-key wins.

Claix checks that the key exists and is active, and that the account is not suspended. Otherwise it returns 401. Document and space must belong to the same account.

2. Request format

Method: POST · Content-Type: application/json

FieldTypeRequiredDescription
document_idstring (uuid)YesUUID of a document with no space_id. Must exist and belong to your account.
space_idstring (uuid)YesTarget space UUID from POST /create-space.

Example body:

{
  "document_id": "d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b",
  "space_id": "5b9e2c14-7d3a-4f8b-9e1c-6a0d4b8f2e7c"
}

3. Building the call

  1. Have a space_id (from POST /create-space) and a document_id for a document with no space yet.
  2. Send POST to https://claix.dev/add-space with your API key and the JSON body.
  3. Check success and store space_id / version if your flow needs them.

4. Request examples

Use the code panel on the right to copy examples in cURL, JavaScript, Python, and more.

5. Success response format

HTTP 200 — The document is linked to the space.

{
  "success": true,
  "document_id": "d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b",
  "space_id": "5b9e2c14-7d3a-4f8b-9e1c-6a0d4b8f2e7c",
  "space_name": "Proveedores 2026",
  "file_name": "factura.pdf",
  "version": 1,
  "message": "Documento añadido al espacio de conocimiento."
}
FieldTypeDescription
successbooleanAlways true in a 200 response.
document_idstring (uuid)Assigned document.
space_idstring (uuid)Space it was added to.
space_namestringName of the target space.
file_namestringDocument file name.
versionnumberCurrent document version.
messagestringHuman-readable confirmation.

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 body, malformed UUIDs, or the document already has a space_id.

401 — Authentication failed: key missing, unknown, disabled, or account not active.

404 — Document or space does not exist, or does not belong to your account.

405 — Method other than POST. · 500 — Internal error.

7. Code summary

CodeCategoryRetry?
200Success — document added to space—
400Client error (already has space, invalid UUID, or bad body)No — fix the request first
401Authentication errorNo — fix credentials first
404Document or space not foundNo — fix the IDs first
405Incorrect HTTP methodNo — use POST
500Internal server errorYes, with caution

8. Best practices

  • Prefer passing space_id at extraction time when you already know the group; use this endpoint only for later assignment.
  • If the document is already in a space, remove it first with DELETE /remove-document-from-space/{document_id} and then add it again.
  • Always use the public claix.dev domain, not the direct Supabase URL.
  • Never ship your API key in frontend code or public repositories.

Request examples

curl -X POST "https://claix.dev/add-space" \
  -H "x-api-key: <TU_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"document_id":"d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b","space_id":"5b9e2c14-7d3a-4f8b-9e1c-6a0d4b8f2e7c"}'