Mobile API Endpoints

Specialized API endpoints designed for mobile applications with support for offline sync, background uploads, and push notifications.

Mobile API Overview

The Mobile API provides specialized endpoints optimized for mobile applications, including features like background sync, offline support, and push notifications.

Mobile Optimized

Designed for mobile apps

  • ✅ Reduced payload sizes
  • ✅ Battery-efficient operations
  • ✅ Network-aware uploads
  • ✅ Chunked file transfers

Offline Support

Work without internet

  • ✅ Local data caching
  • ✅ Conflict resolution
  • ✅ Sync when online
  • ✅ Queue management

Background Operations

Seamless experience

  • ✅ Background uploads
  • ✅ Auto-sync scheduling
  • ✅ Progress tracking
  • ✅ Retry mechanisms
💡

Mobile SDK

Use the official Flutter SDK for MegaVault to automatically handle mobile-specific authentication, caching, and sync operations.

Mobile Authentication

Mobile-specific authentication endpoints with device registration and management.

Device Registration

Request
POST /api/mobile/auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "securepassword123",
  "deviceInfo": {
    "platform": "android",
    "model": "Pixel 7",
    "osVersion": "14",
    "appVersion": "1.2.0",
    "deviceId": "device_unique_identifier",
    "pushToken": "fcm_token_here"
  }
}
Success Response (200)
{
  "success": true,
  "user": {
    "id": "user_123456789",
    "email": "user@example.com",
    "name": "John Doe"
  },
  "tokens": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "rt_mobile_abc123def456...",
    "expiresIn": "7d"
  },
  "device": {
    "id": "device_987654321",
    "name": "John's Pixel 7",
    "registeredAt": "2024-01-20T15:30:00Z"
  },
  "syncData": {
    "lastSyncAt": null,
    "pendingUploads": 0,
    "cacheSize": 0
  }
}

Mobile Token Refresh

Request
POST /api/mobile/auth/refresh
Content-Type: application/json

{
  "refreshToken": "rt_mobile_abc123def456...",
  "deviceId": "device_unique_identifier"
}

File Synchronization

Efficient file synchronization with delta updates and conflict resolution.

Get Sync Status

Request
GET /api/mobile/sync/status?lastSync=2024-01-20T10:00:00Z
Authorization: Bearer MOBILE_JWT_TOKEN
Success Response (200)
{
  "success": true,
  "data": {
    "lastSyncAt": "2024-01-20T14:30:00Z",
    "hasChanges": true,
    "changes": {
      "created": [
        {
          "id": "file_123",
          "name": "document.pdf",
          "folder": "/documents",
          "size": 1024576,
          "modifiedAt": "2024-01-20T12:00:00Z",
          "checksum": "sha256:abc123..."
        }
      ],
      "updated": [],
      "deleted": [
        {
          "id": "file_456",
          "deletedAt": "2024-01-20T13:15:00Z"
        }
      ]
    },
    "conflicts": [],
    "nextSyncToken": "sync_token_xyz789"
  }
}

Sync Files

Request
POST /api/mobile/sync/files
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "syncToken": "sync_token_xyz789",
  "localChanges": [
    {
      "action": "upload",
      "localId": "local_file_123",
      "name": "photo.jpg",
      "folder": "/photos",
      "size": 2048576,
      "checksum": "sha256:def456...",
      "lastModified": "2024-01-20T14:00:00Z"
    }
  ]
}

Background Upload

Upload files in the background with progress tracking and retry capabilities.

Initialize Upload

Request
POST /api/mobile/upload/init
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "files": [
    {
      "localId": "local_123",
      "name": "video.mp4",
      "size": 104857600,
      "mimeType": "video/mp4",
      "folder": "/videos",
      "checksum": "sha256:video_hash...",
      "priority": "high"
    }
  ],
  "uploadOptions": {
    "wifiOnly": true,
    "chunkSize": 1048576,
    "maxRetries": 3
  }
}
Success Response (200)
{
  "success": true,
  "data": {
    "uploadSession": "session_abc123def456",
    "files": [
      {
        "localId": "local_123",
        "uploadId": "upload_789",
        "uploadUrl": "https://api.example.com/api/mobile/upload/chunk",
        "chunks": [
          {
            "index": 0,
            "start": 0,
            "end": 1048575,
            "uploadUrl": "https://upload.example.com/chunk/0"
          }
        ],
        "totalChunks": 100
      }
    ],
    "expiresAt": "2024-01-20T18:30:00Z"
  }
}

