Skip to main content

Feature Flags API

The Feature Flags API documentation is being developed. Feature flags are typically managed through the Mixpanel UI.For programmatic feature flag evaluation, use the Mixpanel SDKs which provide built-in support for:
  • Evaluating flag values for users
  • Tracking flag exposure events
  • A/B testing and experimentation

Using Feature Flags

While there isn’t a dedicated REST API for managing feature flags, you can:
  1. Define flags in the UI: Create and configure feature flags in Project Settings
  2. Evaluate with SDKs: Use Mixpanel JavaScript, Python, or other SDKs to evaluate flags
  3. Track with Events: Flag evaluations are automatically tracked as events

Example with JavaScript SDK

// Initialize with feature flags enabled
mixpanel.init('YOUR_PROJECT_TOKEN', {
    loaded: function(mixpanel) {
        // Get flag value
        const showNewFeature = mixpanel.get_feature_flag('new-checkout-flow');
        
        if (showNewFeature) {
            // Show new feature
            renderNewCheckoutFlow();
        } else {
            // Show old feature
            renderOldCheckoutFlow();
        }
    }
});

Example with Python SDK

from mixpanel import Mixpanel

mp = Mixpanel('YOUR_PROJECT_TOKEN')

# Evaluate feature flag
flag_value = mp.get_feature_flag('new-feature', 'user123')

if flag_value:
    # Feature is enabled for this user
    enable_new_feature()

Best Practices

Use kebab-case for flag names:
  • new-checkout-flow
  • enable-dark-mode
  • experiment-pricing-v2
Mixpanel SDKs automatically track when flags are evaluated, helping you understand:
  • Which users see which variants
  • Impact of feature flags on key metrics
  • A/B test results
Remove flags from code once features are fully rolled out:
// Before: Feature flag
if (mixpanel.get_feature_flag('new-feature')) {
    renderNewFeature();
} else {
    renderOldFeature();
}

// After: Feature fully rolled out
renderNewFeature();

SDK Documentation

For detailed information on using feature flags, see the SDK-specific documentation:

Build docs developers (and LLMs) love