Back to API Overview

Files API

Upload, download, and manage files and folders. Get storage usage statistics.

15 endpoints

Endpoints

POST
/api/v1/files/list

List user files. Optional params: folderId (filter by folder, use "root" for root level), conversationId, sortBy ("uploadedAt", "size", "fileName"), sortOrder ("asc", "desc"), limit, offset. Returns {files[], total}.

Parameters

conversationIdstring

Filter by conversation ID

folderIdstring

Filter by folder ID. Use "root" for root level

sortBystring

Sort field: "uploadedAt", "size", or "fileName"

sortOrderstring

Sort order: "asc" or "desc"

limitnumber

Max files to return (1-100, default: 50)

offsetnumber

Number of files to skip for pagination

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/list \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "conversationId": "example",
  "folderId": "example",
  "sortBy": "example"
}'
POST
/api/v1/files/get

Get a specific file by ID

Parameters

fileIdstringrequired

File ID from list

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/get \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example"
}'
POST
/api/v1/files/getDownloadUrl

Get a presigned download URL for a file (1 hour expiry)

Parameters

fileIdstringrequired

File ID from list

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/getDownloadUrl \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example"
}'
POST
/api/v1/files/delete

Delete a file (move to trash)

Parameters

fileIdstringrequired

File ID to delete

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/delete \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example"
}'
POST
/api/v1/files/rename

Rename a file

Parameters

fileIdstringrequired

File ID to rename

newNamestringrequired

New file name

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/rename \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example",
  "newName": "example"
}'
POST
/api/v1/files/move

Move a file to a different folder

Parameters

fileIdstringrequired

File ID to move

folderIdstringrequired

Target folder ID, or null for root

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/move \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example",
  "folderId": "example"
}'
POST
/api/v1/files/listFolders

List folders. Optional param "parentId" (null for root level folders). Returns array with id, name, parentId.

Parameters

parentIdstring

Parent folder ID, or null for root level

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/listFolders \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "parentId": "example"
}'
POST
/api/v1/files/createFolder

Create a new folder

Parameters

namestringrequired

Folder name

parentIdstring

Parent folder ID, or null for root

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/createFolder \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "example",
  "parentId": "example"
}'
POST
/api/v1/files/renameFolder

Rename a folder

Parameters

folderIdstringrequired

Folder ID to rename

newNamestringrequired

New folder name

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/renameFolder \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "folderId": "example",
  "newName": "example"
}'
POST
/api/v1/files/deleteFolder

Delete an empty folder

Parameters

folderIdstringrequired

Folder ID to delete. Folder must be empty.

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/deleteFolder \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "folderId": "example"
}'
POST
/api/v1/files/getUsage

Get storage stats. No params. Returns {totalSize (bytes), fileCount}.

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/getUsage \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{}'
POST
/api/v1/files/setAccessRules

Set access rules for a file. Controls who can create/read/delete files in published apps.

Parameters

fileIdstringrequired

File ID from list

accessRulesobjectrequired

Access rules per operation

trackCreatorboolean

Whether to track who uploads each file (default: true)

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/setAccessRules \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example",
  "accessRules": {},
  "trackCreator": true
}'
POST
/api/v1/files/getAccessRules

Get access rules for a file

Parameters

fileIdstringrequired

File ID from list

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/getAccessRules \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileId": "example"
}'
POST
/api/v1/files/getQuota

Get storage quota info. Returns usedBytes, limitBytes, availableBytes, maxFileSizeBytes, percentUsed. Call BEFORE upload to check available space.

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/getQuota \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{}'
POST
/api/v1/files/upload

Upload a file. Content must be base64 encoded. Check getQuota first for available space.

Parameters

fileNamestringrequired

Original file name with extension

contentstringrequired

Base64 encoded file content

mimeTypestring

MIME type (auto-detected if not provided)

folderIdstring

Target folder ID, or null for root

Example Request

curl -X POST https://app.serenitiesai.com/api/v1/files/upload \
  -H "Authorization: Bearer mk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "fileName": "example",
  "content": "example",
  "mimeType": "example"
}'