Documentation
API Reference
Storage

Storage API

Upload and manage files.

Base URL

https://api.moontraze.com/api

Upload File

POST /api/storage/:projectId/upload
Authorization: Bearer <token>
Content-Type: multipart/form-data
 
file: <binary>
folderId: <optional>

List Files

GET /api/storage/:projectId/files
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

List Files in Folder

GET /api/storage/:projectId/files?folderId=FOLDER_ID
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Get Presigned URL

GET /api/storage/:projectId/files/:fileId/presign?download=true
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Delete File

DELETE /api/storage/:projectId/files/:fileId
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Create Folder

POST /api/storage/:projectId/folders
Authorization: Bearer <token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "name": "My Folder",
  "parentId": null
}

List Folders

GET /api/storage/:projectId/folders
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Delete Folder

DELETE /api/storage/:projectId/folders/:folderId
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Get Storage Quota

GET /api/storage/:projectId/quota
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Public File URL

https://api.moontraze.com/storage/:projectId/path/to/file.webp
https://api.moontraze.com/storage/:projectId/path/to/file.webp?download=true

SDK Example

const file = document.getElementById('file').files[0];
const result = await moon.storage.upload(file);
console.log(result.publicUrl);
 
const files = await moon.storage.list();
const folders = await moon.storage.listFolders();
await moon.storage.createFolder('My Folder');
const url = await moon.storage.getDownloadUrl(fileId);
await moon.storage.delete(fileId);
await moon.storage.deleteFolder(folderId);
const quota = await moon.storage.getQuota();