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.
/files/upload
Upload a file to storage.
Request Body (form-data)
| Field | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The file to upload |
folder | string | No | Folder name (default: "default") |
metadata | JSON | No | Custom 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"
}
}
/files
Get a paginated list of your files.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
folder | string | - | Filter by folder name |
limit | number | 20 | Max items per page (max: 100) |
offset | number | 0 | Skip items for pagination |
sortBy | string | createdAt | Sort field: createdAt, fileName, fileSize |
sortOrder | string | desc | Sort 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
}
}
/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
}
}
/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.
/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"
}
/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"
}
}
/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}
}
}
}
/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..."
}
}
/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_AUTHENTICATED | 401 | Missing or invalid API key |
INVALID_CREDENTIALS | 401 | Wrong email/password |
FILE_NOT_FOUND | 404 | File doesn't exist or was deleted |
QUOTA_EXCEEDED | 413 | Storage or file size limit exceeded |
RATE_LIMITED | 429 | Too many requests |
UPLOAD_ERROR | 500 | Upload failed |
DOWNLOAD_ERROR | 500 | Download failed |
Rate Limits
| Tier | Requests/Minute |
|---|---|
| Free | 60 |
| Pro | 120 |
| Business | 300 |
| Enterprise | Unlimited |
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 |
|---|---|---|
| Free | 50 MB | Bot API |
| Pro | 2 GB | Bot API (Local Server) |
| Business | 4 GB | MTProto |
| Enterprise | 4 GB | MTProto |