Context Window · Delete document
Delete a persisted document
Endpoint
https://claix.dev/delete-document/{document_id}Write endpoint that deletes a specific row from the documents table by document_id. It accepts no body and no query parameters — the identifier is only in the URL path.
The delete query filters by both id and user_id, so another account's document_id can never be removed with your API key. If the UUID does not exist, was already purged after expiry, or belongs to someone else, the API returns 404 with the same generic message (the exact reason is not exposed).
Public URL: DELETE https://claix.dev/delete-document/{document_id}
The operation is irreversible. This call is free: it is not billed and does not consume extraction or context-window quota.
1. Authentication
Every request must include your API key — a server credential, not an end-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 is enough. If you send both, x-api-key takes priority.
The system checks that the key exists, is active, and the linked user has status = active. Otherwise it returns 401.
2. Request format
Method: DELETE · Body: not required · Query params: none
| Parameter | Location | Required | Description |
|---|---|---|---|
| document_id | URL path | Yes | UUID returned by an extraction with window_context or persistent memory enabled. |
Expected URL shape: /delete-document/{document_id}
3. How to build the call
- Get the
document_idfrom the original extraction or your internal database. - Replace
{document_id}in the URL with that UUID. - Send
DELETEwith your API key inx-api-key(no body).
4. Request examples
Use the code panel on the right for cURL, JavaScript, Python, and more.
5. Successful response
HTTP 200 — The row was removed from documents. The response only contains the deleted document_id; there is no success field. If deletion was not possible, the request ends with 404 before any success payload is built.
{
"document_id": "d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b"
}6. Error codes
{
"error": "Descripción legible del problema.",
"detalle": "Información técnica adicional (solo presente en algunos casos)."
}400 — document_id is missing from the URL or is not a valid UUID.
401 — Authentication failed: missing key, invalid key, deactivated key, or inactive account.
404 — No row was deleted: the document does not exist, belongs to another account, or was already removed (for example after expiry). Same generic message for security.
404 example:
{
"error": "No existe ningún documento con id 'd4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b'."
}405 — Method other than DELETE. · 500 — Internal error.
7. Status code summary
| Code | Category | Retry? |
|---|---|---|
| 200 | Success — document deleted | — |
| 400 | Client error (missing or malformed document_id) | No — fix the request first |
| 401 | Authentication error | No — fix credentials first |
| 404 | Document not found, foreign, or already deleted | No — fix document_id first |
| 405 | Wrong HTTP method | No — use DELETE |
| 500 | Internal server error | Yes, with caution |
8. Best practices
- Always use the public domain
claix.dev, not the direct Supabase function URL. - Delete documents when the user requests it or when you no longer need to keep document context (GDPR, contractual retention, etc.).
- With persistent memory, combine this endpoint with your per-tenant, per-case, or per-user erasure policy.
- After deletion,
GETandPOSTon/window-context/{document_id}will return 404. - Never expose your API key in frontends or public repositories.