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.
POST /api/folders/create creates a new folder record in the Storx database for the authenticated user. Folders share the same files table as regular files, distinguished by the isFolder: true flag. No file is uploaded to storage — only a database record is created.
Request
| Property | Value |
|---|---|
| Method | POST |
| Path | /api/folders/create |
| Auth | Clerk session required |
| Content-Type | application/json |
Body Parameters
Display name for the folder. Must be a non-empty string. Leading and trailing
whitespace is trimmed before the record is saved.
The Clerk user ID of the requesting user. Must exactly match the authenticated
session’s user ID — a mismatch returns
401 Unauthorized.UUID of the parent folder to nest this folder under. Pass
null (or omit the
field) to create a root-level folder. When provided, the API verifies that the
parent exists, belongs to the authenticated user, and is itself a folder.Behavior
- Authentication check — Reads the Clerk session. Returns
401if no session is present. - User ID validation — Compares
body.userIdagainst the sessionuserId. Returns401if they do not match. - Name validation — Verifies that
nameis a non-empty string after trimming. Returns400if the check fails. - Parent folder verification — When
parentIdis provided, queries thefilestable for a record matchingid = parentId,userId = userId, andisFolder = true. Returns404if no such record is found. - Record creation — Inserts a row into the
filestable with the following fixed values:isFolder: truesize: 0type: "folder"fileUrl: ""thumbnailUrl: nullimagekitFileId: nullisStarred: falseisTrash: false- A
pathof the form/folder/<userId>/<uuid>.
Response
200 — Success
Always
true on a successful response.Human-readable confirmation string:
"folder created successfully".The newly created folder record returned directly from the database.
Error Responses
| Status | Error message | Cause |
|---|---|---|
400 | folder name is required | name is missing, not a string, or is an empty / whitespace-only string. |
401 | unauthorized | No active Clerk session, or body.userId does not match the authenticated session ID. |
404 | Parent folder not found | parentId was provided but no matching folder exists for this user. |
500 | Internal Server Error | An unexpected database or runtime error occurred. |
Examples
Creating a nested folder
To create a folder inside an existing folder, pass the parent folder’s UUID asparentId:
Folders can be nested to any depth. The API only validates the immediate
parent — it does not traverse the full ancestor chain.