Context Window · Remove from space
Detach a document from its space
Endpoint
https://claix.dev/remove-document-from-space/{document_id}Sets espacio_id to null on the document. The document still exists; it just no longer belongs to the space. If it already had no space, the API returns 400.
Also accepts POST on the same URL. After detaching you can assign it again with POST /add-space.
Public URL: DELETE https://claix.dev/remove-document-from-space/{document_id}
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. Otherwise it returns 401.
2. Request format
Method: DELETE (also POST) · Body: not required · Query params: none
| Parameter | Location | Required | Description |
|---|---|---|---|
| document_id | URL path | Yes | UUID of a document that currently has a space_id. |
Expected URL shape: /remove-document-from-space/{document_id}
3. Building the call
- Get the
document_idof the document you want to detach. - Replace
{document_id}in the URL with that UUID. - Send
DELETE(orPOST) with your API key inx-api-key(no body).
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 no longer has a space assigned.
{
"success": true,
"document_id": "d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b",
"previous_space_id": "5b9e2c14-7d3a-4f8b-9e1c-6a0d4b8f2e7c",
"espacio_id": null,
"file_name": "factura.pdf",
"version": 1,
"message": "Documento desacoplado del espacio. Ahora está sin space_id."
}| Field | Type | Description |
|---|---|---|
| success | boolean | Always true in a 200 response. |
| document_id | string (uuid) | Detached document. |
| previous_space_id | string (uuid) | Space it was removed from. |
| espacio_id | null | Always null after the operation. |
| 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 — Missing or invalid document_id, or the document already has no space assigned.
401 — Authentication failed: key missing, unknown, disabled, or account not active.
404 — Document does not exist or does not belong to your account.
405 — Method not allowed. · 500 — Internal error.
7. Code summary
| Code | Category | Retry? |
|---|---|---|
| 200 | Success — document detached | — |
| 400 | Client error (already no space or invalid document_id) | No — fix the request first |
| 401 | Authentication error | No — fix credentials first |
| 404 | Document not found | No — fix document_id first |
| 405 | Incorrect HTTP method | No — use DELETE or POST |
| 500 | Internal server error | Yes, with caution |
8. Best practices
- This does not delete the document — it only removes it from the space. To delete it use
DELETE /delete-document/{document_id}. - After detaching, the document no longer appears in that space's
/space-contextqueries. - Always use the public
claix.devdomain, not the direct Supabase URL. - Never ship your API key in frontend code or public repositories.