POST /api/documents/index
Downloads a file from Appwrite Storage, extracts its text (or generates an AI image description for image files), splits the text into overlapping chunks, generates 768-dimension embeddings with Geminitext-embedding-004, detects a category, and upserts all chunk vectors into the Qdrant prism_documents collection.
This is the most expensive endpoint. It has a maximum execution time of 300 seconds.
Request body
The Appwrite Storage file ID. Used to download the file and as the primary
identifier for all vector payloads.
The Appwrite user ID. Stored as a payload field on every vector so that
searches can be scoped per user.
The original file name including extension (e.g.
report.pdf). Used to
detect file type and category.Chunking behaviour
Text documents are split with a maximum chunk size of 1000 characters and an overlap of 200 characters. Markdown files are additionally split on header boundaries. Image files (jpg, jpeg, png, gif, webp, bmp, svg) bypass text extraction and are described by Gemini Vision instead.
Response
true on success.Echo of the supplied Appwrite file ID.
File name as stored in Appwrite.
Number of text chunks indexed into Qdrant.
Auto-detected category label. One of:
Code, Image, Resume, Report, Financial, Legal, Notes, Meeting, Presentation, Documentation, General.Human-readable status message.
Errors
| Status | Condition |
|---|---|
400 | Any of documentId, userId, or fileName is missing |
400 | No extractable text found in the file |
500 | Appwrite Storage download failed, Gemini embedding failed, or Qdrant upsert failed |
Example
POST /api/documents/delete
Deletes all Qdrant vector points associated with a document. This does not delete the file from Appwrite Storage — remove the file from Storage separately using the Appwrite SDK or console. The route has a maximum execution time of 60 seconds.Request body
The Appwrite Storage file ID whose vectors to delete.
Response
true when the delete operation completes.Human-readable confirmation.
Errors
| Status | Condition |
|---|---|
400 | documentId is missing |
500 | Qdrant delete operation failed |
Example
POST /api/documents/rename
Renames a file in Appwrite Storage and updates thedocumentName payload field on all matching Qdrant vectors in a single setPayload call. Both operations run synchronously.
Request body
The Appwrite Storage file ID to rename.
The new file name. Must not be empty or blank, and must be 255 characters or
fewer.
Response
true on success.Echo of the Appwrite file ID.
The name that was applied.
Human-readable confirmation.
Errors
| Status | Condition |
|---|---|
400 | documentId or newName is missing |
400 | newName is blank or exceeds 255 characters |
500 | Appwrite Storage update failed |
Example
GET /api/documents/content
Downloads a file from Appwrite Storage and returns its raw bytes decoded as UTF-8 text. Intended for plain-text file types such as.txt, .md, and .csv.
Query parameters
The Appwrite Storage file ID to retrieve.
Response
Returns the file bytes astext/plain; charset=utf-8. The response body is the raw file content, not JSON.
Errors
| Status | Condition |
|---|---|
400 | fileId query parameter is missing |
500 | Appwrite Storage download failed |
Example
GET /api/documents/recommendations
Finds documents in the user’s library that are semantically similar to the specified document. The endpoint fetches a representative vector from the source document, runs a Qdrant similarity search excluding the source document itself, and filters results to those that still exist in Appwrite Storage. The route has a maximum execution time of 60 seconds.Query parameters
The Appwrite file ID of the source document to find recommendations for.
The Appwrite user ID. Restricts recommendations to the user’s own documents.
Maximum number of recommendations to return. The server fetches
limit * 2
candidates internally, validates each against Appwrite Storage, and returns
the first limit valid results.Response
true on success.Ordered list of similar documents, highest similarity first. Only documents
with a cosine similarity score of
0.5 or above are included.Number of recommendations returned.
Errors
| Status | Condition |
|---|---|
400 | documentId is missing |
400 | userId is missing |
500 | Qdrant or Appwrite error |