← Back to Home

API Documentation

Complete reference for the Mobcraft Storage API

Base URL: https://storage.mobcraft.in/api/v1

Authentication

All API endpoints require an API key passed via the X-API-Key header.

curl -H "X-API-Key: msk_your_api_key_here" \
     https://api.example.com/api/v1/files

Note: Keep your API keys secure. Never expose them in client-side code or public repositories.

POST /files/upload

Upload a file to storage.

Request Body (form-data)

Field Type Required Description
fileFileYesThe file to upload
folderstringNoFolder name (default: "default")
metadataJSONNoCustom metadata object

Example

curl -X POST https://storage.mobcraft.in/api/v1/files/upload \
  -H "X-API-Key: msk_your_key" \
  -F "file=@/path/to/image.jpg" \
  -F "folder=photos"

Response

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "fileName": "image.jpg",
    "fileSize": 1024000,
    "mimeType": "image/jpeg",
    "folder": "photos",
    "downloadUrl": "/api/v1/files/.../download",
    "createdAt": "2024-01-15T10:30:00Z"
  }
}
GET /files

Get a paginated list of your files.

Query Parameters

Parameter Type Default Description
folderstring-Filter by folder name
limitnumber20Max items per page (max: 100)
offsetnumber0Skip items for pagination
sortBystringcreatedAtSort field: createdAt, fileName, fileSize
sortOrderstringdescSort order: asc or desc

Example

curl -X GET "https://storage.mobcraft.in/api/v1/files?folder=photos&limit=10" \
  -H "X-API-Key: msk_your_key"

Response

{
  "success": true,
  "data": {
    "items": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "file_name": "image.jpg",
        "file_size": 1024000,
        "mime_type": "image/jpeg",
        "folder": "photos",
        "created_at": "2024-01-15T10:30:00Z"
      }
    ],
    "total": 50,
    "limit": 10,
    "offset": 0,
    "hasMore": true
  }
}
GET /files/:fileId

Get metadata for a specific file.

Example

curl -X GET "https://storage.mobcraft.in/api/v1/files/550e8400-..." \
  -H "X-API-Key: msk_your_key"

Response

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "fileName": "image.jpg",
    "fileSize": 1024000,
    "mimeType": "image/jpeg",
    "folder": "photos",
    "metadata": {"description": "My photo"},
    "createdAt": "2024-01-15T10:30:00Z",
    "expiresAt": null
  }
}
GET /files/:fileId/download

Download a file. Returns the file content or redirects to download URL.

Example

# Download to file
curl -X GET "https://storage.mobcraft.in/api/v1/files/550e8400-.../download" \
  -H "X-API-Key: msk_your_key" \
  -o downloaded_file.jpg

# Or with query parameter (for browser/iframe)
https://storage.mobcraft.in/api/v1/files/550e8400-.../download?apiKey=msk_your_key

Response

Returns 302 Redirect to download URL, or 200 OK with file content.

DELETE /files/:fileId

Delete a file (soft delete).

Example

curl -X DELETE "https://storage.mobcraft.in/api/v1/files/550e8400-..." \
  -H "X-API-Key: msk_your_key"

Response

{
  "success": true,
  "message": "File deleted successfully"
}
GET /quota

Get your current storage quota and usage.

Example

curl -X GET "https://storage.mobcraft.in/api/v1/quota" \
  -H "X-API-Key: msk_your_key"

Response

{
  "success": true,
  "data": {
    "tier": "free",
    "storageUsed": 524288000,
    "storageLimit": 2147483648,
    "storageUsedFormatted": "500 MB",
    "storageLimitFormatted": "2 GB",
    "storagePercentage": 24,
    "filesCount": 15,
    "fileSizeLimit": 52428800,
    "fileSizeLimitFormatted": "50 MB"
  }
}
GET /quota/usage

Get detailed usage statistics by folder and month.

Example

curl -X GET "https://storage.mobcraft.in/api/v1/quota/usage" \
  -H "X-API-Key: msk_your_key"

Response

{
  "success": true,
  "data": {
    "totalUsed": 524288000,
    "totalUsedFormatted": "500 MB",
    "filesCount": 15,
    "byFolder": {
      "photos": {"used": 300000000, "count": 10},
      "documents": {"used": 224288000, "count": 5}
    },
    "byMonth": {
      "2024-01": {"used": 524288000, "count": 15}
    }
  }
}
POST /auth/register

Create a new account.

Request Body

{
  "email": "user@example.com",
  "password": "securepassword123",
  "name": "John Doe"
}

Response

{
  "success": true,
  "data": {
    "user": {"id": "...", "email": "user@example.com", "name": "John Doe"},
    "token": "abc123...",
    "apiKey": "msk_abc123..."
  }
}
POST /auth/login

Login with email and password.

Request Body

{
  "email": "user@example.com",
  "password": "securepassword123"
}

Response

{
  "success": true,
  "data": {
    "user": {"id": "...", "email": "user@example.com", "name": "John Doe"},
    "token": "abc123...",
    "apiKey": "msk_abc123..."
  }
}

Error Codes

All errors return a consistent format:

{
  "error": "Error message description",
  "code": "ERROR_CODE"
}
Code HTTP Status Description
NOT_AUTHENTICATED401Missing or invalid API key
INVALID_CREDENTIALS401Wrong email/password
FILE_NOT_FOUND404File doesn't exist or was deleted
QUOTA_EXCEEDED413Storage or file size limit exceeded
RATE_LIMITED429Too many requests
UPLOAD_ERROR500Upload failed
DOWNLOAD_ERROR500Download failed

Rate Limits

Tier Requests/Minute
Free60
Pro120
Business300
EnterpriseUnlimited

Rate limit headers are included in responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset

File Size Limits

Tier Max File Size Storage Method
Free50 MBBot API
Pro2 GBBot API (Local Server)
Business4 GBMTProto
Enterprise4 GBMTProto