Storx uses a two-stage deletion model. Moving a file to trash is a reversible soft-delete that hides the file from your main view but leaves it intact in ImageKit CDN. Permanent deletion removes both the database record and the CDN asset in one irreversible operation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Storx/llms.txt
Use this file to discover all available pages before exploring further.
How Trash Works
Trash state is stored as theisTrash boolean column on the files table:
Moving Files to Trash
ThePATCH /api/files/[fileId]/trash endpoint toggles isTrash on the target file, mirroring the same server-side toggle pattern used by the star endpoint:
/api/files/{fileId}/trash
Request body:
200 OK) — the full updated database record:
Permanently Deleting Files
Permanently deleting a file requires theDELETE /api/files/{fileId} endpoint. This endpoint:
Authenticate the request
Verifies the Clerk session and confirms that the
userId in the request body matches the authenticated user.Look up the file
Queries the
files table to confirm the record exists and belongs to the authenticated user.Delete from ImageKit CDN
Calls
imagekit.deleteFile(fileId) to permanently remove the binary asset from the CDN./api/files/{fileId}
Request body:
200 OK):
The
app/api/files/[fileId]/empty-trash/route.ts file exists in the codebase
but contains no implementation. Bulk-emptying the trash is not yet supported.Restoring Files
BecausePATCH /api/files/[fileId]/trash toggles isTrash, sending the same request a second time when isTrash = true sets it back to false, effectively restoring the file to your main view:
| Status | Body | Cause |
|---|---|---|
401 | { "error": "Unauthorized" } | Missing session or userId mismatch |
400 | { "error": "File id is required" } | fileId path param is empty |
404 | { "error": "File not found" } | No matching file for this user |
500 | { "error": "Failed to mark file as trash" } | Database error |