Permanently removes a file record from the database and its corresponding asset from ImageKit CDN. The endpoint validates the Clerk session, verifies ownership, purges the file from storage, then deletes the database record. This action cannot be undone.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.
Request
Method:DELETEPath:
/api/files/{fileId}Content-Type:
application/jsonAuth: Clerk session cookie required. The
userId body field must match the session’s user ID.
Path Parameters
UUID of the file to delete. Must reference a file that exists in the database
and is owned by the authenticated user; otherwise a
404 is returned.Request Body
The Clerk user ID of the authenticated user. Must match the session’s
userId
exactly; mismatches return 401 before any database or CDN operations occur.Response
200 — Success
Returns a confirmation message and the snapshot of the deletedFileItem record as it existed immediately before deletion.
Human-readable confirmation string. Always
"File deleted successfully" on
success.A snapshot of the deleted file’s database record, returned by the
RETURNING
clause before the row is dropped.Error Responses
| Status | Error message | Cause |
|---|---|---|
400 | "File ID is required" | The fileId path parameter is missing or empty. |
401 | "Unauthorized" | No active Clerk session, or userId body field doesn’t match the session user. |
404 | "File not found or you don't have permission to delete it" | No file with that UUID exists for this user. |
500 | "Internal server error" | Unexpected server, database, or ImageKit error during deletion. |
Examples
The deletion sequence is: ImageKit CDN first, then the database record. If
the ImageKit call succeeds but the database deletion fails, a
500 is
returned — the CDN asset will already have been removed in that case.