Context Window · Add to space
Assign a document to a space
Endpoint
https://claix.dev/add-spaceAssigns 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
| Field | Type | Required | Description |
|---|---|---|---|
| document_id | string (uuid) | Yes | UUID of a document with no space_id. Must exist and belong to your account. |
| space_id | string (uuid) | Yes | Target 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
- Have a
space_id(fromPOST /create-space) and adocument_idfor a document with no space yet. - Send
POSTtohttps://claix.dev/add-spacewith your API key and the JSON body. - Check
successand storespace_id/versionif 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."
}| Field | Type | Description |
|---|---|---|
| success | boolean | Always true in a 200 response. |
| document_id | string (uuid) | Assigned document. |
| space_id | string (uuid) | Space it was added to. |
| space_name | string | Name of the target space. |
| file_name | string | Document file name. |
| version | number | Current document version. |
| message | string | Human-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
| Code | Category | Retry? |
|---|---|---|
| 200 | Success — document added to space | — |
| 400 | Client error (already has space, invalid UUID, or bad body) | No — fix the request first |
| 401 | Authentication error | No — fix credentials first |
| 404 | Document or space not found | No — fix the IDs first |
| 405 | Incorrect HTTP method | No — use POST |
| 500 | Internal server error | Yes, with caution |
8. Best practices
- Prefer passing
space_idat 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.devdomain, not the direct Supabase URL. - Never ship your API key in frontend code or public repositories.