Upload Progress

Request
POST /api/mobile/upload/progress
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "uploadId": "upload_789",
  "completedChunks": [0, 1, 2, 3],
  "bytesUploaded": 4194304,
  "status": "uploading"
}

Complete Upload

Request
POST /api/mobile/upload/complete
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "uploadId": "upload_789",
  "checksum": "sha256:final_hash...",
  "metadata": {
    "location": "37.7749,-122.4194",
    "capturedAt": "2024-01-20T14:30:00Z"
  }
}

Offline Support

APIs for managing offline data, conflict resolution, and sync queues.

Queue Operations

Add to Queue Request
POST /api/mobile/queue/add
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "operations": [
    {
      "id": "op_123",
      "type": "upload",
      "localPath": "/storage/photos/IMG_001.jpg",
      "remotePath": "/photos/IMG_001.jpg",
      "priority": "normal",
      "createdAt": "2024-01-20T15:00:00Z"
    },
    {
      "id": "op_124",
      "type": "delete",
      "fileId": "file_456",
      "priority": "low",
      "createdAt": "2024-01-20T15:01:00Z"
    }
  ]
}

Conflict Resolution

Resolve Conflicts Request
POST /api/mobile/conflicts/resolve
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "conflicts": [
    {
      "conflictId": "conflict_123",
      "resolution": "keep_remote",
      "fileId": "file_789"
    },
    {
      "conflictId": "conflict_124",
      "resolution": "keep_local",
      "fileId": "file_890",
      "localData": {
        "name": "updated_name.pdf",
        "modifiedAt": "2024-01-20T14:45:00Z"
      }
    }
  ]
}

Push Notifications

Manage push notifications for file activities, sharing, and system updates.

Register for Notifications

Request
POST /api/mobile/notifications/register
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "deviceId": "device_unique_identifier",
  "pushToken": "fcm_or_apns_token_here",
  "platform": "android",
  "preferences": {
    "uploads": true,
    "shares": true,
    "storage": true,
    "security": true,
    "quietHours": {
      "enabled": true,
      "start": "22:00",
      "end": "07:00",
      "timezone": "America/Los_Angeles"
    }
  }
}

Notification Categories

CategoryDescriptionExample
uploadsUpload completion or failures"Photo upload completed"
sharesFile sharing notifications"John shared a file with you"
storageStorage quota warnings"Storage 90% full"
securitySecurity-related alerts"New device login detected"

Device Management

Manage registered devices, sessions, and device-specific settings.

List Devices

Request
GET /api/mobile/devices
Authorization: Bearer MOBILE_JWT_TOKEN
Success Response (200)
{
  "success": true,
  "data": {
    "devices": [
      {
        "id": "device_123",
        "name": "John's iPhone",
        "platform": "ios",
        "model": "iPhone 15 Pro",
        "osVersion": "17.2",
        "appVersion": "1.2.0",
        "registeredAt": "2024-01-15T10:30:00Z",
        "lastActiveAt": "2024-01-20T14:30:00Z",
        "isCurrent": true,
        "settings": {
          "autoUpload": true,
          "backgroundSync": true,
          "wifiOnly": true
        }
      },
      {
        "id": "device_456",
        "name": "John's Pixel",
        "platform": "android",
        "model": "Pixel 7",
        "osVersion": "14",
        "appVersion": "1.1.5",
        "registeredAt": "2024-01-10T08:15:00Z",
        "lastActiveAt": "2024-01-19T16:45:00Z",
        "isCurrent": false,
        "settings": {
          "autoUpload": false,
          "backgroundSync": true,
          "wifiOnly": false
        }
      }
    ],
    "currentDevice": "device_123"
  }
}

Update Device Settings

Request
PUT /api/mobile/devices/device_123/settings
Authorization: Bearer MOBILE_JWT_TOKEN
Content-Type: application/json

{
  "autoUpload": true,
  "backgroundSync": true,
  "wifiOnly": true,
  "uploadQuality": "original",
  "syncFolders": ["/photos", "/documents"],
  "maxCacheSize": 1073741824
}

Remove Device

Request
DELETE /api/mobile/devices/device_456
Authorization: Bearer MOBILE_JWT_TOKEN
⚠️

Device Limit

Free accounts can register up to 3 devices. Pro accounts support up to 10 devices. Enterprise accounts have no device limits.