Skip to main content
App variables let you control your application’s behavior remotely. By setting boolean or string values in the dashboard, you can toggle features on or off for all users without deploying a new build.

How it works

  1. Set variables in the dashboard or via the API.
  2. The SDK receives them during authentication.
  3. Your app reads the variables and enables or disables features accordingly.

Setup

1. Define your flags

In the dashboard, go to your app’s Settings → Variables and set your flags:
{
  "newDashboard": false,
  "betaFeatures": true,
  "maxUploadSizeMb": 50,
  "maintenanceMode": false,
  "motd": ""
}
Or via the API:
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/variables \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "newDashboard": false,
    "betaFeatures": true,
    "maxUploadSizeMb": 50,
    "maintenanceMode": false,
    "motd": ""
  }'

2. Read flags in your app

if client.login(license_key):
    flags = client.app_variables

    # Kill switch
    if flags.get("maintenanceMode"):
        print("Application is under maintenance. Please try again later.")
        exit(0)

    # Message of the day
    motd = flags.get("motd", "")
    if motd:
        print(f"Notice: {motd}")

    # Feature toggle
    if flags.get("newDashboard"):
        show_new_dashboard()
    else:
        show_classic_dashboard()

    # Config value
    max_upload = int(flags.get("maxUploadSizeMb", 25))
    configure_upload_limit(max_upload)

3. Toggle remotely

When you’re ready to enable a feature, update the variable in the dashboard or via the API:
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/variables \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "newDashboard": true,
    "betaFeatures": true,
    "maxUploadSizeMb": 50,
    "maintenanceMode": false,
    "motd": "New dashboard is live!"
  }'
Users pick up the change the next time they authenticate (restart the app or the SDK re-validates in LOCAL mode).

Practical patterns

Kill switch / maintenance mode

Disable your app remotely without revoking licenses:
if flags.get("maintenanceMode"):
    show_maintenance_screen()
    exit(0)

Minimum version enforcement

Block outdated clients:
import packaging.version

min_ver = flags.get("minVersion")
if min_ver and packaging.version.parse(APP_VERSION) < packaging.version.parse(min_ver):
    print(f"Please update to version {min_ver} or later.")
    show_update_dialog()
    exit(0)

Gradual rollout

Use a percentage-based approach with the license key as a seed:
import hashlib

rollout_pct = int(flags.get("newFeatureRolloutPct", 0))
user_hash = int(hashlib.md5(license_key.encode()).hexdigest(), 16) % 100

if user_hash < rollout_pct:
    enable_new_feature()

A/B testing

Assign users to groups based on their license key hash and configure behavior per group:
group = "A" if int(hashlib.md5(license_key.encode()).hexdigest(), 16) % 2 == 0 else "B"
theme = flags.get(f"theme_{group}", "default")

Limitations

  • Variables are delivered at authentication time, not real-time. Changes take effect on next login.
  • Max 50 keys, 4 KB total. For complex configuration, use a URL variable pointing to your own config endpoint.
  • Values are flat (string/number/boolean). No nested objects or arrays.

Next steps