> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/mixpanel/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Feature Flags

> Manage feature flags programmatically

# Feature Flags API

<Note>
  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
</Note>

## 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

<CodeGroup>
  ```javascript JavaScript theme={null}
  // 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();
          }
      }
  });
  ```
</CodeGroup>

### Example with Python SDK

<CodeGroup>
  ```python Python theme={null}
  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()
  ```
</CodeGroup>

## Best Practices

<AccordionGroup>
  <Accordion title="Use consistent flag naming">
    Use kebab-case for flag names:

    * `new-checkout-flow`
    * `enable-dark-mode`
    * `experiment-pricing-v2`
  </Accordion>

  <Accordion title="Track flag evaluations">
    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
  </Accordion>

  <Accordion title="Clean up old flags">
    Remove flags from code once features are fully rolled out:

    ```javascript theme={null}
    // Before: Feature flag
    if (mixpanel.get_feature_flag('new-feature')) {
        renderNewFeature();
    } else {
        renderOldFeature();
    }

    // After: Feature fully rolled out
    renderNewFeature();
    ```
  </Accordion>
</AccordionGroup>

## SDK Documentation

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

* [JavaScript SDK](https://developer.mixpanel.com/docs/javascript)
* [Python SDK](https://developer.mixpanel.com/docs/python)
* [iOS SDK](https://developer.mixpanel.com/docs/swift)
* [Android SDK](https://developer.mixpanel.com/docs/android)
