API Documentation

RESTful API reference for integrating mobile applications with ERP Mobile Bridge.

Overview

The ERP Mobile Bridge API provides endpoints for mobile applications to retrieve app settings, check for updates, manage device tokens, and fetch content.

Base URL
https://yourdomain.com/api
Response Format

All API responses are in JSON format with the following structure:

{
    "status": "success|error",
    "message": "Human-readable message",
    "data": { /* Response data */ }
}
Note: All endpoints use GET or POST methods and return JSON responses.

Authentication

Currently, the API endpoints are publicly accessible and do not require authentication. Device tokens are used to identify unique devices for push notifications.

Security: Consider implementing API authentication for production environments if needed.

App Settings

GET Get App Settings

/api/app-settings
Description

Retrieve complete app configuration including branding, colors, features, and URLs.

Response Example
{
    "status": "success",
    "message": "App settings retrieved successfully",
    "data": {
        "app_name": "ERP Mobile Bridge",
        "package_name": "com.web2app.pro",
        "platform": "both",
        "website_url": "https://example.com",
        "app_logo_url": "https://yourdomain.com/storage/logos/app-logo.png",
        "splash_logo_url": "https://yourdomain.com/storage/logos/splash-logo.png",
        "primary_color": "#2196f3",
        "secondary_color": "#ffc107",
        "pull_to_refresh": true,
        "exit_popup": true,
        "hide_header": false,
        "hide_footer": false,
        "share_message": "Check out this amazing app!",
        "offline_message": "No internet connection.",
        "maintenance_mode": false
    }
}
Response Fields
Field Type Description
app_name string Application name
package_name string App package identifier
platform string Target platform: "both", "android", or "ios"
website_url string Website URL to load in app
app_logo_url string|null Full URL to app logo
splash_logo_url string|null Full URL to splash screen logo
primary_color string Primary brand color (hex)
secondary_color string Secondary brand color (hex)
pull_to_refresh boolean Enable pull-to-refresh feature
exit_popup boolean Show exit confirmation dialog
hide_header boolean Hide app header/toolbar
hide_footer boolean Hide app footer/navigation
share_message string|null Message for app sharing
offline_message string|null Message when offline
maintenance_mode boolean App in maintenance mode

App Versions

GET Check App Version

/api/app-versions/check
Description

Check if an app update is available for a specific platform and version.

Query Parameters
Parameter Type Required Description
platform string Yes "android" or "ios"
version_code integer Yes Current app version code
Request Example
GET /api/app-versions/check?platform=android&version_code=1
Response Example (Update Available)
{
    "status": "success",
    "message": "Update available",
    "data": {
        "update_available": true,
        "latest_version": {
            "version_name": "2.0.0",
            "version_code": 2,
            "release_notes": "Bug fixes and performance improvements",
            "force_update": false
        }
    }
}
Response Example (No Update)
{
    "status": "success",
    "message": "App is up to date",
    "data": {
        "update_available": false,
        "latest_version": null
    }
}

Pages

GET Get All Pages

/api/pages
Description

Retrieve all published pages.

Response Example
{
    "status": "success",
    "message": "Pages retrieved successfully",
    "data": [
        {
            "id": 1,
            "title": "About Us",
            "slug": "about-us",
            "content": "<h1>About Us</h1><p>...</p>",
            "status": "published",
            "created_at": "2025-12-28T10:00:00.000000Z"
        }
    ]
}

GET Get Single Page

/api/pages/{slug}
Description

Retrieve a specific page by its slug.

URL Parameters
Parameter Type Description
slug string Page slug (e.g., "about-us")
Request Example
GET /api/pages/about-us
Response Example
{
    "status": "success",
    "message": "Page retrieved successfully",
    "data": {
        "id": 1,
        "title": "About Us",
        "slug": "about-us",
        "content": "<h1>About Us</h1><p>Company description...</p>",
        "status": "published",
        "created_at": "2025-12-28T10:00:00.000000Z"
    }
}

Onboarding

GET Get Onboarding Screens

/api/onboarding
Description

Retrieve all active onboarding screens ordered by sequence.

