Version Control & Feature Flags

Force app updates and control feature availability

Version Control API

Force users to update their app to a minimum version

POST /api/version-check

Check if the current app version requires an update. Returns update requirements and information.

Endpoint:
/api/version-check
Example Request:
curl -X POST https://api.wecompleteapp.com/api/version-check \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "ios",
    "currentVersion": "1.0.5",
    "currentBuildNumber": 105,
    "userId": "USER_ID",
    "deviceInfo": {
      "os": "iOS",
      "osVersion": "17.2",
      "deviceModel": "iPhone 15 Pro",
      "appVersion": "1.0.5"
    }
  }'
Example Response:
{
  "updateRequired": true,
  "updateRecommended": false,
  "canContinue": false,
  "updateType": "required",
  "currentVersion": "1.0.5",
  "minRequiredVersion": "1.1.0",
  "recommendedVersion": "1.2.0",
  "latestVersion": "1.2.0",
  "updateMessage": "Please update to the latest version to continue using the app.",
  "releaseNotes": "Bug fixes and performance improvements",
  "downloadUrl": "https://apps.apple.com/app/...",
  "deprecationDate": 1735689600000
}

GET /api/version-check

Check app version using query parameters (alternative to POST).

Endpoint:
/api/version-check
Example Request:
GET https://api.wecompleteapp.com/api/version-check?platform=ios&version=1.0.5&buildNumber=105&userId=USER_ID
Headers:
  Content-Type: application/json
Example Response:
{
  "updateRequired": false,
  "updateRecommended": true,
  "canContinue": true,
  "updateType": "recommended",
  "currentVersion": "1.0.5",
  "minRequiredVersion": "1.0.0",
  "recommendedVersion": "1.1.0",
  "latestVersion": "1.2.0",
  "updateMessage": "A new version is available with exciting new features!",
  "downloadUrl": "https://apps.apple.com/app/..."
}

📱 Version Control Usage:

Update Types:
- optional - User can skip the update
- recommended - Show update prompt but allow skip
- required - Must update to continue using app

Response Fields:
- updateRequired - If true, user MUST update
- updateRecommended - If true, show update prompt
- canContinue - If false, block app usage
- downloadUrl - Link to App Store/Play Store

Version Format:
- Semantic versioning: MAJOR.MINOR.PATCH (e.g., "1.2.3")
- Build numbers are optional but recommended

Feature Flags API

Control feature availability with server-side flags

GET /api/feature-flags?flag=FEATURE_KEY

Check if a specific feature flag is enabled for a user.

Endpoint:
/api/feature-flags?flag=FEATURE_KEY&userId=USER_ID&platform=ios
Example Request:
GET https://api.wecompleteapp.com/api/feature-flags?flag=new_games_module&userId=USER_ID&platform=ios
Headers:
  Content-Type: application/json
Example Response:
{
  "enabled": true,
  "message": "Feature is enabled",
  "flagKey": "new_games_module",
  "flag": {
    "name": "New Games Module",
    "description": "Access to the new games feature"
  }
}

GET /api/feature-flags?action=list

Get all enabled feature flags for a user.

Endpoint:
/api/feature-flags?action=list&userId=USER_ID&platform=ios
Example Request:
GET https://api.wecompleteapp.com/api/feature-flags?action=list&userId=USER_ID&platform=ios
Headers:
  Content-Type: application/json
Example Response:
{
  "userId": "USER_ID",
  "enabledFlags": [
    "new_games_module",
    "premium_sharing",
    "enhanced_notifications"
  ],
  "platform": "ios"
}

POST /api/feature-flags (create/update)

Create or update a feature flag (Admin only).

Endpoint:
/api/feature-flags
Example Request:
curl -X POST https://api.wecompleteapp.com/api/feature-flags \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create",
    "key": "new_games_module",
    "name": "New Games Module",
    "description": "Access to the new games feature",
    "isEnabled": true,
    "enabledForPremium": false,
    "rolloutPercentage": 50,
    "platforms": ["ios", "android"],
    "createdBy": "admin@example.com"
  }'
Example Response:
{
  "success": true,
  "created": true,
  "flagId": "FLAG_ID",
  "message": "Feature flag 'new_games_module' created successfully"
}

POST /api/feature-flags (toggle)

Toggle a feature flag on/off (Admin only).

Endpoint:
/api/feature-flags
Example Request:
curl -X POST https://api.wecompleteapp.com/api/feature-flags \
  -H "Content-Type: application/json" \
  -d '{
    "action": "toggle",
    "flagKey": "new_games_module",
    "isEnabled": false
  }'
Example Response:
{
  "success": true,
  "flagKey": "new_games_module",
  "isEnabled": false,
  "message": "Feature flag 'new_games_module' disabled"
}

🚀 Feature Flags Usage:

Flag Configuration:
- isEnabled - Global on/off switch
- enabledForPremium - Only for premium users
- enabledForUserIds - Whitelist specific users (beta testing)
- disabledForUserIds - Blacklist specific users
- rolloutPercentage - Gradual rollout (0-100%)
- platforms - Platform restrictions (ios, android, web)

Use Cases:
- Beta testing new features with select users
- Gradual feature rollout (A/B testing)
- Premium-only features
- Platform-specific features
- Emergency feature disable (kill switch)