Context window

Context window

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

Context Window · Delete document

Delete a persisted document

Endpoint

DELETEhttps://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

ParameterLocationRequiredDescription
document_idURL pathYesUUID returned by an extraction with window_context or persistent memory enabled.

Expected URL shape: /delete-document/{document_id}

3. How to build the call

  1. Get the document_id from the original extraction or your internal database.
  2. Replace {document_id} in the URL with that UUID.
  3. Send DELETE with your API key in x-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)."
}

400document_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

CodeCategoryRetry?
200Success — document deleted
400Client error (missing or malformed document_id)No — fix the request first
401Authentication errorNo — fix credentials first
404Document not found, foreign, or already deletedNo — fix document_id first
405Wrong HTTP methodNo — use DELETE
500Internal server errorYes, 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, GET and POST on /window-context/{document_id} will return 404.
  • Never expose your API key in frontends or public repositories.

Request examples

curl -X DELETE "https://claix.dev/delete-document/d4a1e9d2-8b1c-4f3e-9a02-8b1e9f3c7a4b" \
  -H "x-api-key: <TU_API_KEY>"