Response Example
{
    "status": "success",
    "message": "Onboarding screens retrieved successfully",
    "data": [
        {
            "id": 1,
            "title": "Welcome",
            "description": "Welcome to our amazing app!",
            "image_url": "https://yourdomain.com/storage/onboarding/screen1.png",
            "order": 1,
            "status": "active"
        },
        {
            "id": 2,
            "title": "Features",
            "description": "Discover powerful features",
            "image_url": "https://yourdomain.com/storage/onboarding/screen2.png",
            "order": 2,
            "status": "active"
        }
    ]
}
Response Fields
Field Type Description
id integer Screen ID
title string Screen title
description string Screen description
image_url string|null Full URL to screen image
order integer Display order
status string "active" or "inactive"

Device Tokens

POST Register Device Token

/api/device-tokens
Description

Register or update a device token for push notifications.

Request Body
Field Type Required Description
token string Yes FCM device token
platform string Yes "android" or "ios"
device_id string No Unique device identifier
Request Example
POST /api/device-tokens
Content-Type: application/json

{
    "token": "fcm_token_here",
    "platform": "android",
    "device_id": "unique_device_id"
}
Response Example
{
    "status": "success",
    "message": "Device token registered successfully",
    "data": {
        "id": 1,
        "token": "fcm_token_here",
        "platform": "android",
        "device_id": "unique_device_id",
        "is_active": true
    }
}

DELETE Delete Device Token

/api/device-tokens/{token}
Description

Remove a device token (e.g., when user logs out or uninstalls).

URL Parameters
Parameter Type Description
token string FCM device token to delete
Request Example
DELETE /api/device-tokens/fcm_token_here
Response Example
{
    "status": "success",
    "message": "Device token deleted successfully",
    "data": null
}

Error Handling

Error Response Format

When an error occurs, the API returns a JSON response with error details:

{
    "status": "error",
    "message": "Error description",
    "error": "Detailed error message (in development mode)"
}

HTTP Status Codes

Code Status Description
200 OK Request successful
201 Created Resource created successfully
400 Bad Request Invalid request parameters
404 Not Found Resource not found
422 Unprocessable Entity Validation error
500 Internal Server Error Server error occurred

Common Error Examples

Validation Error (422)

{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "token": ["The token field is required."],
        "platform": ["The platform must be android or ios."]
    }
}

Not Found (404)

{
    "status": "error",
    "message": "Page not found",
    "data": null
}

Server Error (500)

{
    "status": "error",
    "message": "Failed to retrieve app settings",
    "error": "Database connection error"
}

Integration Examples

JavaScript/React Native Example

// Fetch app settings
async function getAppSettings() {
    try {
        const response = await fetch('https://yourdomain.com/api/app-settings');
        const data = await response.json();
        
        if (data.status === 'success') {
            console.log('App Settings:', data.data);
            return data.data;
        }
    } catch (error) {
        console.error('Error fetching settings:', error);
    }
}

// Register device token
async function registerDeviceToken(fcmToken, platform) {
    try {
        const response = await fetch('https://yourdomain.com/api/device-tokens', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                token: fcmToken,
                platform: platform,
                device_id: 'unique_device_id'
            })
        });
        
        const data = await response.json();
        console.log('Token registered:', data);
    } catch (error) {
        console.error('Error registering token:', error);
    }
}

// Check for updates
async function checkForUpdate(platform, versionCode) {
    try {
        const response = await fetch(
            `https://yourdomain.com/api/app-versions/check?platform=${platform}&version_code=${versionCode}`
        );
        const data = await response.json();
        
        if (data.data.update_available) {
            console.log('Update available:', data.data.latest_version);
            // Show update dialog
        }
    } catch (error) {
        console.error('Error checking update:', error);
    }
}

Flutter/Dart Example

import 'dart:convert';
import 'package:http/http.dart' as http;

// Fetch app settings
Future> getAppSettings() async {
  final response = await http.get(
    Uri.parse('https://yourdomain.com/api/app-settings'),
  );
  
  if (response.statusCode == 200) {
    final data = json.decode(response.body);
    return data['data'];
  } else {
    throw Exception('Failed to load app settings');
  }
}

// Register device token
Future registerDeviceToken(String token, String platform) async {
  final response = await http.post(
    Uri.parse('https://yourdomain.com/api/device-tokens'),
    headers: {'Content-Type': 'application/json'},
    body: json.encode({
      'token': token,
      'platform': platform,
      'device_id': 'unique_device_id',
    }),
  );
  
  if (response.statusCode == 200) {
    print('Token registered successfully');
  }
}
API Best Practices
  • Cache app settings locally to reduce API calls
  • Implement retry logic for failed requests
  • Handle offline scenarios gracefully
  • Update device tokens when they change
  • Check for app updates on app launch
  • Use HTTPS for all API communications