Accepts aDocumentation 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.
multipart/form-data request containing the file binary and ownership metadata. The endpoint validates the Clerk session, checks the file type, optionally verifies the target parent folder, uploads the file to ImageKit under /storex/{userId}/, and persists a metadata record in the database.
Request
Method:POSTPath:
/api/files/uploadContent-Type:
multipart/form-dataAuth: Clerk session cookie required. The
userId form field must match the session’s user ID.
Form Fields
The binary file to upload. Accepted MIME types are:
image/*— any image format (JPEG, PNG, WebP, GIF, etc.)application/pdf— PDF documents
400 error.The Clerk user ID of the authenticated user. Must match the session’s
userId
exactly; mismatches return 401 without touching storage.UUID of an existing folder to upload into. When provided the endpoint queries
the database to confirm the folder exists, is a folder (
isFolder = true),
and belongs to the authenticated user — returning 404 if any check fails.
Omit to upload to the user’s root directory.ImageKit Storage Path
The file is stored under one of these paths depending on whetherparentId is supplied:
| Scenario | ImageKit folder path |
|---|---|
No parentId (root) | /storex/{userId}/ |
With parentId (folder) | /storex/{userId}/folder/{parentId}/ |
3f7a1b2c-....jpg). useUniqueFileName is set to false so the UUID filename is used as-is. The original filename is kept in the database name field for display.
Response
200 — Success
Returns a JSON object confirming success and the full persistedFileItem record.
Always
true on a successful upload.The full database record created for the uploaded file.
Error Responses
| Status | Error message | Cause |
|---|---|---|
400 | "File is required" | The file field is missing from the form data. |
400 | "Only images and PDF files are supported" | The uploaded file’s MIME type is not image/* or application/pdf. |
401 | "Unauthorized" | No active Clerk session, or userId form field doesn’t match the session user. |
404 | "Parent folder not found" | The provided parentId doesn’t exist, isn’t a folder, or isn’t owned by user. |
503 | "File upload service error" | ImageKit threw an error during the upload operation. |
500 | "Failed to upload file" | Unexpected server or database error. |