# Flipper Cloud > Feature flags for Ruby. Every Flipper docs page in one file. The index is at https://www.flippercloud.io/llms.txt. --- Source: https://www.flippercloud.io/docs/introduction # Get Started with Flipper > The official docs for the Flipper gem and Flipper Cloud. ## What is Flipper? {#what} Flipper is an open source library that provides simple, beautiful and performant feature flags for Ruby that makes it easy to... - **Safely isolate new and existing code**. Turning off a feature flag is always faster than another deploy. Similarly, sometimes you just want to turn something non-critical off and go back to bed. - **Get code into production faster**. Once a feature flag is in place and protecting your code, you can ship it to production. Productivity and quality increase when you work smaller. This is great for your mental health and customers. - **Release features your way**. Enable features for individual actors, specific groups of actors, a percentage of users, or a percentage of time. - **Get feedback faster**. Whether it's from a customer or a teammate, you can get feedback on features before they are fully released and iterate more quickly. Flipper Cloud is a platform built on Flipper that makes it easy to... - **Reduce stress and hassle**. Protect acccess to critical environments, roll back instantly and safely, and know who changed what and when. - **Keep feature flags organized**. Assign feature owners, organize features by project, environment and tag, and know when features are safe to delete. - **Relax with solid infrastructure**. Store data your way, evaluate flags local to your app, rest easy with backups, and keep multiple servers (and environments) in sync. ## How does it work? {#how} We have a beautiful web interface for managing your organizations, projects, environments and features. Additionally, we expose a simple HTTP API along with a client library that takes only a [few minutes](/docs/get-started) to integrate into your application. Also, it's important to note that we designed Cloud to [never take your app down](/blog/how-we-designed-flipper-cloud-to-never-take-your-app-down). When you create a project, it comes preloaded with a production environment and a personal environment for each developer to get you up and running quickly. But we support as many other environments as necessary (e.g. Staging, QA, or whatever you can dream up). Just show me the code! Ok, here is a quick example: ###### Basic Setup ```ruby # FLIPPER_CLOUD_TOKEN= require "flipper" if Flipper.enabled?(:billing) # get paid else # wish you were getting paid end ``` For more details and best practices, read the [getting started guide](/docs/get-started) below or check out our [Flipper Cloud rails demo app](https://github.com/flippercloud/flipper-rails-demo). --- Source: https://www.flippercloud.io/docs/uses # What can Flipper do? > Feature flags provide an incredible amount of flexibility for shipping code as well as controlling other aspects of your app's code. Flipper gives you control of your code without committing, reconfiguring, or deploying. With feature flags, you can enable and disable different features of your application in production. The click of a button toggles features on or off for specific users, groups of users, or any other criteria your heart desires. Here are a few of the ways you can use feature flags with Flipper. ## Give users early access {#early-access} Building great software requires feedback, early and often. Some features may take weeks or months to build, but you don't have to wait until everything is completely done to get feedback from your team or users. New features can be shipped to production behind a feature flag without disrupting anyone else, and then enabled individually for developers and groups of users. Guide: [Using feature flags to launch new features](/docs/guides/launch) ## Incrementally roll out new features {#incremental-rollout} Your new feature might be ready for the masses, but the thundering herd of new users could expose unforeseen issues that you weren't prepared for. The same feature flags used to give early access while a feature was in development can now be used to slowly roll features out to a percentage of users, organizations, specific countries, or whatever segments you define. Guide: [Using feature flags to launch new features](/docs/guides/launch) ## Coordinate launches with your team {#coordinate-lanches} Your feature is done, the launch date is here, the press is waiting under embargo, and your team is ready to hype it. Everyone is a little stressed, but you are cool as a cucumber because the feature has already been in production for weeks behind a feature flag. No last minute deploys, no unexpected failures, and no nervous fingers typing into a production terminal. You click a button to enable the feature as your fearless leader walks on stage and wows the world. Guide: [Using feature flags to launch new features](/docs/guides/launch) ## Let users opt-in {#opt-in} Give your users the power to decide which features they have access to. A few examples: * Minimize disruption by letting your users decide when they want to get familiar with a drastic interface redesign. * Let your most eager users join an [early access](#early-access) group. * New users can toggle from "simple" to "advanced" mode as they learn how to use your app ## Manage access to dev tools {#internal-access} Use feature flags to enable or disable internal tools for tasks like performance monitoring, analytics, or support tools. Since everyone has their own personal environment, they can disable tools that they don't need or want, or if you don't want development data cluttering up analytics, anybody can turn it off for their own personal environment. Examples [Using Flipper to manage internal tools](/blog/feature-flags-with-internal-tools) ## Control who has permission {#permissions} Whether you are limiting access to premium features for different subscription levels, or giving teammates and contributors access to administrative features, feature flags are a simple and powerful tool for permissions and access control in your app. ## Block bad actors {#block-users} The feature flag giveth and the feature flag taketh away. Flipper's feature checks are always blazing fast, so you can quickly and easily block bad actors that are abusing your app and rest assured that it will have a negligible impact on your limited resources. ## Perform maintenance on your app {#maintenance} Planned or not, performing maintenance on your app's infrastructure doesn't have to take your app offline entirely. With feature flags, you can disable features that will break and leave the rest of the application accessible. These toggles are also helpful when experiencing performance issues that disrupt your users. ## Run experiments in production {#split-testing} Split testing is an effective way to see how a change affects real users in production. Using feature flags, you can perform an A/B test by enabling an experimental feature for a percentage of users and then measure the results. No more guessing how your users or system will respond to the change. ## Sunset old features {#sunsetting} All good things must come to an end, and software features are no exception. Coordinating the sunset of a feature is not too dissimilar from [coordinating its launch](#coordinate-launches). Feature flags give you complete control over who has access to a feature until its very last day in production. After a feature is completely disabled, you can meticulously untangle and remove it from the code base, eliminating the technical debt it incurred without the pressure of a looming deadline. --- Source: https://www.flippercloud.io/docs/get-started # Getting Started > Setting up Flipper takes only a few minutes. Choose the right guide for your setup below or let us know if you would prefer to have us do it for you. We'd love to help! For the moment, Flipper Cloud only supports ruby applications. If there is another language you would like to see support for, we would love to know. * * * Choose between Flipper Cloud or Cloudless (self-hosted) installation. Don't worry — you can easily switch between the two, so you won't be locked into this decision. Not sure which? See [OSS vs Pro vs Cloud](/docs/oss-vs-pro-vs-cloud).

Cloud Recommended

Best for teams and multi-service apps that benefit from centralized feature flags.

  • Cloud as system of record with local sync
  • Central backup for local datastores
  • Multiple orgs, projects, and environments
  • Fine-grained user permissions
  • Full audit history and rollbacks
  • Personal dev environments
  • Designed to never take your app down
Get Started with Cloud

Cloudless

Great for solo developers or a quick test drive. Free and self-hosted — upgrade to Cloud anytime.

  • Local datastore as system of record
  • Basic feature flags stored locally
  • Optional web UI via flipper-ui gem
  • Entirely free and open source
Get Started Cloudless
--- Source: https://www.flippercloud.io/docs/get-started/cloud # Get Started with Flipper Cloud on Rails > Connect a Rails app to Flipper Cloud in a few minutes: add the gem, set FLIPPER_CLOUD_TOKEN, and gate any code path with a feature flag. In addition to the steps outlined below, we have a fully functional [example Rails application](https://github.com/flippercloud/flipper-rails-demo) for you to peruse. ## Step 1. Add Flipper to your app It's recommended to persist your Flipper configuration locally with an adapter of your choice (e.g. [ActiveRecord](/docs/adapters/active-record), [Redis](/docs/adapters/redis), [Sequel](/docs/adapters/sequel), [Mongo](/docs/adapters/mongo), or several [other adapters](/docs/adapters)). You can decide this later if you don't know which one you want now. ``` bundle add flipper-active_record bin/rails g flipper:setup bin/rails db:migrate ``` You'll need to set the following `ENV` variable: ```bash FLIPPER_CLOUD_TOKEN= ``` ## Step 2. Use Flipper in your code Use `Flipper#enabled?` in your app for anything you want to gate access to, such as rolling out new features, taking parts of your system offline for maintenance without disrupting everyone else, or any other reason. For example, here we check if the search feature of our app is enabled: ##### `search_controller.rb` ```ruby before_action :ensure_search_enabled def ensure_search_enabled render :unavailable unless Flipper.enabled?(:search) end ``` Now flip this feature on for different segments of your users: ```ruby # Enable a feature for everyone Flipper.enable :search # Enable a feature for a specific actor Flipper.enable_actor :search, current_user # Enable a feature for a group of actors Flipper.enable_group :search, :admin # Enable a feature for a percentage of actors Flipper.enable_percentage_of_actors :search, 2 ``` Read more about [enabling features](/docs/features). ## Done That's it. For a couple lines of code and a couple of clicks you get the full power of feature toggles with little to no performance impact. ## What if Flipper Cloud goes down? Your app won't even notice. Every feature flag check reads from your local adapter — zero calls to Flipper Cloud at runtime. Cloud syncs happen in the background, so if Flipper Cloud is ever unreachable, your app keeps running with the last known feature flag state. Learn more about [how Flipper Cloud is designed to never take your app down](/resilience). ## Need Help? We would be delighted to answer any questions or even setup a pairing session to help you get your application setup correctly. Shoot an email to support@flippercloud.io. --- Source: https://www.flippercloud.io/docs/get-started/self-hosted # Get Started with Flipper Cloudless on Rails > Set up open source Flipper in a Rails app without Cloud: add the gem and an adapter, run the generator, and gate any code path with a feature flag. In addition to the steps outlined below, we have a fully functional [example Rails application](https://github.com/flippercloud/flipper-rails-demo) for you to peruse. ## Step 1. Add Flipper to your app It's recommended to persist your Flipper configuration locally with an adapter of your choice (e.g. [ActiveRecord](/docs/adapters/active-record), [Redis](/docs/adapters/redis), [Sequel](/docs/adapters/sequel), [Mongo](/docs/adapters/mongo), or several [other adapters](/docs/adapters)). You can decide this later if you don't know which one you want now. ``` bundle add flipper-active_record bin/rails g flipper:setup bin/rails db:migrate ``` ## Step 2. Use Flipper in your code Use `Flipper#enabled?` in your app for anything you want to gate access to, such as rolling out new features, taking parts of your system offline for maintenance without disrupting everyone else, or many other reasons. For example, here we check if the search feature of our app is enabled: ##### `search_controller.rb` ```ruby before_action :ensure_search_enabled def ensure_search_enabled render :unavailable unless Flipper.enabled?(:search) end ``` Now flip this feature on for different segments of your users: ```ruby # Enable a feature for everyone Flipper.enable :search # Enable a feature for a specific actor Flipper.enable_actor :search, current_user # Enable a feature for a group of actors Flipper.enable_group :search, :admin # Enable a feature for a percentage of actors Flipper.enable_percentage_of_actors :search, 2 ``` Read more about [enabling features](/docs/features). ## Step 3. Add the Flipper Web UI or API (Optional) With Flipper Cloud, the app provides a web interface, but with self-hosted, you can install a simple web interface using the open source `flipper-ui` gem. Or you can skip the Flipper UI and use the Flipper to build feature-toggling functionality directly into your existing administrative tools. Visit the [`flipper-ui` installation guide](/docs/ui) if you want to install the Flipper control panel in your app. Or, if you have external administrative tools, you can add the [`flipper-api` gem](/docs/api) to integrate with external tools. ## Step 4. Subscribe to the Newsletter for Updates (Optional) Stay up-to-date on new releases of the Flipper gem by [subscribing to the newsletter](/newsletter). ## Done That's it. For a couple lines of code and a couple of clicks you get the full power of feature toggles with little to no performance impact. If you're ever ready to upgrade to Flipper Cloud, there's [a guide for migrating from Cloudless to Cloud](https://www.flippercloud.io/docs/guides/migration) that should get you going in no time. ## Need Help? We would be delighted to answer any questions or even setup a pairing session to help you get your application setup correctly. Shoot an email to support@flippercloud.io. --- Source: https://www.flippercloud.io/docs/oss-vs-pro-vs-cloud # OSS vs Pro vs Cloud > Which Flipper fits your team: open source, Flipper Pro, or Flipper Cloud (Free, Bronze, Silver, Gold). Concrete thresholds for each, and what you'd build yourself if you stay on open source. Every option runs on the same open source `flipper` gem, and your app checks flags against local data in all of them. The difference is where flags are managed and who can manage them. You can move between them at any time without changing how your code checks flags. ## The short version - **Open source (self-hosted)** if flags are all you need, with no audit trail, rollbacks, Slack notifications, or permissions on who can change what. - **Pro** if you want Cloud's UI and an audit log, but your flag data can't leave your infrastructure. - **Cloud** if you need rollbacks, environments that mirror production, or one place to manage every app, or want your AI assistant to find flags that are ready to remove, and would rather not host it yourself. ## Stay on open source if - Nobody asks "who turned this on, and when?", and you don't need to undo a change in one click. - You don't need Slack notifications when flags change, or permissions on who can change what. - Flags change through deploys, a console, or [Flipper UI](/docs/ui) mounted behind your own authentication. - You have one environment that matters (production), or you're happy to keep each environment's flags in sync by hand. The size of your team or how many apps you run isn't the test. One app can lean on flags enough to need all of this, and a large team with a few simple flags may not. Open source Flipper is free forever and has every gate type: [boolean](/docs/features/boolean), [actors](/docs/features/actors), [groups](/docs/features/groups), [percentages](/docs/features/percentage-of-actors), and [expressions](/docs/features/expressions). [Get started self-hosted](/docs/get-started/self-hosted). ## Choose Pro when - Compliance, data residency, or a security review rules out SaaS, so flag data can never leave your infrastructure. - You want Cloud's polished UI, feature owners, and an audit log, mounted inside your own Rails app behind your own authentication. Pro is $1,999 per organization per year, flat, with no per-seat fees. See [Flipper Pro](/docs/pro) for what's included. ## Move to Cloud when Each tier below lists the point where it starts to pay off. Full details are on the [pricing page](/pricing). ### Cloud Free ($0) You want to try Cloud on a real app: one project, up to 2 team members, and up to 5 feature flags, with production and personal environments. ### Cloud Bronze ($49/month) - You need to know who changed what, roll back in one click, and post changes to Slack. - You have more than 5 flags or more than one app (unlimited flags and projects). - Up to 10 people change flags. - You want a shared staging environment (1 custom environment) on top of production and personal environments. ### Cloud Silver ($149/month) - 11 to 25 people change flags. - You need 2 shared environments besides production, such as staging and QA. - You want longer telemetry and audit history retention, and changes synced every 30 seconds. ### Cloud Gold ($299/month) - 26 to 50 people change flags. - You need to control who can change production: organization, project, and environment permissions, plus restricted environment access. - New teammates should join automatically when they sign in with your company's Google domain. - You want unlimited custom environments. More than 50 people? Email us. ## What you'd build yourself Open source Flipper gives you flags. If you stay on open source and need any of these, they're yours to build and maintain. Cloud includes them; where a tier is named, it's the lowest plan that has it. Pro covers the UI, actor names, audit log and Slack on your own infrastructure. - **One place for every app.** Flipper UI is mounted per app, so ten apps means ten UIs and ten logins. Cloud manages every [project](/docs/cloud) in one place (more than one project from Bronze). - **Environments that work like production.** Every Cloud [environment](/docs/cloud/environments) inherits from production, so staging and development behave like production out of the box. - **Personal environments.** Each developer can change flags locally without affecting anyone else. - **Audit history and rollbacks.** Who changed what and when, and a one-click undo, from Bronze. See [Audit History](/docs/cloud/audit-history). - **Users and permissions.** Invitations, roles and two-factor sign-in, which organizations can require, on every plan; controlling who can change production from Gold. See [Permissions](/docs/cloud/permissions). - **Actor names and autocomplete.** Name your actors and pick them by name instead of pasting IDs. - **Telemetry.** Which flags are checked, how often, and how often they're enabled, from Bronze. See [Telemetry](/docs/cloud/telemetry). - **Notifications and sync.** [Slack](/docs/cloud/slack) messages on every change (from Bronze), and [webhooks](/docs/cloud/webhooks) that push changes to every server. - **An API.** Manage features and gates from scripts and CI. See the [Cloud API](/docs/cloud/api). - **AI assistant access.** Connect Claude, Codex or Cursor to the [MCP server](/docs/cloud/mcp) and ask which flags are ready to remove, on every plan. It finds flags that are on or off everywhere; finding flags that always return the same answer or are never checked needs telemetry, from Bronze. Cloud also funds the open source gem. Every subscription supports Flipper's maintenance. ## Switching later - **Open source to Cloud:** run `bundle exec flipper cloud migrate` to copy your existing flags into Cloud. See [Upgrade from Open Source to Cloud](/docs/guides/migration). - **Cloud back to open source:** export any environment from its Import / Export page, then import the file on the Settings page of [Flipper UI](/docs/ui) running on your own adapter. --- Source: https://www.flippercloud.io/docs/adapters # Adapters > Flipper is built on adapters for maximum flexibility. Regardless of what data store you are using, Flipper can performantly store data in it. Storage adapters are local to your application, so you'll always have blazing fast feature checks that are always in sync and available—even if Flipper Cloud isn't for some reason. ## Officially Supported Pick one of our [supported adapters](https://github.com/flippercloud/flipper/tree/main/lib/flipper/adapters) and follow the installation instructions:
Storage You definitely need one of these.
ActiveRecord Production Rails apps
Moneta Production Ruby apps already using Moneta
Mongo Production Ruby apps already using Mongo
Redis Production Ruby apps already using Redis
Sequel Production Ruby apps already using Sequel
Cache Reduce calls to storage to speed things up.
ActiveSupportCacheStore Production Rails apps with aggressive caching needs
Dalli Production Ruby apps already using Dalli
Redis Cache Production Rails apps with aggressive caching needs
Extras Additional functionality to complement primary adapters.
ActorLimit Limits the number of actors that can be enabled for a feature (default: 100)
Failover Increasing reliability by failing over to a secondary adapter if primary is unavailable
Failsafe Graceful failures when an exception is raised
Instrumented Instrumenting all adapter operations with ActiveSupport::Notifications
Read Only Preventing writes from a Production console
Strict Raising an error if an unrecognized flag is used
Internal You probably dont need these but here they are.
Dual Write Read from one adapter but write to two (used by Cloud)
Memoizable Prevent subsquent calls to an adapter for the same feature (used by memoizing middleware)
Memory Testing Environments
Operation Logger Stores all adapter operations in memory for verification in tests
Poll Polls for changes from a remote adapter in a background thread but updates local adapter in main thread (used by Cloud)
Sync Keeping two adapters in sync (bits are used in Cloud)
Niche Highly specialized adapters outside of day-to-day usage.
HTTP Connecting to Flipper::Api
PStore When a local file is enough or you need something that works with multiple processes like some system tests
Rollout Migrating from Rollout to Flipper
### JavaScript in Rails In addition to the standard adapters, we wrote a blog post about client-side flags with recommendations and examples of how to expose feature flags to client-side code in Rails apps.' ## Create a new adapter Don't see an adapter that suits your needs? You can [create your own](/docs/adapters/new). We even provide automatic (rspec and minitest) tests for you, so you know you've built your custom adapter correctly. ## Swapping Adapters If you find yourself using one adapter and would like to swap to another, you can do that! Flipper adapters support importing another adapter's data. This will wipe the adapter you are wanting to swap to, if it isn't already clean, so please be careful. ```ruby # Say you are using redis... redis_adapter = Flipper::Adapters::Redis.new(Redis.new) redis_flipper = Flipper.new(redis_adapter) # And redis has some stuff enabled... redis_flipper.enable(:search) redis_flipper.enable_percentage_of_time(:verbose_logging, 5) redis_flipper.enable_percentage_of_actors(:new_feature, 5) redis_flipper.enable_actor(:issues, Flipper::Actor.new('1')) redis_flipper.enable_actor(:issues, Flipper::Actor.new('2')) redis_flipper.enable_group(:request_tracing, :staff) # And you would like to switch to active record... ar_adapter = Flipper::Adapters::ActiveRecord.new ar_flipper = Flipper.new(ar_adapter) # NOTE: This wipes active record clean and copies features/gates from redis into active record. ar_flipper.import(redis_flipper) # active record is now identical to redis. ar_flipper.features.each do |feature| pp feature: feature.key, values: feature.gate_values end ``` --- Source: https://www.flippercloud.io/docs/adapters/active-record # ActiveRecord Adapter > An ActiveRecord adapter for Flipper to use in production Rails applications. Supported Active Record versions: * 5.x * 6.x * 7.x * 8.x ## Installation Add it to your application's Gemfile with: $ bundle add flipper-active_record Or install it yourself with: $ gem install flipper-active_record ## Usage For your convenience a migration generator is provided to create the necessary migrations for using the active record adapter. By default this generates a migration that will create two database tables - `flipper_features` and `flipper_gates`. ```bash $ rails g flipper:setup ``` Note that the active record adapter requires the database tables to be created in order to work; failure to run the migration first will cause an exception to be raised when attempting to initialize the active record adapter. Flipper will be configured to use the ActiveRecord adapter when `flipper-active_record` is loaded. But **if you need to customize the adapter**, you can add this to an initializer: ```ruby require 'flipper/adapters/active_record' Flipper.configure do |config| config.adapter { Flipper::Adapters::ActiveRecord.new } end ``` Flipper uses an abstract base model that you can use to change behavior, such as specifying which database to connect to: ```ruby # config/initializers/flipper.rb Flipper::Adapters::ActiveRecord::Model.connects_to database: { writing: :flipper, reading: :flipper_replica } ```

Internals

Each feature is stored as a row in a features table. Each gate is stored as a row in a gates table, related to the feature by the feature's key. ```ruby # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) Flipper.enable :stats Flipper.enable_group :stats, :admins Flipper.enable_group :stats, :early_access Flipper.enable_actor :stats, User.new('25') Flipper.enable_actor :stats, User.new('90') Flipper.enable_actor :stats, User.new('180') Flipper.enable_percentage_of_time :stats, 15 Flipper.enable_percentage_of_actors :stats, 45 Flipper.enable :search puts 'all rows in features table' pp Flipper::Adapters::ActiveRecord::Feature.all # [#, # #] puts puts 'all rows in gates table' pp Flipper::Adapters::ActiveRecord::Gate.all # [#, # #, # #, # #, # #, # #, # #, # #, # #] puts puts 'flipper get of feature' pp adapter.get(flipper[:stats]) # flipper get of feature ```
--- Source: https://www.flippercloud.io/docs/adapters/active-support-cache-store # ActiveSupportCacheStore Adapter > An ActiveSupportCacheStore adapter for Flipper. [ActiveSupportCacheStore](http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html) ## Installation Add it to your application's Gemfile with: $ bundle add flipper-active_support_cache_store Or install it yourself with: $ gem install flipper-active_support_cache_store ## Usage ```ruby require 'active_support/cache' require 'flipper/adapters/active_support_cache_store' Flipper.configure do |config| config.use Flipper::Adapters::ActiveSupportCacheStore, Rails.cache, 5.minutes end ``` Setting `expires_in` is optional and will set an expiration time on Flipper cache keys. If specified, all flipper keys will use this `expires_in` over the `expires_in` passed to your ActiveSupport cache constructor.

Internals

Each feature is stored in the underlying cache store. This is an example using `ActiveSupport::Cache::MemoryStore` with the [Flipper memory adapter](https://github.com/flippercloud/flipper/blob/main/lib/flipper/adapters/memory.rb). Each key is namespaced under `flipper/v1/feature/` ```ruby require 'active_support/cache' require 'flipper/adapters/active_support_cache_store' memory_adapter = Flipper::Adapters::Memory.new cache = ActiveSupport::Cache::MemoryStore.new adapter = Flipper::Adapters::ActiveSupportCacheStore.new(memory_adapter, cache) flipper = Flipper.new(adapter) # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) flipper[:stats].enable flipper[:stats].enable_group :admins flipper[:stats].enable_group :early_access flipper[:stats].enable_actor User.new('25') flipper[:stats].enable_actor User.new('90') flipper[:stats].enable_actor User.new('180') flipper[:stats].enable_percentage_of_time 15 flipper[:stats].enable_percentage_of_actors 45 flipper[:search].enable # reading all feature keys pp cache.read("flipper/v1/features") # # reading a single feature pp cache.read("flipper/v1/feature/stats") { :boolean=>"true", :groups=>#, :actors=>#, :percentage_of_actors=>"45", :percentage_of_time=>"15" } # flipper get of feature pp adapter.get(flipper[:stats]) { :boolean=>"true", :groups=>#, :actors=>#, :percentage_of_actors=>"45", :percentage_of_time=>"15" } ```
--- Source: https://www.flippercloud.io/docs/adapters/failsafe # Failsafe Adapter > Wraps another adapter and fails safely when an exception is raised. This prevents issues like network hiccups from taking down an application using Flipper. ## Installation This adapter is included with the `flipper` gem. ## Usage ```ruby Flipper.configure do |config| config.use Flipper::Adapters::Failsafe, errors: [Redis::ConnectionError, Redis::TimeoutError] config.adapter do Flipper::Adapters::Redis.new(Redis.new) end end ``` The `errors` option defaults to `[StandardError]`, which will rescue any exception raised. It is recommended to set it to specific errors that you anticipate could take down your application. **Warning**: This adapter will silently swallow the errors that it encounters, including those encountered while updating features (like `Flipper.enable :my_feature`). You will likely want some other health check in place to notify you of issues. --- Source: https://www.flippercloud.io/docs/adapters/http # HTTP Adapter > HTTP adapter for use with the Flipper API. View the [Flipper API documentation.](/docs/api) Given you have [mounted](/docs/api#usage) the Flipper Api on an application, you can use the HTTP adapter to interact with Flipper just like any other adapter, and internally it will handle all the http requests for you. This means that you can have the application exposing the API store your Flipper data, but interact with it from other Ruby apps. Initialize the HTTP adapter with a configuration Hash. ```ruby require 'flipper/adapters/http' Flipper.configure do |config| config.adapter do Flipper::Adapters::Http.new({ url: 'http://app.com/mount-point', # required headers: { 'X-Custom-Header' => 'foo' }, basic_auth_username: 'user123', basic_auth_password: 'password123' read_timeout: 5, open_timeout: 2, }) end end ``` **Required keys**: * url: String url where [Flipper Api](/docs/api) is mounted. **Optional keys**: *These will affect every request the adapter makes. For example, send basic auth credentials with every request.* * headers: HTTP headers. * basic_auth_username: Basic Auth username. * basic_auth_password: Basic Auth password. * read_timeout: [number in seconds](https://docs.ruby-lang.org/en/2.3.0/Net/HTTP.html#attribute-i-read_timeout). * open_timeout: [number in seconds](https://docs.ruby-lang.org/en/2.3.0/Net/HTTP.html#attribute-i-open_timeout). * debug_output: Set an output stream for debugging (e.g. `debug_output: $stderr`). The output stream is passed on to [Net::HTTP#set_debug_output](https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-i-set_debug_output). --- Source: https://www.flippercloud.io/docs/adapters/moneta # Moneta Adapter > A Moneta adapter for Flipper. [Moneta](https://github.com/minad/moneta) ## Installation Add it to your application's Gemfile with: $ bundle add flipper-moneta Or install it yourself with: $ gem install flipper-moneta ## Usage ```ruby require 'flipper/adapters/moneta' moneta = Moneta.new(:Memory) Flipper.configure do |config| config.adapter { Flipper::Adapters::Moneta.new(moneta) } end ```

Internals

Each feature is stored as a key namespaced by `flipper_features`. ```ruby require 'flipper/adapters/moneta' moneta = Moneta.new(:Memory) Flipper.configure do |config| config.adapter { Flipper::Adapters::Moneta.new(moneta) } end # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) Flipper[:stats].enable Flipper[:stats].enable_group :admins Flipper[:stats].enable_group :early_access Flipper[:stats].enable_actor User.new('25') Flipper[:stats].enable_actor User.new('90') Flipper[:stats].enable_actor User.new('180') Flipper[:stats].enable_percentage_of_time 15 Flipper[:stats].enable_percentage_of_actors 45 pp moneta["flipper_features/stats"] {:boolean=>"true", :groups=>#, :actors=>#, :percentage_of_actors=>"45", :percentage_of_time=>"15"} ```
--- Source: https://www.flippercloud.io/docs/adapters/mongo # Mongo Adapter > A MongoDB adapter for Flipper. [MongoDB](https://github.com/mongodb/mongo-ruby-driver) ## Installation Add it to your application's Gemfile with: $ bundle add flipper-mongo Or install it yourself with: $ gem install flipper-mongo ## Usage In most cases, all you need to do is require the adapter. You must set the `MONGO_URL` or `FLIPPER_MONGO_URL` environment vairable to specify which Mongo database to connect to. ```ruby require 'flipper-mongo' ``` **If you're using Mongoid**, you can add this to an initializer: ```ruby Flipper.configure do |config| config.adapter do Flipper::Adapters::Mongo.new(Mongoid.default_client['flipper']) end end ``` Or **if you need to customize the adapter** in any other way, you can add this to an initializer: ```ruby Flipper.configure do |config| config.adapter do collection = Mongo::Client.new(ENV["MONGO_URL"])["flipper"] Flipper::Adapters::Mongo.new(collection) end end ```

Internals

Each feature is stored in a document, which means getting a feature is single query. ```ruby require 'flipper/adapters/mongo' collection = Mongo::Client.new(["127.0.0.1:27017"], database: 'testing')['flipper'] adapter = Flipper::Adapters::Mongo.new(collection) flipper = Flipper.new(adapter) # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) flipper[:stats].enable flipper[:stats].enable_group :admins flipper[:stats].enable_group :early_access flipper[:stats].enable_actor User.new('25') flipper[:stats].enable_actor User.new('90') flipper[:stats].enable_actor User.new('180') flipper[:stats].enable_percentage_of_time 15 flipper[:stats].enable_percentage_of_actors 45 flipper[:search].enable puts 'all docs in collection' pp collection.find.to_a # all docs in collection # [{"_id"=>"stats", # "actors"=>["25", "90", "180"], # "boolean"=>"true", # "groups"=>["admins", "early_access"], # "percentage_of_actors"=>"45", # "percentage_of_time"=>"15"}, # {"_id"=>"flipper_features", "features"=>["stats", "search"]}, # {"_id"=>"search", "boolean"=>"true"}] puts puts 'flipper get of feature' pp adapter.get(flipper[:stats]) # flipper get of feature # {:boolean=>"true", # :groups=>#, # :actors=>#, # :percentage_of_actors=>"45", # :percentage_of_time=>"15"} ```
--- Source: https://www.flippercloud.io/docs/adapters/new # Create a New Adapter > If you would like to make your own adapter, there are shared adapter specs (RSpec) and tests (MiniTest) that you can use to verify that you have everything working correctly. ## API The basic API for an adapter is this: - `features` - Get the set of known features. - `add(feature)` - Add a feature to the set of known features. - `remove(feature)` - Remove a feature from the set of known features. - `clear(feature)` - Clear all gate values for a feature. - `get(feature)` - Get all gate values for a feature. - `enable(feature, gate, thing)` - Enable a gate for a thing. - `disable(feature, gate, thing)` - Disable a gate for a thing. - `get_multi(features)` - Get all gate values for several features at once. Implementation is optional. If none provided, default implementation performs N+1 `get` calls where N is the number of elements in the features parameter. - `get_all` - Get all gate values for all features at once. Implementation is optional. If none provided, default implementation performs two calls, one to `features` to get the names of all features and one to `get_multi` with the feature names from the first call. A good place to start when creating your own adapter is to copy one of the [officially supported adapters](../adapters) and replace the client specific code with whatever client you are attempting to adapt. ## MiniTest Here is what an in-memory adapter MiniTest looks like: ###### test/adapters/memory_test.rb ```ruby require 'test_helper' class MemoryTest < MiniTest::Test prepend SharedAdapterTests def setup # Any code here will run before each test @adapter = Flipper::Adapters::Memory.new end def teardown # Any code here will run after each test end end ``` 1. Create a file under `test/adapters` that inherits from `MiniTest::Test`. 2. `prepend SharedAdapterTests`. 3. Initialize an instance variable `@adapter` referencing an instance of the adapter. 4. Add any code to run before each test in a `setup` method and any code to run after each test in a `teardown` method. ## RSpec For example, here is what the in-memory adapter spec looks like: ###### spec/flipper/adapters/memory_spec.rb ```ruby require 'helper' # The shared specs are included with the flipper gem so you can use them in # separate adapter specific gems. require 'flipper/spec/shared_adapter_specs' describe Flipper::Adapters::Memory do # an instance of the new adapter you are trying to create subject { described_class.new } # include the shared specs that the subject must pass it_should_behave_like 'a flipper adapter' end ``` **Tip:** Set `fail_fast = true` in your RSpec configuration as that will just give you one failure at a time to work through. It is also handy to have the shared adapter spec file open. --- Source: https://www.flippercloud.io/docs/adapters/pstore # Pstore Adapter > A Pstore adapter for Flipper. [Pstore](https://github.com/ruby/pstore) ## Installation The Pstore adapter is distributed as part of the `flipper` gem. Add it to your Gemfile with: $ bundle add flipper Or install it yourself with: $ gem install flipper ## Usage ```ruby require 'flipper/adapters/pstore' Flipper.configure do |config| config.adapter { pstore_path = Rails.root.join("tmp", "flipper.pstore") # or wherever Flipper::Adapters::Pstore.new(pstore_path) } end ``` --- Source: https://www.flippercloud.io/docs/adapters/read-only # Read-only Adapter > A read-only adapter for Flipper. Use this adapter to wrap another adapter and raise an exception for any writes. Any attempted write raises `Flipper::Adapters::ReadOnly::WriteAttempted` with message `'write attempted while in read only mode'` ## Usage ```ruby # example wrapping memory adapter require 'flipper/adapters/read_only' Flipper.configure do |config| config.use Flipper::Adapters::ReadOnly end # Enabling a feature > Flipper[:dashboard_panel].enable => Flipper::Adapters::ReadOnly::WriteAttempted: write attempted while in read only mode ``` --- Source: https://www.flippercloud.io/docs/adapters/redis # Redis Adapter > A Redis adapter for Flipper. [Redis](https://github.com/redis/redis-rb) ## Installation Add it to your application's Gemfile with: $ bundle add flipper-redis Or install it yourself with: $ gem install flipper-redis ## Usage In most cases, all you need to do is require the adapter. It will connect to the Redis instance specified in the `REDIS_URL` or `FLIPPER_REDIS_URL` environment vairable, or localhost by default. ```ruby require 'flipper/adapters/redis' ``` **If you need to customize the adapter**, you can add this to an initializer: ```ruby Flipper.configure do |config| config.adapter { Flipper::Adapters::Redis.new(Redis.new) } end ```

Internals

## Internals Each feature is stored in a redis hash, which means getting a feature is single query. ```ruby require 'flipper/adapters/redis' client = Redis.new adapter = Flipper::Adapters::Redis.new(client) flipper = Flipper.new(adapter) # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) flipper[:stats].enable flipper[:stats].enable_group :admins flipper[:stats].enable_group :early_access flipper[:stats].enable_actor User.new('25') flipper[:stats].enable_actor User.new('90') flipper[:stats].enable_actor User.new('180') flipper[:stats].enable_percentage_of_time 15 flipper[:stats].enable_percentage_of_actors 45 flipper[:search].enable print 'all keys: ' pp client.keys # all keys: ["stats", "flipper_features", "search"] puts print "known flipper features: " pp client.smembers("flipper_features") # known flipper features: ["stats", "search"] puts puts 'stats keys' pp client.hgetall('stats') # stats keys # {"boolean"=>"true", # "groups/admins"=>"1", # "actors/25"=>"1", # "percentage_of_time"=>"15", # "percentage_of_actors"=>"45", # "groups/early_access"=>"1", # "actors/90"=>"1", # "actors/180"=>"1"} puts puts 'search keys' pp client.hgetall('search') # search keys # {"boolean"=>"true"} puts puts 'flipper get of feature' pp adapter.get(flipper[:stats]) # flipper get of feature # {:boolean=>"true", # :groups=>#, # :actors=>#, # :percentage_of_actors=>"45", # :percentage_of_time=>"15"} ```
--- Source: https://www.flippercloud.io/docs/adapters/rollout # Rollout Adapter > A Rollout adapter for importing Rollout data into Flipper. View the [docs on importing](/docs/adapters#swapping-adapters). Requires: * [Rollout](https://github.com/fetlife/rollout) ~> 2.0 * Flipper >= 0.12 ## Installation Add it to your application's Gemfile with: $ bundle add flipper-rollout Or install it yourself with: $ gem install flipper-rollout ## Usage ```ruby require 'redis' require 'rollout' require 'flipper' require 'flipper/adapters/redis' require 'flipper/adapters/rollout' # setup redis, rollout and rollout flipper redis = Redis.new rollout = Rollout.new(redis) rollout_adapter = Flipper::Adapters::Rollout.new(rollout) rollout_flipper = Flipper.new(rollout_adapter) # setup flipper default instance Flipper.configure do |config| config.adapter { Flipper::Adapters::Redis.new(redis) } end # import rollout into redis flipper Flipper.import(rollout_flipper) ``` That was easy. ### Groups If you're using [Rollout groups](https://github.com/fetlife/rollout#user-content-groups) you'll need to register them as [Flipper groups](/docs/features/groups): *Rollout* ```ruby $rollout.define_group(:caretakers) do |user| user.caretaker? end ``` *Flipper* ```ruby Flipper.register(:caretakers) do |user| user.caretaker? end ``` ### flipper_id Rollout expects users to respond to *id* (or method specified in [Rollout#initialize](https://github.com/fetlife/rollout/blob/main/lib/rollout.rb#L135) opts) and stores this value in Redis when a feature is activated for a user. You'll want to make sure that your Flipper actor's [flipper_id](/docs/features/actors) matches this logic. --- Source: https://www.flippercloud.io/docs/adapters/sequel # Sequel Adapter > A Sequel adapter for Flipper. [Sequel](https://github.com/jeremyevans/sequel) ## Installation Add it to your application's Gemfile with: $ bundle add flipper-sequel Or install it yourself with: $ gem install flipper-sequel ## Usage For your convenience, a sequel migration is provided to create the necessary tables. This migration will create two database tables - flipper_features and flipper_gates. ```ruby require 'generators/flipper/templates/sequel_migration' CreateFlipperTablesSequel.new(Sequel::Model.db).up ``` Once you have created and executed the migration, you can use the sequel adapter by simply requiring it: ```ruby require 'flipper-sequel` ``` **If you need to customize the adapter**, you can add this to an initializer: ```ruby Flipper.configure do |config| config.adapter { Flipper::Adapters::Sequel.new } end ```

Internals

Each feature is stored as a row in a features table. Each gate is stored as a row in a gates table, related to the feature by the feature's key. ```ruby require 'flipper/adapters/sequel' adapter = Flipper::Adapters::Sequel.new flipper = Flipper.new(adapter) # Register a few groups. Flipper.register(:admins) { |thing| thing.admin? } Flipper.register(:early_access) { |thing| thing.early_access? } # Create a user class that has flipper_id instance method. User = Struct.new(:flipper_id) flipper[:stats].enable flipper[:stats].enable_group :admins flipper[:stats].enable_group :early_access flipper[:stats].enable_actor User.new('25') flipper[:stats].enable_actor User.new('90') flipper[:stats].enable_actor User.new('180') flipper[:stats].enable_percentage_of_time 15 flipper[:stats].enable_percentage_of_actors 45 flipper[:search].enable puts 'all rows in features table' pp Flipper::Adapters::Sequel::Feature.all #[#"stats", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"search", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>] puts puts 'all rows in gates table' pp Flipper::Adapters::Sequel::Gate.all # [#"stats", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"groups", :value=>"admins", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"groups", :value=>"early_access", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"25", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"90", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"180", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"percentage_of_time", :value=>"15", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"percentage_of_actors", :value=>"45", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"search", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>] puts puts 'flipper get of feature' pp adapter.get(flipper[:stats]) # {:boolean=>"true", # :groups=>#, # :actors=>#, # :percentage_of_actors=>"45", # :percentage_of_time=>"15"} ```
--- Source: https://www.flippercloud.io/docs/adapters/strict # Strict Adapter > Catch typos and missing feature flags early by raising errors or warnings when an unknown feature is checked. The strict adapter wraps another adapter and ensures that a feature exists before allowing it to be checked. This helps you catch typos and missing feature flags early instead of silently returning `false` for features that don't exist. ## Installation This adapter is included with the `flipper` gem. ## Usage ### Rails Configuration The easiest way to enable strict mode in a Rails app is through configuration: ```ruby # config/initializers/flipper.rb Rails.application.configure do # Raise an error for unknown features config.flipper.strict = :raise # Or just log a warning config.flipper.strict = :warn end ``` You can also use an environment variable: ```bash FLIPPER_STRICT=warn # or FLIPPER_STRICT=raise ``` By default, strict mode is disabled in production and set to `:warn` in development and test. ### Manual Configuration ```ruby require 'flipper/adapters/strict' Flipper.configure do |config| config.use Flipper::Adapters::Strict, :raise end ``` ### Handler Options The second argument controls what happens when an unknown feature is checked: * **`:raise`** or **`true`** — Raises a `Flipper::Adapters::Strict::NotFound` error. * **`:warn`** — Logs a warning to stderr. * **`:noop`**, **`false`**, or **`nil`** — Silently ignores missing features (effectively disabling strict mode). * **Block** — Calls a custom block with the unknown feature, useful for custom logging or telemetry. ```ruby # Raise on missing features Flipper.configure do |config| config.use Flipper::Adapters::Strict, :raise end # Warn on missing features Flipper.configure do |config| config.use Flipper::Adapters::Strict, :warn end # Custom handler Flipper.configure do |config| config.use Flipper::Adapters::Strict do |feature| MyLogger.warn("Unknown feature flag checked: #{feature.key}") end end ``` ## Example ```ruby # Without strict mode, typos silently return false: Flipper.enable(:search) Flipper.enabled?(:serach) # => false (typo, but no error!) # With strict mode (:raise), you get an error immediately: Flipper.enabled?(:serach) # => Flipper::Adapters::Strict::NotFound: # Could not find feature :serach. # Call `Flipper.add(:serach)` to create it. ``` ## Recommended Setup We recommend enabling strict mode in development and test so you catch issues early, while leaving it disabled in production to avoid unexpected errors: ```ruby Rails.application.configure do config.flipper.strict = Rails.env.local? && :warn end ``` --- Source: https://www.flippercloud.io/docs/features # Features > Features are the heart of Flipper. They allow you to control code execution by enabling features in certain conditions. ###### Checking if a feature is enabled {#enabled} ```ruby if Flipper.enabled?(:my_feature) # do the thing else # do the other thing end ``` ## Managing features {#managing} Features can be added, removed, and listed using the Flipper DSL. Adding a feature registers it with the adapter without enabling it, which is useful for tracking known features in the UI or API. ###### `Flipper.add` {#add} ```ruby # Add a feature without enabling it Flipper.add(:search) ``` Adding a feature makes it visible in the UI, API, and `Flipper.features` without changing its state. Features are also implicitly added when you enable them. ###### `Flipper.remove` {#remove} ```ruby # Remove a feature and all its gate data Flipper.remove(:search) ``` Removing a feature deletes it and **all of its gate data** (actors, groups, percentages, etc.) from the adapter. This is a destructive action—use `Flipper.disable` if you just want to turn a feature off. ###### `Flipper.exist?` {#exist} ```ruby Flipper.exist?(:search) # false Flipper.add(:search) Flipper.exist?(:search) # true ``` ###### `Flipper.features` {#features-list} ```ruby Flipper.add(:search) Flipper.add(:stats) Flipper.features.each do |feature| puts feature.name end # => search # => stats ``` ## Enabling and disabling features {#enable} Flipper allows you to enable and disable feature flags for different users at runtime. You have control over the scenarios and conditions that enable a feature for a given actor, group, percentage of actors, percentage of time, or even custom expressions that you define. This means you can turn features on and off for certain users—but not others—without deploying new code. There are 6 different ways to enable a feature: 1. [Boolean](/docs/features/boolean) 1. [Actors](/docs/features/actors) 1. [Percentage of Actors](/docs/features/percentage-of-actors) 1. [Percentage of Time](/docs/features/percentage-of-time) 1. [Groups](/docs/features/groups) 1. [Expressions](/docs/features/expressions) --- Source: https://www.flippercloud.io/docs/features/boolean # Boolean > Boolean features are either enabled or disable for all users. All on or all off. Think top level things like :stats, :search, :logging, etc. Also, an easy way to release a new feature, as once a feature is boolean enabled it is on for every situation. ###### Enabling a feature {#enable} ```ruby user = User.first Flipper.enabled?(:search) # false Flipper.enabled?(:search, user) # false Flipper.enable(:search) Flipper.enabled?(:search) # true Flipper.enabled?(:search, user) # true ``` ###### Disabling a feature {#disable} ```ruby Flipper.disable(:search) Flipper.enabled?(:search) # false Flipper.enabled?(:search, user) # false ``` --- Source: https://www.flippercloud.io/docs/features/actors # Actors > Enable features for a specific user, organization, or any other unique record. These are all called "Actors" in Flipper. To check if a feature is enabled for an actor, pass the object to the `Flipper.enabled?` check: ###### `enabled?(:feature, actor)` ```ruby user = User.first # Check if enabled without an actor Flipper.enabled?(:verbose_logging) # false # Check if enabled for the given user Flipper.enabled?(:verbose_logging, user) # false ``` You can check multiple related actors in the same feature check, and it will return true if enabled for any of the given actors: ###### `enabled?` with multiple actors ```ruby Flipper.enabled?(:verbose_logging, user, user.organizations, user.teams) ``` ## Enabling for an actor {#enable} To enable a feature for a specific actor, use `enable_actor`: ###### `enable_actor` ```ruby Flipper.enable_actor(:verbose_logging, user) # Check if enabled without an actor Flipper.enabled?(:verbose_logging) # false # Check if enabled for the given user Flipper.enabled?(:verbose_logging, user) # true # Check if enabled for a different actor Flipper.enabled?(:verbose_logging, User.last) # false ``` ### Limitations `enable_actor` is not designed to handle hundreds or thousands of actors. This is an explicit choice to make it easier to batch load data from the adapters instead of performing individual checks for actors over and over. If you need support for large actor sets, check out the [`flipper-pro` gem](/pro), or use [Groups](/docs/features/groups) to enable features for actors that match custom criteria. As of Flipper 1.3.0, there is a default limit of 100 actors per feature to prevent unexpected performance impacts. We don't advise it, but if needed, you can change this default by setting the `actor_limit` option: ###### Change `actor_limit` default ```ruby Rails.application.configure do # Increase the actor limit (not recommended) config.flipper.actor_limit = 1000 # or disable this check entirely (not recommended) config.flipper.actor_limit = false end ``` ### `flipper_id` An actor is any object that responds to `#flipper_id`. This is defined by default on all ActiveRecord objects, and for other objects you can include the `Flipper::Identifier` module for a default implementation which combines the class name and `id`. ###### `Flipper::Identifier` ```ruby class User < Struct.new(:id) include Flipper::Identifier end User.new(5).flipper_id # => "User;5" ``` You can also define your own implementation: ###### Custom `#flipper_id` ```ruby class Organization < Struct.new(:uuid) def flipper_id uuid end end Organization.new("DEB3D850-39FB-444B-A1E9-404A990FDBE0").flipper_id # => "DEB3D850-39FB-444B-A1E9-404A990FDBE0" ``` Just make sure each type of object has a unique `flipper_id`. ## Disabling for an actor {#disable} Use `disable_actor` to remove an actor from the list of actors for a feature. ###### `disable_actor` ```ruby Flipper.disable_actor(:verbose_logging, user) ``` > **NOTE** > You cannot use `disable_actor` to turn off a feature that is enabled for all actors. The `disable*` methods exist only to clear something previously enabled. Use [Groups](/docs/features/groups) to enable a feature for a subset that excludes certain actors. --- Source: https://www.flippercloud.io/docs/features/percentage-of-actors # Percentage of Actors > Enable features for a percentage of actors. Consistently on or off for this user as long as percentage increases. Think slow rollout of a new feature to a percentage of things. ###### Percentage of Actors Example ```ruby user = User.find(...) # responds to flipper_id method call Flipper.enable_percentage_of_actors(:new_design, 25) # returns true or false consistently for the same enabled percentage and actor Flipper.enabled?(:new_design, user) ``` Percentage of actors also takes into account the feature name to ensure that the same actors are not granted access first to every feature. > **Note** > 100% of actors will not return true if no actor is provided. ```ruby user = User.find(...) # responds to flipper_id method call # turn on for all actors Flipper.enable_percentage_of_actors(:new_design, 100) # true because 100% and actor is passed Flipper.enabled?(:new_design, user) # true # false because no actor provided Flipper.enabled?(:new_design) # => false Flipper.enabled?(:new_design, nil) # => false ``` --- Source: https://www.flippercloud.io/docs/features/percentage-of-time # Percentage of Time > Enable features for a percentage of time. Use Cases: * load testing new features behind the scenes * Performing random sampling of metrics that are too expensive to collect for all requests Do not use percentage of time for slowly rolling out new features. It will return a different result on subsequent calls by the same actor, which will be an inconsistent experience for the user. Use [percentage of actors](percentage-of-actors) instead. ###### Percentage of Time Example ```ruby user = User.find(...) Flipper.enable_percentage_of_time(:dark_ship_new_feature, 25) # returns true for ~25% of the enabled? calls irregardless of the actor provided Flipper.enabled?(:dark_ship_new_feature) Flipper.enabled?(:dark_ship_new_feature, user) ``` ## Caveats Percentage of time is not a good idea for enabling new features in a UI. Most often you'll use percentage of actors, but there are definitely times when I have found percentage of time to be very useful. --- Source: https://www.flippercloud.io/docs/features/groups # Groups > Enable features for a set of actors that share a common trait, which is determined by a configurable block at runtime. Turn on feature based on the return value of block. Super flexible way to turn on a feature for multiple things (users, people, accounts, etc.) as long as the thing returns true when passed to the block. ## Registering a group Use `Flipper.register` in an initializer to register a new group. The block passed to `register` will be called with the actor and a feature context when `enabled?` is called. ###### `config/initializers/flipper.rb` ```ruby # Define the block that will return true or false based on actor. # Registers a group named admins . Flipper.register(:admins) do |actor, context| actor.respond_to?(:admin?) && actor.admin? end ``` Since Flipper allows any object to be an actor, check that `actor.respond_to?(…)` before calling a method on it. ## Enabling a feature for a group A feature can be enabled for a group by calling `enable_group` with the name of the feature and the group. ```ruby Flipper.enable_group(:documentation, :admins) ``` ## Example When a feature is enabled for a group, calls to `Flipper.enabled?` with an actor will check if the actor is in that group. ```ruby user = User.where(admin: false).first # user who returns false for admin? method admin = User.where(admin: true).first # user who returns true for admin? method # The feature is not enabled for a normal user Flipper.enabled?(:documentation, user) # false # The feature is enabled for an admin user. Flipper.enabled?(:documentation, admin) # true ``` --- Source: https://www.flippercloud.io/docs/features/expressions # Expressions > Enable features by defining rules that evaluate against properties of an actor and a feature context. > **NOTE** > Expressions are an experimental feature and are subject to change. Please [provide feedback](mailto:support@flippercloud.io?subject=Expressions) if you use them. Flipper Expressions are a powerful new way to enable features that support complex logic. They are language-agnostic and are stored in JSON, so they can sync between your application and Flipper Cloud. ## Enabling an expression {#enable} The simplest expression is a comparison of a property on the actor to a given value. For example, if we have a `User` model with an `age` property, we can enable a feature for users of a given age: ```ruby must_be_21 = Flipper.property(:age).gte(21) Flipper.enable :night_club, must_be_21 ``` Now we can test it for two actors of different ages: ```ruby # Under age Flipper.enabled? :night_club, User.new(age: 18) #=> false # Of age Flipper.enabled? :night_club, User.new(age: 21) #=> true ``` The `Property` expression extracts a property from the actor (by calling [`#flipper_properties`](#flipper_properties) on it), and in this case we use the `GreaterThanOrEqualTo` (aliased to `gte`) expression to compares it to the constant 21. You can compare any two values using `eq`, `gt`, `lt`, `gte`, `lte`, or `ne`. ## Combining expressions What if you want to enable a feature for users who are over 21 and have either paid or are a VIP? No problem, you can group expressions together using `all` and `any`, and even nest groups inside each other: ```ruby over_21 = Flipper.property(:age).gte(21) paid = Flipper.property(:paid).eq(true) vip = Flipper.property(:vip).eq(true) Flipper.enable :night_club, Flipper.all(over_21, Flipper.any(paid, vip)) ``` Now we can test it for three different actors: ```ruby # Unpaid Flipper.enabled? :night_club, User.new(2, age: 18, paid: false) #=> false # Paid Flipper.enabled? :night_club, User.new(1, age: 18, paid: true) #=> true # Unpaid, but VIP Flipper.enabled? :night_club, User.new(3, age: 18, paid: false, vip: true) #=> true ``` These groups require at least one sub-expression and can be nested to create complex rules. ## Time-based expressions {#time} You can enable features based on time using the `Now` and `Time` expressions. These work without an actor, so no `flipper_properties` are required. ### Scheduled enablement Enable a feature starting at a specific time: ```ruby expression = Flipper.now.gte(Flipper.time("2026-03-01T00:00:00Z")) Flipper.enable :new_feature, expression ``` ### Expiring feature Enable a feature until a specific time: ```ruby expression = Flipper.now.lt(Flipper.time("2026-04-01T00:00:00Z")) Flipper.enable :promo_banner, expression ``` ### Time window Enable a feature during a specific time range: ```ruby start_time = "2026-03-01T00:00:00Z" end_time = "2026-04-01T00:00:00Z" expression = Flipper.all( Flipper.now.gte(Flipper.time(start_time)), Flipper.now.lt(Flipper.time(end_time)) ) Flipper.enable :spring_sale, expression ``` ### Combined with actor properties Combine time-based expressions with property checks: ```ruby expression = Flipper.all( Flipper.property(:plan).eq("basic"), Flipper.now.gte(Flipper.time("2026-03-01T00:00:00Z")) ) Flipper.enable :new_feature, expression ``` ### Expression types - `Flipper.now` — Returns the current time in UTC. Takes no arguments. - `Flipper.time(value)` — Parses a time value. Accepts ISO 8601 strings (e.g. `"2026-03-01T00:00:00Z"`) or epoch timestamps (e.g. `1708300800`). Always returns UTC. ## Version expressions {#semver} Use `SemVer` to compare app versions by [Semantic Versioning](https://semver.org) rules instead of as strings, so `2.10.0` is greater than `2.9.0` and `1.0.0-beta.1` is less than `1.0.0`. Wrap both sides of the comparison: ```ruby expression = Flipper.semver(Flipper.property(:app_version)).gte(Flipper.semver("2.3.1")) Flipper.enable :new_onboarding, expression ``` In the expression builder, choose **Version** from the **+ Add** menu. It shows up once every app that synced the environment in the last 30 days runs a flipper release newer than 1.4.2. ### Version range ```ruby app_version = Flipper.semver(Flipper.property(:app_version)) expression = Flipper.all( app_version.gte(Flipper.semver("2.3.1")), app_version.lt(Flipper.semver("3.0.0")) ) Flipper.enable :new_onboarding, expression ``` ### Version rules - Follows [SemVer 2.0.0](https://semver.org) precedence, including prereleases (`1.0.0-alpha` < `1.0.0-beta` < `1.0.0`). Build metadata is ignored, so `1.0.0+1` equals `1.0.0+2`. - A leading `v` is allowed (`v2.3.1`), and missing minor or patch numbers count as `0` (`2.3` is `2.3.0`). - Pass versions as strings. Floats like `2.10` would read as `2.1`, so they aren't treated as versions. - An actor with a missing or malformed version never matches greater than or less than (or equal to). Equal and not equal compare it as no version, so it does match not equal to `2.3.1`. - Your app needs a flipper release newer than 1.4.2. Apps on 1.4.2 or older treat a feature with a `SemVer` expression as if it had no expression, so it's on for them only through its other gates. They also can't change or import over that expression until they upgrade. ## Feature dependencies {#feature-dependencies} You can make a feature depend on another feature using `Flipper.feature_enabled` and `Flipper.feature_disabled`. This allows you to create feature flag dependencies without custom code. ### Enable only if another feature is on ```ruby Flipper.enable(:search_beta) Flipper.enable :search_v2, Flipper.feature_enabled(:search_beta) ``` The actor is passed through, so if the referenced feature is enabled for specific actors, the dependent feature respects that: ```ruby Flipper.enable_actor(:search_beta, user) Flipper.enable :search_v2, Flipper.feature_enabled(:search_beta) Flipper.enabled?(:search_v2, user) #=> true Flipper.enabled?(:search_v2, other_user) #=> false ``` ### Enable only if another feature is off ```ruby Flipper.enable :new_checkout, Flipper.feature_disabled(:old_checkout) ``` ### Combined with other expressions ```ruby Flipper.enable :advanced_search, Flipper.all( Flipper.feature_enabled(:basic_search), Flipper.property(:plan).eq("premium") ) ``` Circular dependencies (A depends on B, B depends on A) are detected automatically and return `false`. Feature dependencies need flipper 1.4.0 or newer. Apps on 1.3.6 or older treat a feature with one as if it had no expression, and can't change or import over it until they upgrade. In the expression builder, **Feature Enabled** and **Feature Disabled** show up once every app that synced the environment in the last 30 days runs flipper 1.4.0 or newer. ## `flipper_properties` To use expressions, you'll need to ensure that actors respond to `flipper_properties` and return a hash of properties that you want to use in expressions. This is defined on ActiveRecord models by default. If you want to use expressions with a different model, you can define a method that returns a hash of properties: ```ruby class User < Struct.new(:id, :flipper_properties) include Flipper::Identifier end basic_user = User.new(1, {"plan" => "basic", "age" => 30}) premium_user = User.new(2, {"plan" => "premium", "age" => 40}) ``` --- To learn more, check out the plethora of code samples in [examples/expressions.rb](https://github.com/flippercloud/flipper/blob/main/examples/expressions.rb). --- Source: https://www.flippercloud.io/docs/testing # Testing > Advice and insights related to best practices for testing feature flags in your application. Since 1.2.0, Flipper will default to the `Memory` adapter when running tests in a Rails app and reset it before each test. This means each test is run with a fresh instance of Flipper and all features disabled. We find this the best route, but your application **may** have different needs. If you want some features to always be enabled, you can enable them in your test setup. ```ruby class ActiveSupport::TestCase setup do Flipper.enable :accounts Flipper.enable :fathom end end ``` In the example above, the `accounts` and `fathom` features would both start enabled for every test. Every other feature flag would start disabled. ## Test Both Sides For any feature flag, we strongly encourage you to have at least one test for when the feature is enabled and disabled. This ensures both sides of the coin are tested. ```ruby require 'test_helper' class DocumentationControllerTest < ActionDispatch::IntegrationTest test "returns 404 for documentation when feature disabled" do Flipper.disable(:docs) get documentation_path assert_response :not_found end test "renders documentation when feature enabled" do Flipper.enable(:docs) get documentation_path assert_response :success end end ``` ## System Tests The default configuration for testing should work for [system tests](https://guides.rubyonrails.org/testing.html#system-testing) just as any other test. [Let us know on this issue](https://github.com/flippercloud/flipper/issues/615) if you run into any issues. ## Advanced For non-Rails apps or Flipper <1.2, see [test_help.rb](https://github.com/flippercloud/flipper/blob/main/lib/flipper/test_help.rb). --- Source: https://www.flippercloud.io/docs/ui # Flipper UI > Flipper UI is a self-hosted web interface that gives you access to the basics but does not offer the full functionality of Flipper Cloud. While you can use Flipper UI in conjunction with Flipper Cloud, it would be redundant since Flipper Cloud offers a superset of the functionality provided through Flipper UI. ## Screenshots Viewing list of features:
Viewing list of flipper features in self-hosted UI
Viewing list of features in self-hosted UI
Viewing an individual feature:
Viewing an individual feature in self-hosted UI
Viewing an individual feature in self-hosted UI
## Installation Add it to your application's Gemfile with: $ bundle add flipper-ui Or install it yourself as: $ gem install flipper-ui ## Usage ### Rails Given that you've already initialized `Flipper` as per the [flipper](https://github.com/flippercloud/flipper) readme, you can mount `Flipper::UI` to a route of your choice: ```ruby # config/routes.rb YourRailsApp::Application.routes.draw do mount Flipper::UI.app(Flipper) => '/flipper' end ``` If you'd like to lazy load flipper, you can instead pass a block to initialize it: ```ruby # config/routes.rb YourRailsApp::Application.routes.draw do flipper_block = lambda { # some flipper initialization here, for example: adapter = Flipper::Adapters::Memory.new Flipper.new(adapter) } mount Flipper::UI.app(flipper_block) => '/flipper' end ``` #### Security You almost certainly want to limit access when using Flipper::UI in production. ##### Basic Authentication via Rack The `Flipper::UI.app` method yields a builder instance prior to any predefined middleware. You can insert the `Rack::Auth::Basic` middleware, that'll prompt for a username and password when visiting the defined (i.e., `/flipper`) route. ```ruby # config/routes.rb flipper_app = Flipper::UI.app do |builder| builder.use Rack::Auth::Basic do |username, password| # Verify credentials end end mount flipper_app, at: '/flipper' ``` ##### Route Constraints It is possible to use [routes constraints](http://guides.rubyonrails.org/routing.html#request-based-constraints) to limit access to routes: ```ruby # config/routes.rb flipper_constraint = lambda { |request| request.remote_ip == '127.0.0.1' } constraints flipper_constraint do mount Flipper::UI.app => '/flipper' end ``` Another example is to use the `current_user` when using a gem-based authentication system (i.e., [warden](https://github.com/hassox/warden) or [devise](https://github.com/plataformatec/devise)): ```ruby # initializers/admin_access.rb class CanAccessFlipperUI def self.matches?(request) current_user = request.env['warden'].user current_user.present? && current_user.respond_to?(:admin?) && current_user.admin? end end # config/routes.rb constraints CanAccessFlipperUI do mount Flipper::UI.app(Flipper) => '/flipper' end ``` ### Standalone Minimal example for Rack: ```ruby # config.ru require 'flipper/ui' adapter = Flipper::Adapters::Memory.new flipper = Flipper.new(adapter) run Flipper::UI.app(flipper) { |builder| builder.use Rack::Session::Cookie, secret: "something long and random" } ``` The key is that you need to have sessions setup. Rails does this for you, so this step isn't necessary, but for standalone rack, you'll need it. Without sessions setup, you will receive a Runtime error like: ``` RuntimeError: you need to set up a session middleware *before* Rack::Protection::RemoteToken. ``` See [examples/ui/basic.ru](https://github.com/flippercloud/flipper/blob/main/examples/ui/basic.ru) for a more full example ### Configuration Flipper UI can be customized via `configure`, which yields a configuration instance. #### Description We can associate a `description` for each `feature` by providing a descriptions source: ```ruby Flipper::UI.configure do |config| config.descriptions_source = ->(keys) do # descriptions loaded from YAML file or database (postgres, mysql, etc) # return has to be hash of {String key => String description} end # Defaults to false. Set to true to show feature descriptions on the list # page as well as the view page. # config.show_feature_description_in_list = true end ``` Descriptions show up in the UI like so:
Viewing flipper feature descriptions in self-hosted UI
Viewing flipper feature descriptions in self-hosted UI
#### Banner Flipper UI can display a banner across the top of the page. The `banner_text` and `banner_class` can be configured by using the `Flipper::UI.configure` block as seen below. ```ruby Flipper::UI.configure do |config| config.banner_text = 'Production Environment' config.banner_class = 'danger' end ``` By default the `environment` is set to an empty string so no banner will show. If you wish to customize the look of the banner, you can set `banner_class` to one of the bootstrap color classes: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, or `dark`. The default `banner_class` is `danger`. The above configuration results in:
Viewing banner in self-hosted UI
Viewing banner in self-hosted UI
#### Actor names Resolve actor ids to human-readable names by providing an actor names source: ```ruby Flipper::UI.configure do |config| config.actor_names_source = ->(actor_ids) { # Lookup actor_ids here and return hash, e.g. { "User;1" => "Dr. Paul Rhoades" } } end ``` #### Fun mode By default, Flipper UI displays a videoclip when there are no flags. The `fun` mode can be configured by using the `Flipper::UI.configure` block as seen below. ```ruby Flipper::UI.configure do |config| config.fun = false end ``` ## Import / Export Flipper UI supports importing and exporting features. This is useful for sharing features between environments or backing up features. - To export a backup file, click Download. This file can be shared with other developers or used to restore features to another environment. You can also import this file into Flipper Cloud for easy migration. - To import a backup file, choose it from the Import form and click Import.
Viewing import and export in self-hosted UI
Viewing import and export in self-hosted UI
--- Source: https://www.flippercloud.io/docs/api # Flipper::Api > See how the Flipper API works and how to use it. API for the [Flipper](https://github.com/flippercloud/flipper) gem. ## Installation Add it to your application's Gemfile with: $ bundle add flipper-api Or install it yourself as: $ gem install flipper-api ## Usage `Flipper::Api` is a mountable application that can be included in your Rails/Ruby apps. In a Rails application, you can mount `Flipper::Api` to a route of your choice: ```ruby # config/routes.rb YourRailsApp::Application.routes.draw do mount Flipper::Api.app(Flipper) => '/flipper/api' end ``` ### Mount Priority - important if using Flipper::UI There can be more than one router in your application. Make sure if you choose a path that begins with the same pattern as where Flipper::UI is mounted that the app with the longer pattern is mounted first. *bad:* ```ruby YourRailsApp::Application.routes.draw do mount Flipper::UI.app(Flipper) => '/flipper' mount Flipper::Api.app(Flipper) => '/flipper/api' end ``` In this case any requests to /flipper\* will be routed to Flipper::UI - including /flipper/api* requests. Simply swap these two to make sure that any requests that don't match /flipper/api\* will be routed to Flipper::UI. *good:* ```ruby YourRailsApp::Application.routes.draw do mount Flipper::Api.app(Flipper) => '/flipper/api' mount Flipper::UI.app(Flipper) => '/flipper' end ```` For more advanced mounting techniques and for suggestions on how to mount in a non-Rails application, it is recommend that you review the [`Flipper::UI` usage documentation](/docs/ui#usage) as the same approaches apply to `Flipper::Api`. ## Endpoints **Note:** Example CURL requests below assume a mount point of `/flipper/api`. ### Get all features **URL** `GET /features` **Request** ``` curl http://example.com/flipper/api/features ``` **Response** Returns an array of feature objects: ```json { "features": [ { "key": "search", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 }, ] }, { "key": "history", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ] } ``` ### Create a new feature **URL** `POST /features` **Parameters** * `name` - The name of the feature (Recommended naming conventions: lower case, snake case, underscores over dashes. Good: foo_bar, foo. Bad: FooBar, Foo Bar, foo bar, foo-bar.) **Request** ``` curl -X POST -d "name=reports" http://example.com/flipper/api/features ``` **Response** On successful creation, the API will respond with an empty JSON response. ### Retrieve a feature **URL** `GET /features/{feature_name}` **Parameters** * `feature_name` - The name of the feature to retrieve **Request** ``` curl http://example.com/flipper/api/features/reports ``` **Response** Returns an individual feature object: ```json { "key": "search", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Delete a feature **URL** `DELETE /features/{feature_name}` **Parameters** * `feature_name` - The name of the feature to delete **Request** ``` curl -X DELETE http://example.com/flipper/api/features/reports ``` **Response** Successful deletion of a feature will return a 204 No Content response. ### Clear a feature **URL** `DELETE /features/{feature_name}/clear` **Parameters** * `feature_name` - The name of the feature to clear **Request** ``` curl -X DELETE http://example.com/flipper/api/features/reports/clear ``` **Response** Successful clearing (removing of all gate values) of a feature will return a 204 No Content response. ## Gates The API supports enabling / disabling any of the Flipper [features](/docs/features). Gate endpoints follow the url convention: **enable** `POST /{feature_name}/{gate_name}` **disable** `DELETE /{feature_name}/{gate_name}` and on a succesful request return a 200 HTTP status and the feature object as the response body. ### Boolean enable a feature **URL** `POST /features/{feature_name}/boolean` **Parameters** * `feature_name` - The name of the feature to enable **Request** ``` curl -X POST http://example.com/flipper/api/features/reports/boolean ``` **Response** Successful enabling of the boolean gate will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "on", "gates": [ { "key": "boolean", "name": "boolean", "value": true }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Boolean disable a feature **URL** `DELETE /features/{feature_name}/boolean` **Parameters** * `feature_name` - The name of the feature to disable **Request** ``` curl -X DELETE http://example.com/flipper/api/features/reports/boolean ``` **Response** Successful disabling of the boolean gate will return a 200 HTTP status and the feature object. ```json { "key": "reports", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Enable Group **URL** `POST /features/{feature_name}/groups` **Parameters** * `feature_name` - The name of the feature * `name` - The name of a registered group to enable **Request** ``` curl -X POST -d "name=admins" http://example.com/flipper/api/features/reports/groups ``` **Response** Successful enabling of the group will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "conditional", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": ["admins"] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Disable Group **URL** `DELETE /features/{feature_name}/groups` **Parameters** * `feature_name` - The name of the feature * `name` - The name of a registered group to disable **Request** ``` curl -X DELETE -d "name=admins" http://example.com/flipper/api/features/reports/groups ``` **Response** Successful disabling of the group will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Enable Actor **URL** `POST /features/{feature_name}/actors` **Parameters** * `feature_name` - The name of the feature * `flipper_id` - The flipper_id of actor to enable **Request** ``` curl -X POST -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors ``` **Response** Successful enabling of the actor will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "conditional", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": ["User;1"] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Disable Actor **URL** `DELETE /features/{feature_name}/actors` **Parameters** * `feature_name` - The name of the feature * `flipper_id` - The flipper_id of actor to disable **Request** ``` curl -X DELETE -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors ``` **Response** Successful disabling of the actor will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Enable Percentage of Actors **URL** `POST /features/{feature_name}/percentage_of_actors` **Parameters** * `feature_name` - The name of the feature * `percentage` - The percentage of actors to enable **Request** ``` curl -X POST -d "percentage=20" http://example.com/flipper/api/features/reports/percentage_of_actors ``` **Response** Successful enabling of a percentage of actors will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "conditional", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 20 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Disable Percentage of Actors **URL** `DELETE /features/{feature_name}/percentage_of_actors` **Parameters** * `feature_name` - The name of the feature **Request** ``` curl -X DELETE http://example.com/flipper/api/features/reports/percentage_of_actors ``` **Response** Successful disabling of a percentage of actors will set the percentage to 0 and return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Enable Percentage of Time **URL** `POST /features/{feature_name}/percentage_of_time` **Parameters** * `feature_name` - The name of the feature * `percentage` - The percentage of time to enable **Request** ``` curl -X POST -d "percentage=20" http://example.com/flipper/api/features/reports/percentage_of_time ``` **Response** Successful enabling of a percentage of time will return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "conditional", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 20 } ] } ``` ### Disable Percentage of Time **URL** `DELETE /features/{feature_name}/percentage_of_time` **Parameters** * `feature_name` - The name of the feature **Request** ``` curl -X DELETE http://example.com/flipper/api/features/reports/percentage_of_time ``` **Response** Successful disabling of a percentage of time will set the percentage to 0 and return a 200 HTTP status and the feature object as the response body. ```json { "key": "reports", "state": "off", "gates": [ { "key": "boolean", "name": "boolean", "value": false }, { "key": "expression", "name": "expression", "value": null }, { "key": "groups", "name": "group", "value": [] }, { "key": "actors", "name": "actor", "value": [] }, { "key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0 }, { "key": "percentage_of_time", "name": "percentage_of_time", "value": 0 } ] } ``` ### Check if features are enabled for an actor **URL** `GET /actors/{flipper_id}` **Parameters** * `keys` - comma-separated list of features to check **Request** ``` curl -X GET http://example.com/flipper/api/actors/User;1?keys=my_feature_1,my_feature_2 ``` **Response** Returns whether the actor with the provided flipper_id is enabled for the specififed feature keys. If no keys are specified all features are returned. ```json { "flipper_id": "User;1", "features": { "my_feature_1": { "enabled": true, }, "my_feature_2": { "enabled": false, } } } ``` ## Errors In the event of an error the Flipper API will return an error object. The error object will contain a Flipper-specific error code, an error message, and a link to documentation providing more information about the error. *example error object* ```json { "code": 1, "message": "Feature not found", "more_info": "https://flippercloud.io/docs/api#error-code-reference", } ``` ### Error Code Reference #### 1: Feature Not Found The requested feature does not exist. Make sure the feature name is spelled correctly and exists in your application's database. #### 2: Group Not Registered The requested group specified by the `name` parameter is not registered. Information on registering groups can be found in the [features documentation](/docs/features). #### 3: Percentage Invalid The `percentage` parameter is invalid or missing. `percentage` must be an integer between 0-100 inclusive and cannot be blank. #### 4: Flipper ID Invalid The `flipper_id` parameter is invalid or missing. `flipper_id` cannot be empty. #### 5: Name Invalid The `name` parameter is missing. Make sure your request's body contains a `name` parameter. #### 7: Expression Invalid The expression is invalid. Every `Any` and `All` group must contain at least one condition. To clear an expression, send a `DELETE` request to the expression gate endpoint instead of posting an empty group. --- Source: https://www.flippercloud.io/docs/cloud # Flipper Cloud > Hosted feature flag management with audit history, environments, permissions, and integrations. ## What is Flipper Cloud? Flipper Cloud is a hosted service for managing feature flags across your team and infrastructure. It builds on top of the [open source Flipper gem](/docs/introduction) and adds collaboration, audit history, permissions, and integrations. ## Your Availability is Not Tied to Ours A common concern with hosted feature flag services is availability — if the service goes down, does your app go down too? With Flipper Cloud, the answer is no. Your application syncs feature flag data from Flipper Cloud and stores it locally. All feature flag checks are evaluated against this local data with no external requests. If Flipper Cloud is unreachable, your app continues working with the last known feature state. There is zero latency impact and zero availability risk. Read more about how this works in [How We Designed Flipper Cloud to Never Take Your App Down](/blog/how-we-designed-flipper-cloud-to-never-take-your-app-down). ## Organizations Organizations group your projects for billing and team management. You can belong to one or more organizations. Each organization has its own members, projects, and subscription. Organization members are automatically granted access to all projects in the organization. ## Projects Projects let you manage feature flags for different applications or services under one organization. Each project has its own [environments](/docs/cloud/environments) and features. All organization members have access to every project. You can also add [project collaborators](/docs/cloud/permissions#project-collaborators) — people outside your organization who need access to a specific project. ## Key Features - **[Environments](/docs/cloud/environments)** — Model your development lifecycle with production, personal, and custom environments. Non-production environments mirror production by default. - **[Organizing Features](/docs/cloud/organizing)** — Keep flags organized with temporary/permanent longevity, feature owners, and tags. - **[Audit History](/docs/cloud/audit-history)** — Track every feature flag change with who, what, and when. Rollback to any previous state with one click. - **[Permissions](/docs/cloud/permissions)** — Control who can modify features with organization roles, project collaborators, and environment-level restrictions. - **[Telemetry](/docs/cloud/telemetry)** — Monitor feature flag evaluation rates, enabled percentages, and usage patterns in real time. - **[Webhooks](/docs/cloud/webhooks)** — Keep your application in sync instantly when feature flags change, instead of waiting for the next poll interval. - **[Slack Integration](/docs/cloud/slack)** — Get notified in Slack whenever feature flags are changed in an environment. - **[Search](/docs/search)** — Find features quickly across all your projects. - **[API](/docs/cloud/api)** — Full REST API for managing features, gates, audits, and telemetry programmatically. --- Source: https://www.flippercloud.io/docs/configuration # Configuration > Flipper Cloud offers a variety of configuration options as well as adapters so you can be confident it works smoothly with your application. With Flipper Cloud, each project environment receives its own set of API tokens so Flipper connects to the correct environment for flag states. So each environment in your application will have its own credentials—except for `test` which uses an in-memory adapter for performance. You'll want to be sure that your credentials correspond to the correct environments for the project in Flipper Cloud. Most often, this would mean setting up the tokens for production and staging environments. Each team member always receives their own local development environment and will need to configure their local settings using that. ## Finding your Secret Tokens {#finding} To find your Flipper Cloud token, go to the "Tokens" settings in the environment settings (Organization > Project > Environment > Settings > Tokens) for the relevant project environment in Flipper Cloud. For the Cloud sync secret—which is optional—go to the "Webhooks" settings (Organization > Project > Environment > Settings > Webhooks) for the relevant environment for the project. Regardless of your configuration approach, the Flipper Cloud `sync_secret` value is optional and uses Flipper Cloud webhooks to perform syncs of your feature data slightly faster than normal. ## Using Environment Variables {#env-var} Environment variables provide the easiest way to configure Flipper Cloud. Set a `FLIPPER_CLOUD_TOKEN` environment variable using [`.dotenv`](https://github.com/bkeepers/dotenv) or any other approach that works with environment variables, and Flipper will recognize it and handle the rest. ```bash FLIPPER_CLOUD_TOKEN= FLIPPER_CLOUD_SYNC_SECRET= ``` ## Using Rails Credentials and an Initializer {#credentials} If you use [Rails credentials](https://guides.rubyonrails.org/security.html#environmental-security), you can add an entry for the Flipper Cloud token to your credentials for each environment. Then you can use an initializer to configure Flipper using the values stored in credentials. Once you have your relevant secrets, edit the credentials files for each of the environments you want to connect to Flipper Cloud. ```bash bin/rails credentials:edit --environment= ``` Then, depending on the version of the Flipper gem you have locally, you can connect credentials to Flipper Cloud with one of two strategies. ### Flipper 1.1 or Newer If you're using version 1.1 or newer of the Flipper gem, it will automatically detect the relevant values from each environment's credentials file as long as the credentials are specified in the following format. ###### `config/credentials/.yml.enc` ```yaml flipper: cloud_token: cloud_sync_secret: ``` If your credentials files use a different organization, you can use a Flipper configuration block to set up the values for different sets of keys based on the structure in your credentials files. See the next section on configuring Flipper 1.0 or earlier for an example. ### Flipper 1.0 or Earlier If you're using version 1.0 or earlier, you can load the credentials in a Flipper configuration block. In addition to configuring tokens, Flipper offers a variety of other configuration options. View all [`Flipper configuration options`](https://github.com/flippercloud/flipper/blob/main/lib/flipper/cloud/configuration.rb). ###### `config/initializers/flipper.rb` ```ruby Flipper.configure do |config| config.default do options = { token: Rails.application.credentials.dig(:flipper, :cloud_token), sync_secret: Rails.application.credentials.dig(:flipper, :cloud_sync_secret), } Flipper::Cloud.new(options) end end ``` --- Source: https://www.flippercloud.io/docs/cloud/environments # Environments > Model your development lifecycle with production, personal, and custom environments in Flipper Cloud. ## Overview Environments allow you to vary feature enablement depending on where your code is running. A typical setup mirrors your deployment pipeline — production, staging, QA, and local development — so you can enable features in one context without affecting another. Every project starts with a production environment and a personal environment for each team member. You can add custom environments (staging, QA, etc.) as needed. ## Production Environment Each project has exactly one production environment. It serves as the source of truth — all other environments mirror production by default. When you enable a feature in production, it's automatically enabled everywhere else unless an environment has explicitly overridden it. ## Production Mirroring Non-production environments mirror production by default. This means every environment works like production out of the box without any additional configuration. If you need a feature to behave differently in a specific environment, you can override it. For example, you might disable a feature in production but enable it in your personal environment for local development. Overriding a feature in one environment has no effect on any other environment. You can return an overridden feature to mirrored state at any time with a single click. ## Personal Environments Every team member gets their own personal environment for each project they belong to. Personal environments are: - **Private** — only visible to the person they belong to - **Isolated** — changes don't affect anyone else - **Automatic** — created when a member joins the project, removed when they leave Personal environments are ideal for local development. Enable or disable features freely without worrying about impacting other team members or shared environments. ## Custom Environments Beyond production and personal environments, you can create any number of custom environments to match your workflow. Common examples include canary, staging, and QA. Custom environments mirror production by default, just like personal environments. You can override individual features as needed and control who has access to modify feature state through [environment permissions](/docs/cloud/permissions#environment-permissions). ## API Tokens Each environment has its own API tokens for authenticating your application. Tokens are scoped to a single environment, so your staging application only sees staging feature state. You can create multiple tokens per environment, allowing for rotation without downtime. Generate a new token, update your application configuration, then archive the old token. --- Source: https://www.flippercloud.io/docs/cloud/permissions # Permissions > Control access to your Flipper Cloud organization, projects, and environments with role-based permissions. ## Overview Flipper Cloud provides role-based access control at three levels: organization, project, and environment. On Free, Bronze, and Silver plans, all non-billing organization members are administrators with full access. Cloud Gold and higher plans unlock granular permissions so you can restrict access as your team grows. ## Organization Roles Organization memberships use one of three roles: - **Admin** — Full control over the organization, including billing, projects, environments, team members, and features. - **Member** — Can view projects and manage features according to each environment's permissions. Cannot invite team members or manage organization settings. - **Billing** — Can only manage subscription and billing information. Cannot access projects or features. Billing managers are available on every paid plan and its trial, are always free, and do not count toward seat limits. On Free, Bronze, and Silver plans, new non-billing members default to the admin role. On Cloud Gold and higher plans with advanced permissions, new members default to the member role. Every organization must have at least one admin. ## Project Collaborators Organization members automatically have access to all projects in the organization. You can also grant access to people outside your organization by adding them as project collaborators. Collaborators can view and manage features in the projects they're added to, but they don't have access to other projects or organization settings. On plans with advanced permissions, organization admins can promote project collaborators to full organization members. ## Environment Permissions Each environment can be configured to control who can enable, disable, and rollback feature flags: - **All project members** (default) — Anyone with access to the project can modify features in this environment. - **Organization members only** — Only organization members can modify features. Project collaborators can view but not change feature state. - **Environment owners only** — Only hand-picked environment owners can modify features. Everyone else can view but not change feature state. Environment permissions apply to enabling, disabling, and rolling back feature flags. Viewing feature state is available to all project members regardless of the environment's permission setting. Personal environments are always controlled exclusively by the person they belong to. ## Trusted Domains Organization admins on supported plans can configure trusted domains for automatic team provisioning. When a user signs in with Google using an email address from a verified domain, they're automatically added to the organization. To set up a trusted domain: 1. Go to your organization's settings. 2. Add your domain and select the default role for new members. 3. Verify ownership by adding a DNS TXT record. Once verified, anyone signing in with a matching email domain is automatically added to your organization with the configured role, as long as seats are available. ## Two-Factor Authentication Anyone can turn on two-factor authentication from **Profile → Two-Factor**. Scan the QR code with an authenticator app like 1Password, Google Authenticator, or Authy, then enter the 6-digit code it shows. You'll get 10 one-time recovery codes. Save them somewhere safe: each one signs you in once if you lose your device. With two-factor on, signing in with your email and password also asks for a code. Signing in with GitHub or Google doesn't, unless one of your organizations requires two-factor. ### Requiring two-factor for an organization Organization admins can require two-factor in the organization's settings under **Security**. Turn on two-factor for your own account first. Once it's required, members and project collaborators are asked to set up two-factor (or enter a code, if they already use it) before they can keep using Flipper Cloud, including their other organizations. This applies to people who sign in with GitHub or Google too, since Flipper Cloud can't tell whether those accounts use two-factor. Two-factor protects signing in to the Flipper Cloud website. API tokens and personal API keys keep working without it, so treat them like passwords. --- Source: https://www.flippercloud.io/docs/cloud/organizing # Organizing Features > Keep your feature flags organized with longevity, owners, and tags in Flipper Cloud. ## Overview As the number of feature flags in a project grows, it helps to have tools for keeping them organized. Flipper Cloud provides three ways to manage your features: marking them as temporary or permanent, assigning owners, and tagging. ## Temporary vs Permanent Every feature flag has a longevity setting — temporary or permanent. This communicates intent about a flag's lifecycle and helps your team know which flags are safe to clean up. - **Temporary** — The flag supports work in progress and should be removed once the work is complete. This is the default for new flags. - **Permanent** — The flag is long-lived and serves an ongoing purpose like maintenance mode, infrastructure controls, or plan-based access. Remove with care. Marking flags as temporary or permanent makes it easy to identify stale flags that have outlived their purpose and are ready to be cleaned up. ## Feature Owners Assign an owner to each feature flag so your team knows who to ask when they have questions. The owner is typically the person responsible for the feature's rollout or the team lead for that area of the product. Owners are selected from project members and displayed on the feature's detail page. When ownership changes, the change is recorded in the [audit history](/docs/cloud/audit-history). ## Tags Tags let you group related features across your project. Add one or more tags to a feature and then filter the feature list by tag to focus on what matters. Common tagging strategies include: - **By team** — `payments`, `onboarding`, `platform` - **By initiative** — `q1-launch`, `redesign`, `migration` - **By area** — `api`, `dashboard`, `mobile` Tags are free-form text, normalized to lowercase. As you add tags, Flipper Cloud suggests frequently used tags from your project so your team stays consistent. --- Source: https://www.flippercloud.io/docs/cloud/audit-history # Audit History > Track every feature flag change with a complete audit trail and one-click rollbacks in Flipper Cloud. ## Overview On paid plans, Flipper Cloud keeps an audit trail of every feature flag change. You can see who changed a feature, when they changed it, and exactly what changed. Audit history is available on each feature's detail page within an environment. ## What Gets Tracked Every feature flag action is recorded, including: - Feature enabled or disabled - Actor added or removed - Group enabled or disabled - Percentage of actors or time changed - Expression enabled or disabled - Gates cleared - Feature created or removed - Feature mirrored from production - Feature rolled back to a previous state Each audit entry records the person or API token that made the change, their IP address, and the complete feature state after the change was applied. ## One-Click Rollbacks Made a mistake? Rollback to any previous state with a single click. Each audit entry captures a complete snapshot of the feature's gate configuration at that point in time. When you rollback, the feature is restored to exactly the state it was in after that change — including all actors, groups, percentages, and expressions. Rollbacks are themselves audited, so you always have a record of what happened and can rollback a rollback if needed. ## Retention Audit history is available on paid plans. How long it is retained depends on your plan. Higher (and yearly) plans retain more history. See the [pricing page](/pricing) for details. ## API Access On paid plans, audit history is available through the [Cloud API](/docs/cloud/api#audits). You can list audits with pagination and filter by feature key. --- Source: https://www.flippercloud.io/docs/cloud/telemetry # Telemetry > Monitor feature flag usage with real-time telemetry in Flipper Cloud. ## Overview Telemetry tracks how your feature flags are being evaluated in production. It shows you how often each flag is checked and what percentage of evaluations are enabled vs disabled over time. ## How It Works The Flipper client gem automatically collects evaluation metrics as your application runs. Metrics are batched and periodically sent to Flipper Cloud in the background with no impact on your application's performance. For each feature flag evaluation, the client records: - The feature key - Whether the result was enabled or disabled - The count of evaluations ## What You See On each feature's detail page, telemetry displays: - **Enabled Rate** - The percentage of evaluations that returned enabled over time. - **Request Rate** - Total evaluation throughput displayed in adaptive units (requests per second, minute, or hour depending on volume). - **Last Check** - When the feature was last evaluated in that environment. Charts default to a 24-hour view with hourly resolution. Depending on your plan, you can view up to 90 days of history with daily resolution. ## Telemetry Summary API The telemetry summary API (`GET /adapter/telemetry/summary`) returns evaluation metrics combined with flag configuration context. Each feature in the response includes its description, longevity (temporary or permanent), tags, creator, owner, creation date, current state, and a gates summary with counts of enabled actors, groups, and percentages. This makes it possible to reason about flag lifecycle from a single API call — for example, finding temporary flags that have been fully enabled for months and routing each one to its owner for cleanup. See the [Cloud API docs](/docs/cloud/api#telemetry) for the full response shape. Malformed summary selectors return JSON `400` or `422` responses. Telemetry submissions reject malformed or non-object JSON, unsupported encodings, gzip framing errors, and bodies larger than 256 KiB compressed or 1 MiB expanded before queueing or persistence. ## Use Cases - **Verify rollouts** - Confirm that a percentage rollout is reaching the expected proportion of users. - **Identify unused flags** - Find features that are no longer being evaluated and are safe to remove. - **Monitor adoption** - Track how quickly a newly enabled feature is being used. - **Debug issues** - Correlate feature flag changes with changes in evaluation patterns. --- Source: https://www.flippercloud.io/docs/cloud/webhooks # Webhooks > Keep your application in sync with Flipper Cloud using webhooks for instant feature flag updates. ## Overview Webhooks notify your application instantly when feature flags change in Flipper Cloud. Instead of waiting for the next poll interval, your app receives a request telling it to sync — keeping feature state up to date within seconds of a change. ## How It Works Each environment can have one or more webhooks. When a feature flag changes in that environment, Flipper Cloud sends an HTTP POST request to your webhook URL. Your application receives the request and syncs its local feature state with Cloud. If you're using the Flipper client gem, webhook handling is built in. The gem exposes a webhook receiver endpoint that processes incoming webhooks and updates your local feature data automatically. ## Setup 1. Navigate to the environment you want to add a webhook to. 2. Go to **Settings** and click **New Webhook**. 3. Enter the URL where your application will receive webhook requests. 4. Copy the generated webhook secret for signature verification. ## Payload Webhook requests are HTTP POST with a JSON body: ```json { "environment_id": 123, "webhook_id": 456, "delivery_id": "467dd251-b5e9-44d1-b490-539a97ef0983", "action": "sync" } ``` Each delivery has a unique `delivery_id` that can be used for idempotency — if your application receives the same `delivery_id` more than once, it can safely skip the duplicate. ## Signature Verification Every webhook request includes a `Flipper-Cloud-Signature` header containing an HMAC-SHA256 signature. Use your webhook secret to verify the signature and confirm the request came from Flipper Cloud. The signature header includes both the signature and a timestamp to protect against replay attacks. ## Retries If your application returns a server error (5xx) or doesn't respond within 20 seconds, Flipper Cloud retries the delivery with exponential backoff. Retries continue for up to 13 attempts over approximately one day. Client errors (4xx) are not retried — these indicate a problem with your endpoint configuration rather than a transient failure. ## Managing Webhooks From the environment's settings page you can: - **Enable/Disable** — Toggle a webhook on or off without deleting it. - **Send Test** — Verify the webhook is working by sending a test request. - **Regenerate Secret** — Generate a new signing secret if the current one is compromised. - **View Delivery History** — See past deliveries with status, duration, and error details. ## Webhooks vs Polling Your application can stay in sync with Flipper Cloud through either webhooks or polling: - **Polling** checks for updates on an interval (configurable per plan). It's simpler to set up but introduces a delay between when a change is made and when your application sees it. - **Webhooks** push updates to your application immediately. They require your application to be reachable from the internet but provide near-instant synchronization. You can use both together. Polling acts as a safety net that catches any updates a webhook might miss, while webhooks ensure changes are reflected quickly. Regardless of which approach you use, feature flag data is always stored and evaluated locally in your application. If Flipper Cloud is temporarily unreachable, your app continues working with the last known state. Read more about [how Flipper Cloud is designed to never take your app down](/blog/how-we-designed-flipper-cloud-to-never-take-your-app-down). --- Source: https://www.flippercloud.io/docs/cloud/slack # Slack Integration > Receive Slack notifications when feature flags change in your Flipper Cloud environments. ## Overview The Slack integration sends notifications to a Slack channel whenever feature flags are changed in an environment. This helps your team stay informed about feature flag changes in real time. ## Setup 1. Navigate to the environment you want to integrate with Slack. 2. Go to **Integrations** and click **New Slack Integration**. 3. Click **Add to Slack** to start the OAuth flow. 4. Select the Slack workspace and channel where you want notifications sent. 5. The integration is created and immediately active. ## Notifications Slack notifications are sent for all feature flag changes, including: - Feature enabled or disabled - Actor added or removed - Group enabled or disabled - Percentage of actors or time changed - Gates cleared - Feature created or removed - Feature mirrored from another environment - Feature rolled back - Expression enabled or disabled Each notification includes the feature name, action taken, environment, who made the change, and a link to view the feature in Flipper Cloud. ## Managing Integrations You can manage integrations from the environment's Integrations page: - **Enable/Disable** - Toggle an integration on or off without deleting it. - **Send Test** - Verify the integration is working by sending a test message. - **Description** - Add a description to help identify the integration's purpose. - **Delivery History** - View past deliveries with status and timing information. ## Troubleshooting If an integration stops working (e.g., the Slack channel is deleted or the app is removed from the workspace), it will be automatically marked as failed after several consecutive delivery failures. Organization admins receive an email when this happens. To fix a failed integration, delete it and create a new one with the updated channel. --- Source: https://www.flippercloud.io/docs/cloud/mcp # MCP Server > Connect Claude Code, Codex, Cursor and other AI assistants to Flipper Cloud with its MCP server, then ask which feature flags are ready to remove, or have it create, change and remove flags for you. Flipper Cloud runs a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server, so AI assistants like Claude Code, Codex and Cursor can work with your feature flags. Ask "Which Flipper flags can we remove?" and your assistant checks every environment, your telemetry and your audit history, then tells you which flags are done and why. Allow it, and it can also create flags, turn them on and off, and remove them. An assistant acts as you. It sees only what you can see, changes only what your role allows, and does only what you allowed when you connected it. ## Connect The server lives at `https://www.flippercloud.io/mcp` and uses the streamable HTTP transport. Connect by signing in with your Flipper Cloud account, or with an API key. ### Sign in Add the server URL to your assistant. The first time it connects, a browser window asks you to sign in to Flipper Cloud and choose what the assistant can do. In Claude (claude.ai and the desktop app), go to **Settings → Connectors**, choose **Add custom connector**, and enter `https://www.flippercloud.io/mcp`. ###### Claude Code ```bash claude mcp add --transport http flipper-cloud https://www.flippercloud.io/mcp ``` Then run `/mcp` in Claude Code and choose **Authenticate**. ###### Cursor (~/.cursor/mcp.json, or .cursor/mcp.json in a project) ```json { "mcpServers": { "flipper-cloud": { "url": "https://www.flippercloud.io/mcp" } } } ``` Any other MCP client that supports OAuth works the same way. A connection acts as you, with what you allowed. It stays signed in until you disconnect it under **Profile → [API Keys](/profile/api-keys)** or change your password. ### Or use an API key For clients that don't support OAuth, or scripts. Go to **Profile → [API Keys](/profile/api-keys)** and create a key. It's shown once, so copy it somewhere safe, like a `FLIPPER_CLOUD_API_KEY` environment variable. Choose what it can do when you create it, and change that any time with **Edit**. A key acts as you, just like a connection, and stops working the moment you revoke it. ###### Claude Code ```bash claude mcp add --transport http flipper-cloud https://www.flippercloud.io/mcp --header "Authorization: Bearer $FLIPPER_CLOUD_API_KEY" ``` ###### Codex (~/.codex/config.toml, with the key in FLIPPER_CLOUD_API_KEY) ```toml [mcp_servers.flipper-cloud] url = "https://www.flippercloud.io/mcp" bearer_token_env_var = "FLIPPER_CLOUD_API_KEY" ``` Any MCP client that can send an `Authorization: Bearer` header over HTTP works. ## What it can do Each connection or key can view your flags, and does only the other things you check for it. A new API key starts with View alone: | Choice | Lets your assistant | |---|---| | View (always) | See your organizations, projects and feature flags | | Create flags | Add flags to a project. A new flag starts off in every environment | | Change flags outside production | Turn flags on or off in every environment except production, for everyone or for actors, groups, percentages and expressions | | Change flags in production | Turn flags on or off in production, the same ways | | Remove flags | Delete flags from a project, which removes them from every environment | - **Each choice stands alone.** An assistant can add flags without turning them on, try them in staging without touching production, or clean up old flags without changing live ones. - **Removing a flag that's on turns it off**, so it also needs the choice for changing flags wherever the flag is on. - **Production and removal start unchecked.** When an assistant signs in, the screen starts with what it asked for, but at most creating flags and changing them outside production. Tick the rest yourself if you want them. - **Your role still decides.** A choice is a ceiling: in a project where you can only view, your assistant can only view. - **Changes are recorded as yours.** Each one shows in the flag's [audit history](/docs/cloud/audit-history) under your name and sends your webhooks and Slack notifications, just like a change you make in Flipper Cloud. - **Changing your mind.** Edit a key's choices under **Profile → [API Keys](/profile/api-keys)**. For a connected app, disconnect it there and connect again to choose anew. ## Ask about your flags Try prompts like these: - "Which Flipper flags can we clean up in the Billing project?" - "Is the `new_checkout` flag safe to remove? Who owns it?" - "Remove the flags that are fully enabled everywhere from this codebase, keeping the enabled code path." - "Create a `new_onboarding` flag in the Web project and turn it on for 10% of actors in staging." - "Turn `new_checkout` on for the `staff` group in production." - "We've deployed the cleanup. Delete the flags we just removed from the code." ## How it finds flags to remove A flag is only done once it's settled in every environment, so the server looks at all of a project's shared environments together. Each candidate comes with its reasons and how confident to be: | Reason | Confidence | Means | |---|---|---| | `fully_enabled` | High | On for everyone in every environment | | `fully_disabled` | High | Off in every environment | | `always_true` | Verify | Conditionally enabled, but every check in the window returned true | | `always_false` | Verify | Conditionally enabled, but every check in the window returned false | | `not_evaluated` | Verify | Your apps send telemetry, but nothing checked the flag in the window | - **Settling flags wait.** A flag created or changed in the last 7 days isn't a candidate yet. - **Permanent flags are skipped** unless you ask for them. Set a flag's longevity to permanent when you create or edit it. - **Usage-based reasons need [telemetry](/docs/cloud/telemetry) from every environment.** If only staging sends telemetry, a flag production never checks could look always true, so the server holds those reasons back and says telemetry is partial. - **Removing a flag takes three steps:** remove the check from your code, deploy, then delete the flag from Flipper Cloud. Deleting it first means your code falls back to the flag being off. ## Tools | Tool | What it returns | |---|---| | `whoami` | The person the key belongs to and their organizations | | `list_projects` | Projects you can see, with their shared environments and whether the plan includes telemetry | | `list_cleanup_candidates` | A project's flags that look ready to remove, strongest first. Takes `project_id`, plus optional `days` of telemetry (30 by default, up to your plan's retention), `include_permanent` and `limit` | | `get_feature` | One flag's description, owner, tags, state and checks in each environment, and its latest changes. Takes `project_id` and `key` | These change flags, and are listed only when the connection may use them. The gate tools take the `project_id`, an `environment_id` from `list_projects` and the flag's `key`, and need the choice for changing flags in that environment: in production or outside it. | Tool | What it does | |---|---| | `create_feature` | Adds a flag to a project, off everywhere. Needs Create flags. Takes `project_id`, `key` and an optional `description` | | `enable_feature`, `disable_feature` | Turns a flag fully on or fully off for everyone. Turning it off clears its other gates | | `enable_actor`, `disable_actor` | Adds or removes one actor. Takes `actor_id` | | `enable_group`, `disable_group` | Adds or removes a group your app registers. Takes `group` | | `enable_percentage_of_actors` | Turns it on for a percentage of actors, 0 to 100. Takes `percentage` | | `enable_percentage_of_time` | Turns it on for a random percentage of checks, 0 to 100. Takes `percentage` | | `enable_expression`, `disable_expression` | Sets or removes an [expression](/docs/features/expressions). Takes `expression` | | `remove_feature` | Deletes a flag from every environment. Needs Remove flags. Takes `project_id` and `key` | ## Privacy Assistants see your teammates' names where they've set one, never their email addresses (`whoami` shows only your own). They never see your customers' actor IDs: gates are shown as counts, and actor and expression values are left out of a flag's history. Change history follows your plan's [audit history](/docs/cloud/audit-history) retention. ## Limits Each key or connected app can make 120 requests a minute. Over that, the server answers `429` with a `Retry-After` header. --- Source: https://www.flippercloud.io/docs/search # Search > Use Command+K to quickly navigate Flipper Cloud Flipper Cloud includes a [powerful search feature](/blog/early-gifts-under-the-tree#super-search) that lets you quickly navigate to any feature, tag, environment, project, or organization. ## Opening Search Press `Cmd+K` on Mac or `Ctrl+K` on Windows/Linux to open the search modal. You can also click the search button in the navigation sidebar. ## What You Can Search - **Features** - Search by feature key name - **Tags** - Search by tag name and jump to that project's features with the tag filter applied - **Organizations** - Search by organization name - **Projects** - Search by project name - **Environments** - Search by environment name (including "Your Environment" or "My Environment" for personal environments) ## Creating a Feature When nothing matches, search lists the projects where you can create features. Pick one to open the new feature form with the name you typed filled in. The project you're viewing comes first. ## Quick Actions When you're viewing a specific organization, project, or environment, contextual quick actions appear in search results. These let you quickly navigate to related pages. ### Organization Quick Actions When viewing an organization: - **Members** - View and manage organization members - **Billing** - Access subscription and billing settings ### Project Quick Actions When viewing a project: - **Collaborators** - View and manage project collaborators - **Project Settings** - Access project configuration ### Environment Quick Actions When viewing an environment: - **History** - View the audit log of feature changes - **Credentials** - Manage API tokens - **Webhooks** - Configure webhook integrations - **Access** - Manage environment permissions - **Actors** - View and manage individual actors - **Groups** - View and manage actor groups - **Analytics** - View feature usage analytics Quick actions are searchable by name and common keywords. For example, typing "hist" or "audits" will match the History quick action. ## Keyboard Navigation - `↑` `↓` - Navigate through results - `Enter` - Open the selected result - `Esc` - Close search ## Result Ordering Search results are ordered with features appearing first, followed by tags, quick actions, then organizations, projects, and environments. ## Related - [Organizing and Managing Feature Flags](/benefits/organization) - Learn how search fits into Flipper Cloud's organizational features - [Concepts](/docs/cloud) - Understand organizations, projects, and environments --- Source: https://www.flippercloud.io/docs/cloud/api # Cloud API > Flipper Cloud API reference including features, gates, audits, and telemetry endpoints. ## Overview The Flipper Cloud API is available at `https://www.flippercloud.io/adapter`. It includes all of the [open source Flipper API](/docs/api) endpoints plus Cloud-specific endpoints for audits and telemetry. ## Authentication All requests require a token sent via the `Flipper-Cloud-Token` header: ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features ``` Tokens are scoped to a specific environment. You can create and manage tokens in your environment's settings. The [Organization API](#organization) at `https://www.flippercloud.io/api/v1` uses organization API tokens instead. Environment tokens don't work there, and organization API tokens don't work with `/adapter`. ### Token access levels {#token-access-levels} - **Read Only** tokens can evaluate features but cannot change them. Use Read Only for production applications and any client that only needs to evaluate flags. - **Read/Write** tokens can evaluate and change features. Use Read/Write for personal, development, and test environments where the application or automation needs to change flags. **Manage preview environments** is a separate permission from the access level. It lets a stable token create preview environments and delete the environments it created, but does not grant permission to change features. Enable it on a dedicated read-only preview automation token in a stable custom environment such as `previews`, rather than on a production application token. ## Features ### List All Features `GET /adapter/features` ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features ``` ```json { "features": [ { "key": "search", "state": "on", "gates": [ {"key": "boolean", "name": "boolean", "value": true}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ] } ``` Responses include these headers: - `flipper-sync-version`: a number that increases every time a feature in the environment changes, including changes inherited from production. It never decreases, so a response with a lower number is older. - `poll-interval`: the recommended number of seconds between polls for this token. ### Get a Feature `GET /adapter/features/{feature_name}` - `feature_name` - The name of the feature to retrieve ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/search ``` ```json { "key": "search", "state": "on", "gates": [ {"key": "boolean", "name": "boolean", "value": true}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ``` ### Create a Feature `POST /adapter/features` - `name` - The name of the feature to create ```bash curl -X POST -d "name=new_dashboard" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features ``` Returns an empty JSON response on success. Feature names starting with `__flipper` are reserved for Flipper's internal use. Creating one, or enabling or disabling a gate on one, returns `422 Unprocessable Entity` and changes nothing. ### Delete a Feature `DELETE /adapter/features/{feature_name}` - `feature_name` - The name of the feature to delete Features belong to the project, so deleting a feature removes it from every environment. This endpoint requires a writable Production environment token. Requests using other environment tokens return `403 Forbidden`; you can also delete the feature in Flipper Cloud. ```bash curl -X DELETE -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard ``` Successful deletion returns a 204 No Content response. ### Clear a Feature `DELETE /adapter/features/{feature_name}/clear` - `feature_name` - The name of the feature to clear ```bash curl -X DELETE -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/clear ``` Removes all gate values and returns a 204 No Content response. ### Import Features `POST /adapter/import` Replaces the token's environment with the features in a Flipper export file, the same JSON that `Flipper.export` produces. This is what `flipper cloud push` uses. Features and gate values that aren't in the file are removed. Features belong to the project, so removing one removes it from every environment. Only writable Production environment tokens can import a file that leaves out existing features. With any other token, the file must include every feature in the project. Otherwise the request returns `403 Forbidden` and changes nothing. A file containing a feature whose name starts with `__flipper` returns `422 Unprocessable Entity` and changes nothing. Those names are reserved for Flipper's internal use. ```bash curl -X POST -H "Content-Type: application/json" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ --data-binary @flipper.json \ https://www.flippercloud.io/adapter/import ``` A successful import returns a 204 No Content response. If the environment has an expression the client's flipper can't read, the import returns `409 Conflict` and changes nothing, because the client can't see the expression it would replace. That's a [Version (`SemVer`) expression](/docs/features/expressions#semver) for flipper 1.4.2 or older, or a [feature dependency (`FeatureEnabled`)](/docs/features/expressions#feature-dependencies) for flipper 1.3.6 or older. Upgrade flipper first. ## Gates All gate endpoints return a 200 HTTP status and the updated feature object on success. ### Boolean `POST /adapter/features/{feature_name}/boolean` - Enable for everyone `DELETE /adapter/features/{feature_name}/boolean` - Disable ```bash curl -X POST -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/boolean ``` ```json { "key": "new_dashboard", "state": "on", "gates": [ {"key": "boolean", "name": "boolean", "value": true}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ``` ### Actors `POST /adapter/features/{feature_name}/actors` - Enable for an actor `DELETE /adapter/features/{feature_name}/actors` - Disable for an actor - `flipper_id` - The identifier of the actor (e.g., `User;123`) ```bash curl -X POST -d "flipper_id=User;123" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/actors ``` ```json { "key": "new_dashboard", "state": "conditional", "gates": [ {"key": "boolean", "name": "boolean", "value": false}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": ["User;123"]}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ``` ### Groups `POST /adapter/features/{feature_name}/groups` - Enable for a group `DELETE /adapter/features/{feature_name}/groups` - Disable for a group - `name` - The name of a registered group ```bash curl -X POST -d "name=admins" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/groups ``` ```json { "key": "new_dashboard", "state": "conditional", "gates": [ {"key": "boolean", "name": "boolean", "value": false}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": ["admins"]}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ``` ### Percentage of Actors `POST /adapter/features/{feature_name}/percentage_of_actors` - Set percentage `DELETE /adapter/features/{feature_name}/percentage_of_actors` - Clear percentage - `percentage` - Integer between 0-100 ```bash curl -X POST -d "percentage=25" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/percentage_of_actors ``` ```json { "key": "new_dashboard", "state": "conditional", "gates": [ {"key": "boolean", "name": "boolean", "value": false}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 25}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 0} ] } ``` ### Percentage of Time `POST /adapter/features/{feature_name}/percentage_of_time` - Set percentage `DELETE /adapter/features/{feature_name}/percentage_of_time` - Clear percentage - `percentage` - Integer between 0-100 ```bash curl -X POST -d "percentage=50" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ https://www.flippercloud.io/adapter/features/new_dashboard/percentage_of_time ``` ```json { "key": "new_dashboard", "state": "conditional", "gates": [ {"key": "boolean", "name": "boolean", "value": false}, {"key": "expression", "name": "expression", "value": null}, {"key": "groups", "name": "group", "value": []}, {"key": "actors", "name": "actor", "value": []}, {"key": "percentage_of_actors", "name": "percentage_of_actors", "value": 0}, {"key": "percentage_of_time", "name": "percentage_of_time", "value": 50} ] } ``` ### Expression `POST /adapter/features/{feature_name}/expression` - Set an expression `DELETE /adapter/features/{feature_name}/expression` - Clear the expression Send the expression as a JSON request body. Every `Any` and `All` group must contain at least one condition. To remove every condition, use `DELETE` instead of posting an empty group. Empty groups return HTTP 422 with the `expression_invalid` error. Flipper 1.4.2 and older can't evaluate a Version (`SemVer`) expression, and flipper 1.3.6 and older can't evaluate a feature dependency (`FeatureEnabled`). Requests from those clients read that feature's expression as `null`. Setting or clearing that expression from one of them returns `409 Conflict` and leaves it unchanged. Upgrade flipper to change it. ```bash curl -X POST \ -H "Content-Type: application/json" \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ -d '{"All":[{"Equal":[{"Property":["plan"]},{"String":["pro"]}]}]}' \ https://www.flippercloud.io/adapter/features/new_dashboard/expression ``` ## Actors ### Check Features for an Actor `GET /adapter/actors/{flipper_id}` - `keys` - Comma-separated list of features to check (optional, returns all features if omitted) ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ "https://www.flippercloud.io/adapter/actors/User;123?keys=new_dashboard,search" ``` ```json { "flipper_id": "User;123", "features": { "new_dashboard": { "enabled": true }, "search": { "enabled": false } } } ``` ## Environments {#environments} Create and delete custom environments for the project your token belongs to. These endpoints are intended for temporary preview environments, such as pull request or branch previews. Only custom environments are affected. Production and personal environments are never created or deleted by these endpoints. Creating an environment counts against your plan's custom environment limit. Use two tokens for preview environments: 1. Create a dedicated stable custom environment such as `previews`. In it, create a read-only token named something like `Preview Environments` with **Manage preview environments** enabled. Use it to create and delete preview environments. Avoid using a production application token for preview automation. 2. Use the token returned by the create endpoint inside the preview app itself. The returned preview app token cannot create more environments. Keep it available until teardown because it can delete its own environment if the preview automation token has been rotated or disabled. ### Create an Environment `POST /adapter/environments` - `name` - The name of the environment to create (required). Names that generate reserved slugs like `new`, `edit`, or `admin` are rejected. ```bash curl -X POST -d "name=pr-1234" \ -H "Flipper-Cloud-Token: PREVIEW_ENVIRONMENT_MANAGER_TOKEN" \ https://www.flippercloud.io/adapter/environments ``` ```json { "environment": { "id": 42, "slug": "pr-1234", "name": "pr-1234", "state": "other", "created_at": "2026-01-15T12:00:00Z" }, "token": { "name": "API", "access": "read_and_write", "value": "Mb72kngHcVSLGefYptt2JvX5" } } ``` The response includes a read-write token scoped to the new environment. Use its `value` as the `Flipper-Cloud-Token` for that preview app. You can safely call create more than once with the same token and name. If the environment already exists and was created by that token, Flipper Cloud returns it instead of creating a duplicate. Existing matching environments return `200`; newly created environments return `201`. If another token or the web dashboard created the environment with that name, the request returns `409` with an `environment_name_taken` code. If your plan's custom environment limit has been reached, the request returns `402` with a `custom_environments_limit` code. #### Create errors | Status | Code | Meaning | | --- | --- | --- | | `402` | `custom_environments_limit` | The project has reached its plan's custom environment limit. | | `403` | `preview_environment_management_token_required` | The token cannot manage preview environments. Preview app tokens never have this capability. | | `403` | `organization_membership` | The token owner no longer has the organization access required for this project. | | `403` | `project_membership` | The token owner no longer has access to this project. | | `409` | `environment_name_taken` | The name belongs to an environment not created by this token. | | `422` | `name_missing` | The request did not include a usable name. | | `422` | `name_invalid` | The name cannot produce a valid, non-reserved slug. | | `422` | `token_limit` | Flipper Cloud could not create a returned token because the environment reached its active token limit. | ### Delete an Environment `DELETE /adapter/environments/{id}` - `id` - The environment ID returned by create. ```bash curl -X DELETE \ -H "Flipper-Cloud-Token: PREVIEW_ENVIRONMENT_MANAGER_TOKEN" \ "https://www.flippercloud.io/adapter/environments/42" ``` Deletes the custom environment, including its tokens, gates, and audits. Authenticate with the preview-environment management token that created it. The returned preview app token can also delete its own environment. Other tokens receive `403` with a `not_environment_creator` code. Deleting an environment that is already gone, or is not a custom environment, returns `204`. Successful deletion also returns `204 No Content`. Repeated calls with the creating preview-environment management token are safe, and the ID remains the same if the environment is renamed in the dashboard. #### Delete errors | Status | Code | Meaning | | --- | --- | --- | | `403` | `not_environment_creator` | The token is neither the environment's creator token nor its returned preview token. | | `403` | `organization_membership` | The token owner no longer has the organization access required for this project. | | `403` | `project_membership` | The token owner no longer has access to this project. | | `422` | `environment_id_required` | The path did not include a valid positive environment ID. | ## Audits {#audits} ### List Audits `GET /adapter/audits` Audit history is available on paid plans. Free-plan responses preserve the same response shape, but return an empty `audits` array and a `limits` object with `"limited": true` and `"max_events": 0`. - `page` - Page number (default: 1) - `per_page` - Records per page (default: 100, max: 250) - `keys` - Comma-separated feature keys to filter by `page`, `per_page`, and `keys` must be scalar, valid UTF-8 query parameters. Invalid numeric values, container-shaped values, conflicting Rack shapes, and malformed encodings return a JSON `400` or `422` response. ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ "https://www.flippercloud.io/adapter/audits?per_page=10" ``` ```json { "audits": [ { "action": "enable", "actor": { "type": "User", "id": "123" }, "target": { "type": "Feature", "key": "new_dashboard" }, "value": null, "created_at": "2026-01-15T12:00:00Z" } ], "pagination": { "page": 1, "per": 10, "previous": null, "next": 2 }, "limits": { "limited": false } } ``` Audit actions include: `enable`, `disable`, `enable_actor`, `disable_actor`, `enable_group`, `disable_group`, `percentage_of_actors`, `percentage_of_time`, `clear`, `create`, `remove`, `mirror`, `rollback`, `enable_expression`, `disable_expression`. ## Telemetry {#telemetry} ### Submit Telemetry `POST /adapter/telemetry` Submit feature flag evaluation metrics. This is typically handled automatically by the Flipper client gem. The endpoint accepts the content types supported by existing clients and gzip-compressed request bodies. Gzip requests are limited to 256 KiB compressed and 1 MiB after expansion. Malformed JSON, non-object JSON, invalid encodings, decompression errors, and size-limit violations return JSON `400` or `422` responses before telemetry is queued. ```bash curl -X POST \ -H "Flipper-Cloud-Token: YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "request_id": "550e8400-e29b-41d4-a716-446655440000", "enabled_metrics": [ {"key": "new_dashboard", "time": 1706108400, "result": true, "value": 150}, {"key": "new_dashboard", "time": 1706108400, "result": false, "value": 50} ] }' \ https://www.flippercloud.io/adapter/telemetry ``` Returns `202 Accepted` with an empty JSON body. ### Get Telemetry Summary `GET /adapter/telemetry/summary` - `days` - Number of days of history (clamped to your plan's retention limit) - `keys` - Comma-separated feature keys to filter by `days` and `keys` must be scalar, valid UTF-8 query parameters. Invalid numeric values, container-shaped values, conflicting Rack shapes, and malformed encodings return a JSON `400` or `422` response. ```bash curl -H "Flipper-Cloud-Token: YOUR_TOKEN" \ "https://www.flippercloud.io/adapter/telemetry/summary?days=7" ``` ```json { "days": 7, "resolution": "day", "features": [ { "key": "new_dashboard", "description": "New dashboard experience for pro users", "longevity": "temporary", "tags": ["growth", "billing"], "creator": { "id": 42, "name": "Ada Lovelace", "email": "ada@example.com" }, "owner": { "id": 57, "name": "Grace Hopper", "email": "grace@example.com" }, "created_at": "2025-09-15T10:30:00Z", "state": "conditional", "gates_summary": { "boolean": false, "actors": 3, "groups": 2, "percentage_of_actors": 25, "percentage_of_time": 0, "expression": true }, "summary": { "total": 10000, "enabled": 6000, "disabled": 4000, "enabled_rate": 0.6 }, "time_series": [ { "timestamp": "2026-01-15T00:00:00Z", "total": 1500, "enabled": 900, "disabled": 600 } ] } ] } ``` Each feature includes configuration context alongside telemetry data: - `description` — Feature description, or `null` if not set - `longevity` — `"temporary"`, `"permanent"`, or `null` if not set - `tags` — Array of tag strings (empty array if none) - `creator` — User who created the feature, or `null` if unknown. Object with `id`, `name`, and `email`. - `owner` — User assigned as the feature's owner, or `null` if unassigned. Object with `id`, `name`, and `email`. - `created_at` — When the feature was created (ISO 8601) - `state` — Current state: `"on"`, `"conditional"`, or `"off"` - `gates_summary` — Summary of gate configuration (always present): - `boolean` — Whether the boolean gate is enabled - `actors` — Number of individually enabled actors - `groups` — Number of enabled groups - `percentage_of_actors` — Percentage of actors enabled (0-100) - `percentage_of_time` — Percentage of time enabled (0-100) - `expression` — Whether an expression gate is active ## Organization API {#organization} The organization API manages your organization rather than a single environment. It lives at `https://www.flippercloud.io/api/v1` and authenticates with an organization API token in the same `Flipper-Cloud-Token` header. Organization API tokens are available on plans with trusted domains. Organization admins create them in **Organization Settings → API Tokens**. A token stops working if the admin who created it is removed from the organization or is no longer an admin. Treat an organization API token like a password. Keep it on a server or in your secrets manager, never in a repository or on developer machines. If one leaks, delete it: deleting a token also disables every token it handed out, and people get new ones when your tooling calls with a new organization token. ### Provision a Member `POST /api/v1/organization/members` - `email` - The person's email address (required). It must be on one of your organization's verified [trusted domains](/docs/cloud/permissions#trusted-domains). Adds the person to your organization and returns their personal environment in every project, each with a read/write token. Use it from developer setup tooling so nobody has to copy tokens by hand. ```bash curl -X POST -d "email=dev@example.com" \ -H "Flipper-Cloud-Token: ORGANIZATION_API_TOKEN" \ https://www.flippercloud.io/api/v1/organization/members ``` ```json { "member": { "email": "dev@example.com", "role": "member", "added": true }, "environments": [ { "project": { "id": 7, "slug": "storefront", "name": "Storefront" }, "environment": { "id": 42, "slug": "dev-example-com", "name": "dev@example.com", "state": "personal", "created_at": "2026-11-06T12:00:00Z" }, "token": { "name": "Provisioned via API", "access": "read_and_write", "value": "Mb72kngHcVSLGefYptt2JvX5" } } ] } ``` The person doesn't need to have signed in before. If they haven't, Flipper Cloud creates their account, and it becomes theirs the first time they sign in with Google or GitHub using that email. New members join with the role set on the trusted domain and use a seat. Each environment's token is one the API created for this purpose. It's named **Provisioned via API** and owned by the person. It never returns a token the person created themselves, even one with the same name. They can see it with their other tokens and disable it without breaking anything else. If they disable it or make it read-only, the next call creates a new one. Each organization API token gets its own tokens, so switching tooling to a new organization token hands out fresh ones. You can safely call this more than once for the same email. Existing members return `200` with the same tokens, and `added` is `false`. Newly added members return `201`. Each call also adds existing members to any projects they're missing, so it picks up projects created since the last call. Calls for one organization run one at a time. If another call is still running, you get `409` with an `organization_busy` code and a `Retry-After` header. Wait that many seconds and try again. Retrying is always safe. To provision many people at once, such as a backfill, make the calls one after another instead of in parallel. #### Organization errors {#organization-errors} | Status | Code | Meaning | | --- | --- | --- | | `400` | `body_invalid` | The request body isn't valid JSON or form data. | | `401` | `organization_token_invalid` | The `Flipper-Cloud-Token` header is missing or isn't an organization API token. | | `402` | `no_available_seats` | The organization has no seats left for a new member. Existing members still succeed. | | `403` | `google_sso_domains` | The organization's plan doesn't include trusted domains. | | `403` | `organization_admin` | The admin who created the token is no longer an organization admin. | | `409` | `organization_busy` | Another call for the organization is still running. Retry after the `Retry-After` header's seconds. | | `422` | `email_missing` | The request didn't include an email. | | `422` | `email_invalid` | The email isn't a valid address. | | `422` | `email_domain_not_trusted` | The email isn't on one of the organization's verified trusted domains. | | `422` | `token_limit` | A personal environment needs a new read/write token but already has the maximum number of active tokens. Disable one of its tokens and try again. | ## Error Responses Errors return JSON with a code and message: ```json { "code": 1, "message": "Feature not found", "more_info": "https://www.flippercloud.io/docs" } ``` Common HTTP status codes: - `401` - Invalid or missing token - `402` - Feature requires a plan upgrade - `403` - Token does not have write access, or the request deletes features with a non-production token - `404` - Feature not found - `422` - Invalid parameters, or a feature name starting with the reserved `__flipper` prefix ## Error Code Reference {#error-code-reference} - `7` - The expression is invalid. Empty `Any` and `All` groups are not accepted; use `DELETE /adapter/features/{feature_name}/expression` to clear an expression. - `9` - The feature name starts with `__flipper`, which is reserved for Flipper's internal use. Nothing was changed. --- Source: https://www.flippercloud.io/docs/pro # Flipper Pro > Self-hosted feature flag administration. Flipper Cloud's polished UI on your infrastructure. ## What is Flipper Pro? Flipper Cloud, on your infrastructure. No flag data, telemetry, or anything else leaves your infra. **Available now in early access** for $1,999 per organization per year. [Get early access](/pro), or email [support@flippercloud.io](mailto:support@flippercloud.io), and we'll get you set up. ## OSS vs Pro vs Cloud
| Feature | OSS | Pro | Cloud | |---------|-----|-----|-------| | Admin UI | Basic | Polished, self-hosted | Polished, hosted | | Expressions | Code only | Visual editor | Visual editor | | Feature owners | — | Yes | Yes | | Call sites | — | Yes | — | | Audit log | — | DB-backed, optional Slack | Hosted, optional Slack, with rollbacks | | Multi-database support | — | Yes | Yes | | Multiple environments | — | — | Yes | | Personal environments | — | — | Yes | | Permissions | — | Your app's auth | Predefined roles | | Data location | Your infra | Your infra | Our infra | | Pricing | Free | $1,999/yr flat per org | [Tiered](/pricing) (Bronze, Silver, Gold) |
## Is Flipper Pro for me? You want Pro if any of these describe you: - You can't use SaaS for compliance reasons (regulated US industries like healthcare, finance, or government contractors). - You have EU data residency requirements or strict data-egress policies. - Your security team blocks non-approved SaaS vendors. - You want Flipper Cloud's UI experience without the external dependency. - You're running Flipper OSS and have outgrown the basic admin UI. ## How it deploys - Ships as a Ruby gem, `flipper-pro`. - Mounts as a Rails Engine alongside your app. - Reads and writes your existing database. No new infrastructure. - Protected by your existing authentication (Devise, Rack::Auth::Basic, or custom middleware). - No outbound network calls. Nothing phones home. - Works with single-database and multi-database Rails setups. Full setup walkthrough on the [Installation page](/docs/pro/installation). ## Getting started [Get early access](/pro) or email [support@flippercloud.io](mailto:support@flippercloud.io). We'll get you set up. Early access customers get direct support from the maintainers. --- Source: https://www.flippercloud.io/docs/pro/features # Flipper Pro Features > Self-hosted admin dashboard, expressions UI, audit log, call sites, multi-database support, and large actor sets. ## Features ### Self-hosted admin dashboard A web UI for managing feature flags, mounted as a Rails Engine in your app. Bootstrap 5 styling. Protected by your existing authentication: Devise, `Rack::Auth::Basic`, or any custom middleware. ### Expressions UI Flipper's [expressions](/docs/features/expressions) work in the OSS gem via code. Flipper Pro provides the same visual editor for creating and managing expression rules that's available in Flipper Cloud. ### Feature owners Assign ownership to each feature so your team knows who is responsible. Makes it easy to identify who to contact about a flag and holds accountability as your flag count grows. ### Call sites See exactly where in your codebase each feature flag is checked. Flipper Pro scans your `app/` and `lib/` directories for calls like `Flipper.enabled?(:feature_name)` and shows them on the feature detail page. Useful for understanding usage and knowing when a flag is safe to remove. Search paths are configurable. Editor deep links are supported for VS Code, Cursor, Zed, RubyMine, and Sublime Text, so you can jump from the admin UI straight to the right file and line. ### Audit log Every feature flag change is recorded in your database: what changed, who changed it, when. Optional Slack notifications keep the team aware in real time. ### Multi-database support Configure Flipper Pro to work with Rails applications that use multiple databases. Explicit writing and reading connections through standard Active Record configuration, including setups with read replicas and the `DatabaseSelector` middleware. ### Dynamic and large actor sets Efficiently check features for actors with many group memberships. Preload group memberships for an actor to avoid N+1 queries when checking several features in the same request. --- Source: https://www.flippercloud.io/docs/pro/installation # Installing Flipper Pro > Install Flipper Pro in your Rails app. Gemfile, migrations, engine mount, authentication, multi-database support. ## How it deploys Flipper Pro ships as a Ruby gem and mounts as a Rails Engine. It reads and writes your existing database, protected by your existing authentication. No new infrastructure, no outbound network calls, nothing phones home. Works with single-database and multi-database Rails setups. ## Installing the gem Add Flipper Pro to your Gemfile: ```ruby source "https://rubygems.pkg.github.com/flippercloud" do gem "flipper-pro" end ``` After purchase, you'll receive an access credential. Configure Bundler to authenticate: ``` bundle config https://rubygems.pkg.github.com/flippercloud USERNAME:TOKEN ``` Install: ``` bundle ``` ## Migrations Generate and run the migrations: ``` bin/rails flipper_pro:install:migrations bin/rails db:migrate ``` Flipper Pro stores flag data, groups, expressions, audit history, and group memberships in your database. ## Mount the engine Mount Flipper Pro in `config/routes.rb`: ```ruby Rails.application.routes.draw do mount Flipper::Pro::Engine => "/flipper" end ``` ## Authenticate The Pro admin dashboard ships without authentication. Protect it with your existing auth. Three common patterns: ### Rack basic auth ```ruby # config/initializers/flipper.rb expected_username = ::Digest::SHA256.hexdigest(ENV.fetch("FLIPPER_PRO_USERNAME")) expected_password = ::Digest::SHA256.hexdigest(ENV.fetch("FLIPPER_PRO_PASSWORD")) Flipper::Pro::Engine.middleware.use(Rack::Auth::Basic) do |username, password| given_username = ::Digest::SHA256.hexdigest(username.to_s) given_password = ::Digest::SHA256.hexdigest(password.to_s) ActiveSupport::SecurityUtils.secure_compare(expected_username, given_username) & ActiveSupport::SecurityUtils.secure_compare(expected_password, given_password) end ``` Hashing both sides keeps the comparison constant-time regardless of input length. Reading the credentials above `middleware.use` makes `ENV.fetch` raise at boot if either is missing, instead of failing on the first request to the dashboard. ### Devise ```ruby # config/routes.rb authenticate :user, ->(user) { user.admin? } do mount Flipper::Pro::Engine => "/flipper" end ``` ### Custom middleware ```ruby # config/initializers/flipper.rb Flipper::Pro::Engine.middleware.use MyCustomMiddleware ``` ## Multi-database support If your app uses ActiveRecord's multiple database support (for example, read replicas with `DatabaseSelector`), configure Flipper Pro's connections: ```ruby # config/initializers/flipper.rb Flipper::Pro.configure do |config| config.database = { writing: :primary, reading: :primary } end ``` Without this, you may see `No connection pool for 'ActiveRecord::Base' found for the 'reading' role` errors. ## Upgrading from Flipper OSS Flipper Pro is a drop-in upgrade. Your existing Flipper adapter, flag data, groups, and Rails integration keep working. The change is the gem you install and the engine you mount. --- Source: https://www.flippercloud.io/docs/pro/pricing # Flipper Pro Pricing > Simple, flat rate per organization. ## Pricing **$1,999 per organization per year.** Flat rate. No per-seat fees. Unlimited environments. Flipper Pro is in early access. [Get early access](/pro) and we'll email you an invoice and give your team access to the private gem on GitHub. ## What's included - Every feature on the [Features page](/docs/pro/features). - Upgrades for the length of your subscription. - Direct support from the maintainers during early access. ## Larger or unusual deployments Multi-tenant redistribution, custom SLAs, government procurement, or something else we haven't anticipated? Email [support@flippercloud.io](mailto:support@flippercloud.io) for a quote. ## Refund policy If Flipper Pro doesn't function properly for you within two weeks of purchase, email [support@flippercloud.io](mailto:support@flippercloud.io) for a full refund. Note: some features (large actor set performance, audit log) stop functioning after a subscription lapses. A rollback to OSS behavior is real, not cosmetic. --- Source: https://www.flippercloud.io/docs/pro/faq # Flipper Pro FAQ > Common questions about Flipper Pro. Phone-home behavior, databases, license, upgrades, trials. ## Common questions ### Does it phone home? No. Flipper Pro makes no outbound network calls. All flag data stays in your database. ### Can I use Flipper Pro without Flipper Cloud? Yes. Flipper Pro is fully standalone. Cloud is a separate product with its own features and pricing. ### Does it work with my existing Flipper OSS setup? Yes. Flipper Pro is a drop-in upgrade on top of your existing adapter and flag data. ### What Ruby and Rails versions are supported? Flipper Pro requires Rails 6.1+ and Flipper 1.3+. It runs on any Ruby version those support. If you're on a recent Rails app with a recent Flipper, you're good. Pro requires Rails — non-Rails Ruby apps that use OSS Flipper aren't supported. ### What databases does it support? Anything ActiveRecord supports: PostgreSQL, MySQL, SQLite. ### How do I upgrade from OSS? Add the `flipper-pro` gem with the credential from your license email, run the migrations, and mount the engine. Full walkthrough on the [Installation page](/docs/pro/installation). ### Is there a free trial? No free trial. If Flipper Pro doesn't function properly for you within two weeks of purchase, email us for a full refund. See [Pricing](/docs/pro/pricing) for details. ### How is Flipper Pro licensed? Commercial, per-organization, non-transferable, non-redistributable. The OSS Flipper gem is MIT. Flipper Pro is not. Full terms: the [EULA](/docs/pro/eula) shipped with the gem. Short version: you can install Pro on any number of servers and environments under your control. You cannot redistribute the gem, embed it in a product you ship to third parties, or use it as the basis for a competing product. ### Can I ship Flipper Pro inside my SaaS product? Not under the standard license. Email [support@flippercloud.io](mailto:support@flippercloud.io) for redistribution terms. --- Source: https://www.flippercloud.io/docs/pro/eula # Flipper Pro EULA > End-user license agreement for Flipper Pro 0.2.6. > [!IMPORTANT] > This software end-user license agreement ("EULA") is a legal agreement (“Agreement”) between you (the customer, either as an individual or, if purchased or otherwise acquired by or for an entity, as an entity) and Fewer and Faster, LLC. Read it carefully before completing the installation process and using Flipper Pro and related software components (“Software”). It provides a license to use the Software and contains warranty information and liability disclaimers. By installing and using the Software, you are confirming your acceptance of the Software and agreeing to become bound by the terms of this agreement. ## 1. License Grant ### 1.1. General Use. This Agreement grants you a non-exclusive, non-transferable, limited license to the use rights for the Software, without the right to grant sublicenses, subject to the terms and conditions in this Agreement. The Software is licensed, not sold. ### 1.2. Archive Copies. You are entitled to make a reasonable amount of copies of the Software for archival purposes. Each copy must reproduce all copyright and other proprietary rights notices on or in the Software Product. ### 1.3. Delivery. All Software and license documentation shall be delivered by electronic means unless otherwise specified on the applicable invoice or at the time of purchase. Software shall be deemed delivered when it is made available for download by you (“Delivery”). ## 2. Restricted Uses. You shall not (and shall not allow any third party to): * (a) use the Software as part of a product which provides similar functionality to the software itself, or is competitive with any Fewer and Faster, LLC product offerings. * (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; * (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; * (d) redistribute the Software as part of a product, "appliance" or "virtual server"; * (e) redistribute the Software on any server which is not directly under your control; * (f) remove any product identification, proprietary, copyright or other notices contained in the Software; or * (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section [3. Modifications.](#3-modifications)), or incorporate the Software, except to the extent expressly authorized in writing by Fewer and Faster, LLC. ## 3. Modifications. Fewer and Faster, LLC shall provide you with source code so that you can create Modifications of the original software. “Modification” means: (a) any addition to or deletion from the contents of a file included in the original Software or previous Modifications created by You, or (b) any new file that contains any part of the original Software or previous Modifications. While you retain all rights to any original work authored by you as part of the Modifications, We continue to own all copyright and other intellectual property rights in the Software. ## 4. Ownership. Notwithstanding anything to the contrary contained herein, except for the limited license rights expressly provided herein, Fewer and Faster, LLC and its suppliers have and will retain all rights, title and interest (including, without limitation, all patent, copyright, trademark, trade secret and other intellectual property rights) in and to the Software and all copies, modifications and derivative works thereof (including any changes which incorporate any of your ideas, feedback or suggestions). You acknowledge that you are obtaining only a limited license right to the Software, and that irrespective of any use of the words “purchase”, “sale” or like terms hereunder no ownership rights are being conveyed to you under this Agreement or otherwise. ## 5. Fees and Payment. The Software license fees will be due and payable in full as set forth in the applicable invoice or at the time of purchase. If the Software does not function properly within two weeks of purchase, please contact us within those two weeks for a refund. You shall be responsible for all taxes, withholdings, duties and levies arising from the order (excluding taxes based on the net income of Fewer and Faster, LLC). ## 6. Support, Maintenance and Services. Subject to the terms and conditions of this Agreement, as set forth in your invoice, and as set forth on the Flipper Pro support page (https://www.flippercloud.io/pro), support and maintenance services may be included with the purchase of your license subscription. ## 7. Term of Agreement. ### 7.1 Term. This Agreement is effective as of the Delivery of the Software and expires at such time as all license and service subscriptions hereunder have expired in accordance with their own terms (the “Term”). For clarification, the term of your license under this Agreement may be perpetual, limited for Evaluation Version, or designated as a fixed-term license in the Invoice, and shall be specified at your time of purchase. Either party may terminate this Agreement (including all related Invoices) if the other party: (a) fails to cure any material breach of this Agreement within thirty (30) days after written notice of such breach, provided that Fewer and Faster, LLC may terminate this Agreement immediately upon any breach of Section 3 or if you exceed any other restrictions contained in Section 1, unless otherwise specified in this agreement; (b) ceases operation without a successor; or (c) seeks protection under any bankruptcy, receivership, trust deed, creditors arrangement, composition or comparable proceeding, or if any such proceeding is instituted against such party (and not dismissed within sixty (60) days)). Termination is not an exclusive remedy and the exercise by either party of any remedy under this Agreement will be without prejudice to any other remedies it may have under this Agreement, by law, or otherwise. ### 7.2 Termination. Upon any termination of this Agreement, you shall cease any and all use of any Software and destroy all copies thereof. ### 7.3 Expiration of License. Upon the expiration of any term under this Agreement, (a) all Software updates and services pursuant to the license shall cease, (b) you may only continue to run existing installations of the Software, (c) you may not install the Software on any additional Hosts, and (d) any new installation of the Software shall require the purchase of a new license subscription from Fewer and Faster, LLC. ## 8. Disclaimer of Warranties. The Software is provided "as is," with all faults, defects and errors, and without warranty of any kind. Fewer and Faster, LLC does not warrant that the Software will be free of bugs, errors, viruses or other defects, and Fewer and Faster, LLC shall have no liability of any kind for the use of or inability to use the Software, the Software content or any associated service, and you acknowledge that it is not technically practicable for Fewer and Faster, LLC to do so. To the maximum extent permitted by applicable law, Fewer and Faster, LLC disclaims all warranties, express, implied, arising by law or otherwise, regarding the Software, the Software content and their respective performance or suitability for your intended use, including without limitation any implied warranty of merchantability, fitness for a particular purpose. ## 9. Limitation of Liability. In no event will Fewer and Faster, LLC be liable for any direct, indirect, consequential, incidental, special, exemplary, or punitive damages or liabilities whatsoever arising from or relating to the Software, the Software content or this Agreement, whether based on contract, tort (including negligence), strict liability or other theory, even if Fewer and Faster, LLC has been advised of the possibility of such damages. In no event will Fewer and Faster, LLC's liability exceed the Software license price as indicated in the invoice. The existence of more than one claim will not enlarge or extend this limit. ## 10. Remedies. Your exclusive remedy and Fewer and Faster, LLC's entire liability for breach of this Agreement shall be limited, at Fewer and Faster, LLC's sole and exclusive discretion, to (a) replacement of any defective software or documentation; or (b) refund of the license fee paid to Fewer and Faster, LLC, payable in accordance with Fewer and Faster, LLC' refund policy. ## 11. Acknowledgements. ### 11.1 Consent to the Use of Data. You agree that Fewer and Faster, LLC and its affiliates may collect and use technical information gathered as part of the product support services. Fewer and Faster, LLC may use this information solely to improve products and services and will not disclose this information in a form that personally identifies you. ### 11.2 Verification. We or a certified auditor acting on our behalf, may, upon its reasonable request and at its expense, audit you with respect to the use of the Software. Such audit may be conducted by mail, electronic means or through an in-person visit to your place of business. Any such in-person audit shall be conducted during regular business hours at your facilities and shall not unreasonably interfere with your business activities. We shall not remove, copy, or redistribute any electronic material during the course of an audit. If an audit reveals that you are using the Software in a way that is in material violation of the terms of the EULA, then you shall pay our reasonable costs of conducting the audit. In the case of a material violation, you agree to pay Us any amounts owing that are attributable to the unauthorized use. In the alternative, We reserve the right, at our sole option, to terminate the licenses for the Software. ### 11.3 Government End Users. If the Software and related documentation are supplied to or purchased by or on behalf of the United States Government, then the Software is deemed to be "commercial software" as that term is used in the Federal Acquisition Regulation system. Rights of the United States shall not exceed the minimum rights set forth in FAR 52.227-19 for "restricted computer software". All other terms and conditions of this Agreement apply. ## 12. Third Party Software. Examples included in Software may provide links to third party libraries or code (collectively “Third Party Software”) to implement various functions. Third Party Software does not comprise part of the Software. In some cases, access to Third Party Software may be included along with the Software delivery as a convenience for demonstration purposes. Such source code and libraries may be included in the “…/examples” source tree delivered with the Software and do not comprise the Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Software referencing or including any portion of a Third Party Software may require appropriate licensing from such third parties. ## 13. Miscellaneous ### 13.1 Entire Agreement. This Agreement sets forth our entire agreement with respect to the Software and the subject matter hereof and supersedes all prior and contemporaneous understandings and agreements whether written or oral. ### 13.2 Amendment. Fewer and Faster, LLC reserves the right, in its sole discretion, to amend this Agreement from time. Amendments to this Agreement can be located at: https://github.com/flippercloud/flipper-pro/blob/main/LICENSE.md. ### 13.3 Assignment. You may not assign this Agreement or any of its rights under this Agreement without the prior written consent of Fewer and Faster, LLC and any attempted assignment without such consent shall be void. ### 13.4 Export Compliance. You agree to comply with all applicable laws and regulations, including laws, regulations, orders or other restrictions on export, re-export or redistribution of software. ### 13.5 Indemnification. You agree to defend, indemnify, and hold harmless Fewer and Faster, LLC from and against any lawsuits, claims, losses, damages, fines and expenses (including attorneys' fees and costs) arising out of your use of the Software or breach of this Agreement. ### 13.6 Governing Law. This Agreement is governed by the laws of the State of Oregon and the United States without regard to conflicts of laws provisions thereof, and without regard to the United Nations Convention on the International Sale of Goods or the Uniform Computer Information Transactions Act, as currently enacted by any jurisdiction or as may be codified or amended from time to time by any jurisdiction. The jurisdiction and venue for actions related to the subject matter hereof shall be the state of Oregon and United States federal courts located in Portland, Oregon, and both parties hereby submit to the personal jurisdiction of such courts. ### 13.7 Attorneys' Fees and Costs. The prevailing party in any action to enforce this Agreement will be entitled to recover its attorneys' fees and costs in connection with such action. ### 13.8 Severability. If any provision of this Agreement is held by a court of competent jurisdiction to be invalid, illegal, or unenforceable, the remainder of this Agreement will remain in full force and effect. ### 13.9 Waiver. Failure or neglect by either party to enforce at any time any of the provisions of this licence Agreement shall not be construed or deemed to be a waiver of that party's rights under this Agreement. ## 14. Contact Information. If you have any questions about this EULA, or if you want to contact Fewer and Faster, LLC for any reason, please direct correspondence to support@flippercloud.io. --- Source: https://www.flippercloud.io/docs/guides/naming # Naming Conventions for Feature Flags > Learn how to structure and name your feature flags for maximum clarity and consistency. There are [two hard things](https://martinfowler.com/bliki/TwoHardThings.html) in programming — cache invalidation and **naming things**. Feature flag names are no exception. A couple hard and fast rules: * The name of a feature flag should be descriptive enough to understand what the flag is for, but not so long that it becomes hard to read or type. * The name should be consistent with the conventions used in the rest of your organization/codebase. ## Pick a Style Pick a naming style and stick with it. The most important thing is consistency. Here are some examples of styles you can use: 1. **We recommend snake case** (`trial_lifecycle_emails`) 2. kebab case (`trial-lifecycle-emails`) 3. camel case (`trialLifecycleEmails`) 4. pascal case (`TrialLifecycleEmails`) We'd also recommend staying away from spaces, punctuation, and special characters because you will be referring to these names in code (e.g. `if Flipper.enabled?("Awkward Feature Name")`) Plus, standardized and consistent formatting reduces the chances of typing the right key using the wrong formatting. ## Keep It Short Feature flag names should be short and descriptive. If you find yourself writing a long name, consider whether you can shorten it without losing clarity. `google_analytics` is better than `google_analytics_integration` or `google_analytics_tracking` because it's clear that the flag is related to Google Analytics, and the shorter name is easier to type. It's also easier to remember becuause you don't have to double-check if you used "analytics" or "tracking" when you need to reference the flag in your code. ## Use Prefixes Succinct and relevant prefixes can help avoid naming collisions and make names more descriptive. For example, we have a couple flags related to the events API in Flipper Cloud — `event_receiving` and `event_enqueue`. Using `event_` as the prefix makes it clear that they are related to the same functionality. Naming those flags `receiving` and `enqueue` alone would be confusing (which receiving or enqueueing part of the app does this control?). In these cases, adding a succinct reference to the relevant area or module (logger, jobs, email, webhooks, etc.) can help clarify purpose. That said, we don't recommend going wild with prefixes (or suffixes). Other feature flag systems often recommend prefixing the name with the: * type (e.g. release, experiment, ops, etc.) * longevity (temporary or permanent) * team (e.g. engineering, marketing, security, etc.) We don't recommend this, as it just makes flag names unnecessarily long and harder to type. Instead, we recommend using the feature description and tags for organizational purposes. For example, you can tag all features related to marketing with `marketing` and then filter by that tag in the UI. You can also use the description field to add more context to the flag. ## Enforce Your Conventions Even with the best naming conventions, typos happen. `Flipper.enabled?(:serach)` silently returns `false` when you meant `:search`, which can be a painful bug to track down. The [strict adapter](/docs/adapters/strict) catches these mistakes by raising an error or warning whenever your code checks a feature that doesn't exist. Enable it in development and test to get immediate feedback: ```ruby Rails.application.configure do config.flipper.strict = Rails.env.local? && :warn end ``` With strict mode enabled, checking an unknown feature will warn you immediately instead of silently returning `false`. --- Source: https://www.flippercloud.io/docs/guides/launch # Using Flags to Launch New Features > Learn how to use feature flags to build and launch new functionality with advice for the development process and iteratively expanding the size of the audience that has access to the new functionality. Building great software requires feedback, early and often. Some features may take weeks or months to build, but you don't have to wait until everything is completely done to get feedback from your team or users. New features can be shipped to production quickly and safely behind a feature flag without disrupting anyone else, and then enabled individually for specific users as the feature matures. This short guide shows how to add feature flags to your app, give early access to a few users, incrementally roll out to more users, and then fully ship it! ## What is a feature flag? A feature flag is a conditional that allows you to change the behavior of your app without changing the code. Here's an example: ```ruby def shipping_cost if Flipper.enabled? :shipping_calculator, user shipping_provider.calculate(weight, postal_code) else price * 0.1 end end ``` Here our method to calculate shipping cost has two branches of logic. We delegate to Flipper to decide if the new or original behavior should be used, and as you'll see shortly, Flipper gives that simple conditional super powers. ## Add feature flags to your app Before we begin, check out the [Getting Started](/docs/get-started) guide to install Flipper into your app, or use our [Flipper Rails Demo](https://github.com/flippercloud/flipper-rails-demo) as a starting point. Adding feature flags to your app is as simple as adding conditionals anywhere you want to toggle access. So when adding a new feature that has visual components, simply wrap it with `Flipper.enabled?` to show or hide it. ###### app/views/dashboard/show.html.erb ```erb <% if Flipper.enabled? :new_feature, current_user %> <%= link_to "New Feature", new_feature_path %> <% end %> ``` Notice we pass in the `current_user`, which returns an instance of our `User` model will allow us to enable this feature for specific users later. This argument can be any _actor_ that you want, be it a user, organization, or anything else with a unique identifier (`flipper_id`). If the new feature has its own controller or model logic, you'll want to also add a feature flag there to ensure some unsuspecting user can't stumble upon it. Add a `before_action` to render our default 404 page if the feature is not enabled. ###### app/controllers/new_feature_controller.rb ```ruby class NewFeatureController < ApplicationController before_action :ensure_enabled def index render plain: "Work in Progress" end private def ensure_enabled render :not_found unless Flipper.enabled?(:new_feature, current_user) end end ``` _That's it!_ This new feature can be committed and even deployed to production. All features are disabled until you enable them, so nobody would see the new button we added or be able to access our new controller. ## Enable the feature for yourself You as the developer are likely the first person that will want access to this feature, so let's enable it for just you. You can enable it from [Flipper Cloud](/dashboard) or your local console: ###### `$ rails console` ```ruby Flipper.enable_actor :new_feature, User.find_by(username: "me") ``` Now when you visit your app, the new feature will be visible for just you! > Read more: [Enabling features for an actor](/docs/features/actors) ## Enable the feature for a group Once the feature is ready for more users, register a group that returns true if an actor is part of that group. This can be based on a value in the database or any other logic that you use to identify segments. Here, we define an employees group that checks if they have an email address matching a specific domain: ###### `config/initializers/flipper.rb` ```ruby Flipper.register(:employees) do |actor| actor.email.ends_with?("@mycompany.com") && actor.verified? end ``` You can enable it from [Flipper Cloud](/dashboard) or your local console: ###### `$ rails console` ```ruby Flipper.enable_group :new_feature, :employees ``` Now you can get feedback from your team before sharing the feature with your users. > Read more: [Enabling features for a group](/docs/features/groups) ## Enable the feature for a percentage of users Congrats, the feature is now ready to share with users! This is a huge milestone, and hopefully you feel confident since you and your team have been able to thoroughly test the feature in production. If your app has a lot of users, you can slowly roll out features to a small percentage of them at a time and make sure there are no issues at scale before letting more in. From [Flipper Cloud](/dashboard) or your local console, you can enable for a percentage of actors: ###### `$ rails console` ```ruby Flipper.enable_percentage_of_actors :new_feature, 1 # Wait and verify Flipper.enable_percentage_of_actors :new_feature, 5 # Wait some more Flipper.enable_percentage_of_actors :new_feature, 20 # … ``` The feature will start to show up for a percentage of users (based on a consistent hashing algorithm), letting more and more people in as you increase the percentage. > Read more: [Enabling features for a percentage of actors](/docs/features/percentage-of-actors) > ## Ship it! When you're confident that your feature is ready for everyone, you can fully enable it from [Flipper Cloud](/dashboard) or your local console: ###### `$ rails console` ```ruby Flipper.enable :new_feature ``` ## Wrapping Up _Congrats on launching a new feature with feature flags!_ Doesn't it feel great to be completely in control of your code without having to redeploy?!? Now that your feature is fully shipped, consider if you want to remove the feature flags or not. It's often helpful to leave them in case you need to disable the feature, take it [down for maintenance](/docs/uses#maintenance), [block bad actors](/docs/uses#block-users), or later want to [sunset](/docs/uses#sunsetting) it. Feature checks in Flipper are blazing fast, so there's not a performance reason to remove them. On the other hand, a feature flag might include a code path that is now unused, in which case it may be worth removing the dead code to reduce technical debt. It's up to your specific scenario whether you want to remove the feature checks. --- Source: https://www.flippercloud.io/docs/agents # Feature Flags for AI Coding Agents > A copy-paste AGENTS.md section that tells Claude Code, Codex, Cursor and other coding agents to ship every user-facing change behind a Flipper feature flag, test both paths, and leave the rollout to a person. Coding agents write a lot of code quickly, and some of it will be wrong in ways tests don't catch. Merge it behind a feature flag and you get to try it in production yourself, then with a few customers, before everyone sees it. If something breaks, you turn the flag off instead of reverting and redeploying. Agents follow the instructions in your repository. Add the section below to your `AGENTS.md` (or `CLAUDE.md`, `.cursor/rules`, or whatever file your agent reads), and every user-facing change it writes ships behind a flag. ## The AGENTS.md section ```markdown ## Feature flags This app uses Flipper for feature flags. Docs: https://www.flippercloud.io/docs - Put every user-facing change behind a Flipper feature flag. Check it with `Flipper.enabled?(:flag_name, user)` so it can be rolled out per user. - Name flags in snake_case: short and descriptive, with an area prefix when it helps (`billing_annual_plans`, `search_typo_tolerance`). No team, type, or ticket prefixes. - Keep the old code path working until the flag is removed. Test both paths with `Flipper.enable` and `Flipper.disable`. - Never enable or disable flags in production, migrations, or seeds. A person rolls the change out. - When a flag has been fully enabled for 14 days, remove the check and the old code path in a separate change. ``` Adjust the details to fit your team. The names follow our [naming guide](/docs/guides/naming), and the testing advice follows [Testing](/docs/testing). ## Catch typos in flag names Agents sometimes check a flag under a slightly different name than the one you created, and `Flipper.enabled?` quietly returns `false` for a flag that doesn't exist. Turn on the [strict adapter](/docs/adapters/strict) in development and test so the mistake shows up right away: ```ruby Rails.application.configure do config.flipper.strict = Rails.env.local? && :warn end ``` ## Let your agent find flags to remove The last rule above only works if your agent knows when a flag has been fully enabled. Connect it to Flipper Cloud's [MCP server](/docs/cloud/mcp) and it can check for itself: ask "Which Flipper flags can we remove?" and it looks at every environment, telemetry and audit history before touching your code. ## Rolling out agent-written changes 1. Merge and deploy with the flag off. Nothing changes for customers. 2. Enable it for yourself or your team as [actors](/docs/features/actors) or a [group](/docs/features/groups), and use the feature in production. 3. Widen it with a [percentage of actors](/docs/features/percentage-of-actors), and watch your errors and metrics. 4. Enable it for everyone, then remove the flag. More agent-written code also means more flags to keep track of. [Flipper Cloud](/docs/cloud) shows who changed each flag and when in its [audit history](/docs/cloud/audit-history), lets you [assign owners and tags](/docs/cloud/organizing), and reports how often each flag is checked with [telemetry](/docs/cloud/telemetry), so you can tell which flags are ready to remove. --- Source: https://www.flippercloud.io/docs/guides/migration # Upgrade from Open Source to Cloud > Learn how to safely upgrade from only using the self-hosted version of Flipper to using Flipper Cloud to manage your feature flags. If you are already using the open source version of Flipper, migrating to Cloud is easy without any code changes. You can use the UI or the flipper gem to migrate all your feature data in a few minutes. ### Automatic Migration (Recommended) If you're on the latest version of the Flipper gem, migration is seamless. **Via the CLI:** ``` flipper cloud migrate ``` This exports your features, uploads them to Flipper Cloud, and opens a link to sign up (or sign in) with your features pre-loaded. Your local setup is not affected. **Via Ruby:** ```ruby require "flipper/cloud/migrate" result = Flipper::Cloud.migrate puts result.url # Visit this URL to complete setup ``` You do not need a Flipper Cloud token to migrate. Migration reads from your currently configured local adapter without modifying or replacing it. **Via the Flipper UI:** Go to Settings and click "Migrate to Flipper Cloud". This walks you through the process with an explanation of what will happen before anything is sent. --- The methods below are still available if you prefer a manual approach. ### Via the Flipper UI The easiest way to migrate to Cloud is via the [Flipper UI](/docs/ui). Since version 0.27, the Flipper UI supports exporting your feature data to a JSON file. Go to Settings and then click Download.
Viewing import and export in self-hosted UI
Viewing import and export in self-hosted UI
Once you have the exported file, go to Import / Export for the Flipper Cloud environment you'd like to import into. From there, you can upload the file and import your features. ### Via the flipper gem If you don't have the Flipper UI installed, you can use the flipper gem to export your features to a JSON file. ```ruby File.write("flipper.json", Flipper.export.contents) ``` Once you've exported the file, you can go to Import / Export for the Flipper Cloud environment you'd like to import into. From there, you can upload the file and import your features. ### Via Flipper Cloud In addition to importing and exporting file backups, Flipper supports syncing between adapters. This avoids the need for exporting and importing a file. From a console or script, you can import your current adapter into Flipper Cloud: ```ruby require 'flipper/cloud' # Get the currently configured instance of flipper with whatever adapter you are using. current_flipper = Flipper.instance # Or if you need to initialize flipper with a specific adapter or configuration # current_flipper = Flipper.new(Flipper::Adapters::ActiveRecord.new) # makes cloud identical to memory flipper # note: this will wipe out whatever is in cloud Flipper::Cloud.new(token: "").import(current_flipper) ``` **Warning**: do _not_ configure the `FLIPPER_CLOUD_TOKEN` environment variable in your application prior to running the import. This will cause your application to use the Flipper Cloud adapter which will sync your current adapter with whatever is currently in Cloud (and could result in data loss). --- Source: https://www.flippercloud.io/docs/guides/env-vars # Move ENV Var Feature Flags to Flipper > When ENV var feature flags are enough, when they stop being enough, and how to move them to Flipper one flag at a time without changing behavior in production. An ENV var is the simplest feature flag there is. `if ENV["NEW_CHECKOUT"] == "true"` needs no gem, no table, and no UI, and for some flags that's all you'll ever need. This guide covers when to keep them and how to move the rest to Flipper, one flag at a time. ## Keep ENV vars when - The flag is on or off for everyone, and it rarely changes. - Waiting for a restart or deploy to change it is fine. - It's really configuration, like an API host or a timeout, and not a product decision. - You have a few of them, and the people who change them already have access to your host's config. ## Move to Flipper when | You want to | ENV var | Flipper | | --- | --- | --- | | Turn a feature on | Change config, usually a restart | [One call or a click](/docs/features/boolean), no restart | | Turn it on for one customer | Build it yourself | [Enable an actor](/docs/features/actors) | | Roll out to 10% of users | Build it yourself | [Percentage of actors](/docs/features/percentage-of-actors) | | Turn it on for staff | Build it yourself | [Groups](/docs/features/groups) | | Let non-developers change it | Give them host access | [Flipper UI](/docs/ui) or [Cloud](/docs/cloud) | | See who changed what | Your host's logs, if it keeps them | [Audit history](/docs/cloud/audit-history) in Cloud | | Find flags nobody checks anymore | Search the code | [Telemetry](/docs/cloud/telemetry) in Cloud | The first time a teammate asks "can we turn this on for just one customer?" is usually the time to switch. ## Move one flag at a time You don't need to move everything at once. Each flag below keeps its current value in production the whole way through, so nobody sees a change until you make one. ### 1. List your flags Search for every ENV var your app reads, then pick out the ones that act as on/off switches. Leave real configuration where it is. ```bash $ grep -rnE "ENV(\[|\.fetch)" app config lib ``` ### 2. Install Flipper If you haven't already, [add the gem and an adapter](/docs/get-started). For a Rails app with Active Record: ```bash $ bundle add flipper-active_record $ bin/rails generate flipper:setup $ bin/rails db:migrate ``` Deploy this on its own. Nothing checks Flipper yet, so nothing changes. ### 3. Copy each value into Flipper Run this once in each environment, before you deploy any code that reads the flag. A flag that doesn't exist yet is off, so if you skip this step a feature that's on today turns off when the new code ships. ```ruby Flipper.add(:new_checkout) Flipper.enable(:new_checkout) if ENV["NEW_CHECKOUT"] == "true" ``` Use whatever comparison your code uses today. If it treats any non-empty value as on, match that here. ### 4. Change the check ```ruby # Before if ENV["NEW_CHECKOUT"] == "true" # After if Flipper.enabled?(:new_checkout, current_user) ``` Passing an actor changes nothing while the flag is fully on or off, and it's what lets you [target one customer](/docs/features/actors) later. If a check runs while your app boots, such as in an initializer, move it to where the feature runs, because a value read at boot won't see later changes until the next restart. Update your tests too. See [testing](/docs/testing) for how to turn flags on and off in them. ### 5. Delete the ENV var Once the new check is deployed everywhere, nothing reads the old value. Remove it from your host's config, from `.env` files, and from your setup docs, so nobody changes it and wonders why nothing happened. ## Catch typos An ENV var with a typo reads as unset, and so does a Flipper feature with a typo. The [strict adapter](/docs/adapters/strict) warns or raises when your code checks a feature that doesn't exist, and it's set to warn in development and test by default. ## Next - [Naming features](/docs/guides/naming) so your new flags stay easy to find. - [Upgrade to Cloud](/docs/guides/migration) when you want audit history, telemetry, and environments in one place. --- Source: https://www.flippercloud.io/docs/guides/opt-in # Let People Opt-in to New Features > Learn how to user feature flags to let end users opt-in to new functionality on their terms instead of forcing them to adapt on your timeline. You've been quietly working on a significant new feature in your app, and you're finally ready to release it. You're excited to release it because you know how much of an improvement it represents. So you push it out the door, and thousands of customers are forced to adjust to the update right in the middle of their workflow. You get dozens of support requests from angry customers who are just trying to get their work done, and you realize just how much people don't like to be forced into a new way of doing things. There's another way, and with Flipper, it's not even difficult. ## Feature flags as preferences? Instead of pushing significant changes on people, you can use feature flags to ensure those large changes are a better experience for both your customers and your team. The essence of feature flags is all about incrementally releasing changes in a way that minimizes negative impacts on customers, doesn't break your existing code, doesn't take down your app due to unforeseen performance issues, and provides you a way to revert quickly if something goes wrong. If [launching new features with feature flags](/docs/guides/launch) lets you slowly roll out a new feature to a wider audience, letting people control their own adaption on their schedule takes it to the next level. Before we get into the implementation details, let's run through the benefits of releasing new features via feature flags as preferences. ### Happier Customers By letting people decide when they're ready to try out a new feature—and turn it off if they don't like it or aren't ready—you're empowering them to make their own decisions instead of forcing them into something on your timeline. You end up with happier customers because there's never a surprise, and they choose whether they want to help provide feedback or whether they just need it to work and are happy waiting for the final release. Also, keep in mind that the people most likely to be negatively affected by significant, unexpected changes are the people that use your application the most. They may not be your most vocal supporters, but they're certainly more likely to be some of your best customers. They're definitely not the customers you want to upset and send shopping for alternatives. ### Better Feedback When people opt-in to a feature, they're self-selecting for you. You end up with a more engaged (as opposed to enraged) set of beta testers that want the feature and are happy to provide feedback. When new features are pushed on people without the ability to opt-in, there's a good chance it won't be changing at a convenient time for them. If they're providing feedback from the perspective of being inconvenienced, they likely aren't going to want to bother providing considered feedback, and they'll be upset on top of it. Getting feedback from someone who's been inconvenienced is much less likely to be useful and actionable feedback. ### Less Support We've all been there after that large new feature release or design change. No matter how much you notified customers ahead of time or tried to prepare them, not everyone has seen your preparatory announcements or had the time or inclination to prepare for the change. So you unleash the great new feature, but for a large percentage of your customers, they can't appreciate any new benefits because it just threw them for a loop. All they want is for you to change it back so they can do their job. Now instead of celebrating the release, you're stuck replying to angry customers. Or worse, the rug pull has them thinking about leaving for a competitor that's more predictable. ### Let customers choose between basic and advanced With any system, there's a delicate balance between simplicity and power. Keeping an interface simple and clean makes it easier to learn, but power users may be alright with a busier interface if it means they can perform tasks in less time or with less interaction. With feature flags, you can provide a way for some to opt-in to the more advanced features so they can have the added flexibility while leaving others with a less-overwhelming initial experience so they can ease into learning how to use your system. ## Using feature flags for opt-in If you like the idea of all of these benefits, all that's left is making a plan for how to make it happen. If you haven't read our guide on [using feature flags to launch new features](/docs/guides/launch), you might want to go read through that first to lay the groundwork. We have a few options when it comes to implementing opt-in feature flags. ### Opting in to individual features Assuming that you're already using feature flags to incrementally share functionality with a wider group of customers or testers, you're not far from letting people opt in or out of a given feature. With Rails, you could build a preferences controller that acts as a proxy for Flipper. For example, let's say the `current_user` instance represents your currently-logged-in user. You would need to make the following call to Flipper: ```ruby Flipper.enable(:new_design, current_user) ``` In that context, you could create a controller dedicated to customer preferences for new features. ###### app/controllers/new_feature_controller.rb ```ruby class LabsController < ApplicationController def index # Use these to generate the relevant form fields for customers @available_features = available_features end def update if available_features.include?(feature) toggle(feature, current_user) redirect_to action: :index, notice: "Welcome to the beta!" else redirect_to action: :index, alert: "Uh oh. That's not a valid opt-in feature." end end private # Make sure they can turn the feature on or off def toggle(feature, user) if Flipper.enabled?(feature, user) Flipper.disable(feature, user) else Flipper.enable(feature, user) end end def feature params[:feature]&.to_sym end def available_features [:new_design, :advanced_search] end end ``` ### Joining an early access group In addition to opting in to individual features you could let people join an early access group that always gets access to new features. Or you could gate their ability to opt-in to new features by requiring that they belong to the early access group, and then you can control who is in that group the same you would with any other features. For example, you could use the console to add someone to the early access group, or you could create an administrative tool that lets you add someone to a `:beta_testers` group so non-technical team members can do it. ```ruby # Register a special group with Flipper by checking to see if they've been # flagged as a beta tester. Flipper.register(:beta_testers) do |actor, _context| actor.respond_to?(:beta_tester?) && actor.beta_tester? end # Ensure all beta testers in the group get early access without having to enable # it manually for each user Flipper.enable_group(:early_access, :beta_testers) ``` To use groups, you'd need to have an attribute on the `User` model that can serve as a flag for knowing when someone is beta tester. The easiest solution is to add a boolean, but you may already have flags for VIPs or a similar group that can be used in a similar fashion. Or, if there's no existing identifying characteristic/attribute for early access users, and adding one isn't feasible, you can enable them manually on a case-by-case basis. This approach isn't quite as tidy as using Flipper's groups, but it may be all you need. ```ruby class EarlyAccess attr_reader :email, :user FEATURE_KEY = :early_access def initialize(email) @email = email # Ensure there's a valid user with that email address, or it won't work # This could also check other status or role-based details to verify @user ||= User.find_sole_by(email: email) end def self.add!(email) new(email).enable! end def self.remove!(email) new(email).disable! end def toggle! Flipper.enabled?(FEATURE_KEY, user) ? disable! : enable! end def enable! Flipper.enable(FEATURE_KEY, user) end def disable! Flipper.disable(FEATURE_KEY, user) end end ``` Then you could use the `:early_access` flag to allow or prevent access to the opt-in feature flags. Or, maybe you have some feature flags that are available to everyone, but you limit some of the feature flags to your early access customers. The possibilities are endless, and you have maximum flexibility to design your opt-in features in the way that works best with your data model. Alternatively, each opt-in feature could get its own group. So instead of a wider "beta testers" group, people would be adding themselves to "feature one testers" or "feature two testers" and opt in or our of features individually. ### Toggling simple and advanced mode Finally, you may want to start customers off with a subset of key features or a simpler interface when they join, and then let them turn on the more advanced functionality once they've found their way around. This approach is similar to providing preferences or a labs area where people can opt in to features, but instead of opting in to features that have been widely released, they're simply turning on more advanced features that may create a little more clutter or confusion in the interface but allow them to perform an action with less clicking around. So with this approach, the difference is in the workflow. Those with limit access still have the features, they just don't have as many options for how they use the feature or where they access them from. This kind of approach works best for exposing shortcuts or interface conveniences that don't provide new functionality, they just provide faster ways to perform actions by adding widgets that might otherwise clutter the interface and overwhelm someone who's in the process of learning their way around your app. For a quick example, if you have an onboarding process, you can add people to a group as they complete steps. For example, say you create groups for "new", "onboarded", "beginner", "intermediate", and "advanced" users. Then as someone progresses through onboarding or after a set period of time, you can add them to the next group which will expose the additional functionality as they're ready for it. ## Wrapping Up Feature flags are great for slowly expanding a release to more customers, but it doesn't solve the problem that eventually some customers have significant changes forced onto them at inopportune times. It's certainly a great start, but feature flags can do so much more for you and your customers. Adopting feature flags for more gradual releases is a necessary first step, but you don't want to stop there. Let people have a say in their destiny so they can try out a new feature when they have the time and capacity instead of forcing them to adapt on the fly at a time when they could be navigating a critical deadline. It's a little more work up front, but once it's in place, the benefit to both you and your customers pays for itself in no time. --- Source: https://www.flippercloud.io/docs/guides/circuit-breakers # Using Circuit Breaker Feature Flags > Learn how to use feature flags as circuit breakers for both internal and external services to mitigate downtime. No web application is an island. Modern web applications are an amalgamation of services, and any single one of those services can need maintenance or be offline at any given moment. In some cases, a degraded service can take down the entire application or create ripple effects in terms of customer satisfaction, increased support requests, or a variety of other challenges. With carefully considered “circuit breakers” in place, however, that can change. ## What is a circuit breaker? Circuit breaker flags in web applications aren’t all that much different from the standard electric circuit breaker that protects devices so they don’t receive too much current and potentially start a fire. The main difference in web applications is that they aren’t limited to safety-centric scenarios. They can also be used to temporarily disable specific areas of functionality for a variety of purposes and even help mitigate spammers, bots, or standard traffic surges. Unlike temporary feature flags that are removed after a feature has been fully rolled out, circuit breaker flags tend to be long-lived—if not essentially permanent. Since the services behind circuit breakers represent core functionality, the circuit breakers serve as a devops tool to help mitigate issues and provide a better user experience during downtime or downgraded performance. ## Why use circuit breakers? Like many devops tools, circuit breakers make it less painful to handle unexpected events that lead to degraded performance or downtime. By designing an application with circuit breakers for the various services, it’s easier to proactively keep customers informed and ensure they aren’t unceremoniously dumped onto an empty page, or worse, a less-than-friendly generic error page. With circuit breakers and the relevant interface elements, teams can reduce support requests by informing customers of degraded performance or downtime right where they are. Instead of wondering if a feature is broken or if they should file a bug report, they can stay focused on their task without worrying about whether the team is working on it. Similarly, circuit breakers can streamline maintenance by disabling only the affected services with the hope that it can prevent more significant downtime in the larger application. - **Reduced support requests.** With proactive messaging and explanations, users don't need to contact support. - **Better user experience.** End users can receive explanations and answers instead of encountering generic error pages. - **Easier maintenance.** Temporarily disabling a feature in order to perform maintenance or updates to that specific feature reduces the chances of conflicts or downstream effects. - **Less overall downtime.** By catching and blocking problems caused by one feature, we increase the chances of keeping that feature from causing problems that could take down the entire application. With circuit breakers in place, teams can disable specific services and design the interface to gracefully handle the downtime. In the case of search, the search fields could be disabled and display a message proactively explaining the downtime as well as providing an estimate on when it will return. And circuit breakers don’t have to be limited to external services. They can be used for any type of maintenance or safety valve. Migrating or upgrading a database? Use flags to temporarily put the primary database into read-only mode during the cutover. Traffic surge affecting a non-critical service? Use a flag to disable it so it can’t cause problems for the more critical services. Spammers hammering a registration page? Temporarily disable registration or enable extra layers of verification for new accounts. ## Where can circuit breakers help? In the case of web applications, we can use circuit breakers to help manage a few different common challenges without needing to roll back or re-deploy. With Flipper, you can even toggle the flags from a mobile device if necessary. When adding a circuit breaker, we have two primary goals: protect the larger system from smaller failures and provide a more graceful experience for end users who would otherwise encounter the problem. Any scenario that can benefit from one or both of those conditions is a good candidate for a circuit breaker. In some cases, circuit breakers can used to completely disable a service, but they can also be designed to throttle a service so it can still work but maybe not as quickly as it normally would. Let’s take a look at some specific scenarios and example solutions using circuit breakers. ### 1. Mitigate External Provider Downtime With circuit breakers, teams can have an instant way to temporarily disable functionality affected by external providers. So for features like search or third-party logins, if the vendor is offline, the functionality can be disabled gracefully. In other cases like webhooks or polling, if provider goes offline, the webhooks and polling can be temporarily disabled until the provider is back online. Imagine an application’s search functionality depends on a third party provider, and that provider has a one-hour maintenance window planned where search temporarily won’t work. Without circuit breakers, when that provider starts their maintenance, the search box will still be visible in the interface, and people will still try to search. They may end up seeing an error page or an empty results page, and in many cases, that can mean an increase in support requests or even some lost trust or perception that the service is unreliable. Similarly, for apps that rely on third-party chat or support widgets, if the service goes offline, a circuit breaker could disable the interface elements for those tools and instead focus on directing people to send emails the old-fashioned way as a fallback for anyone that needs help. ### 2. Fail & Troubleshoot Gracefully In addition to providing insulation from external service issues, circuit breakers can also make it easier to troubleshoot. An internal service can temporarily disabled in production for most users while leaving it enabled for internal team members so they can still investigate and troubleshoot in production if necessary. For example, if an application has a collection of standardized reports that can be run and cached in the background but also has more performance-intensive ad hoc reporting that’s creating problems, then the ad hoc reporting could be disabled for all but the developers working on the problem. That way, they can still run ad hoc reports in production and follow the logs without having to leave the feature enabled for everyone. In the meantime, while the ad hoc reporting is offline, end users receive a status messaging that lets them know what’s happening and that the team is already working to fix the problem. It provides a better experience for the team fixing the problem and the customers who are inconvenienced by it. ### 3. Mitigate Downtime Caused by Non-critical services In the case of the previous example, being able to disable the ad hoc reporting could also play a role in mitigating larger downtime. If the reporting problem is database-related, that could create ripple effects that creates problems for other services. But by temporarily disabling the problematic service, the team gets some breathing room to address the issue. The same idea can be applied to areas like logging as well. If a surge in traffic is creating issues related to logging, being able to temporarily throttle or delay logging can be an almost invisible change that also creates some headroom until the larger problem can be solved. This can work with background jobs as well. If the server running background jobs is struggling to keep up, jobs can be processed on a delay, or systems that spin up a lot of non-critical jobs can let those jobs linger for a bit without being processed. ```ruby if Flipper.enabled?(:log_throttling) # Only log 10% of requests else # Log 100% of requests end ``` Alternatively, in cases like e-commerce, if there’s a problem processing a specific form of payment, a circuit breaker could temporarily disable that form of payment in order to avoid needing to completely disable checkout. It might temporarily affect sales, but it would minimize the amount of lost sales by ensuring the other payment methods stay available. ### 4. Lower Risk for Migrations & Maintenance Mode Sometimes when making large changes to the user-facing portion of a web application, some level of downtime is borderline inevitable. But what if the API interface could still work even if the web interface is in maintenance mode? It's not ideal, but it sure beats taking the whole application offline. ```ruby if Flipper.enabled?(:ui_maintenance) # Present a helpful message about the web interface maintenance, # and clarify that other API and other requests are unaffected. else # Handle the request like normal. end ``` Circuit breaker flags can also help with planned maintenance, migrations, or upgrades. They can provide a way to disable individual features during maintenance while leaving other functionality unaffected. For example, if you're making significant updates to your search indexing, you can temporarily disable the search interface while the rest of the application can still be fully usable. So instead of fielding endless support questions or taking your application offline, you can temporarily turn off search while leaving everything else unaffected. ```ruby if Flipper.enabled?(:search, current_user) # Enable Search UI in Views else # Disable Search UI in Views & Show Maintenance Message end ``` Similarly, during a database upgrade, a circuit breaker could be used to temporarily disable writes so that all of the data is still available to read, and end users are only partially inconvenienced instead of completely inconvenienced. ### 5. Protect Services from Bots and Spammers Another common use for circuit breakers is [protecting public-facing web forms like registration or support](/blog/fighting-bots-spam-with-feature-flags). At the simplest level, the forms can be completely disabled until the attack subsides. Or, in the case of contact forms, the form could automatically be replaced with an email address or social media handles so legitimate users still have options for support. ```ruby <% if Flipper.enabled?(:registration) %> # Show the Form <% else %> # Hide the Form and Display a Message <% end %> ``` Alternatively, if a registration form is being hammered and creating junk accounts, instead of fully disabling the form, a circuit breaker could enable more draconian additional verification steps during the attack in order to stem the tide while still letting legitimate traffic through—albeit at a slightly increased level of hassle. ```ruby <% if Flipper.enabled?(:registration) %> # Show the Form <% elsif Flipper.enabled?(:registration_protection) %> # Require additional verification steps <% else %> # Hide the Form and Display a Message <% end %> ``` Fully-disabling registration or public forms temporarily is certainly an option of last resort, but in some cases, it's the only thing that works when playing cat-and-mouse with bots or spammers. Even if it's only used to disable registration long enough to implement better spam controls, it can help. It's never any fun to try and manage a batch of spam while also trying to fix the underlying problem at the same time. ## Thinking Bigger We don't want a hammer and nail problem where everything we see looks like an opportunity to use feature flags, but we have endless scenarios where judicious feature flags can play a significant role. Circuit breakers provide a powerful way to help keep a large application running for the vast majority of users while minimizing the inconvenience to a subset of users. And being able to enable and disable those features from mobile devices can be the key between hours of review and cleanup or hitting pause to buy time to fix the problem. Better to briefly disable one feature than let a problem spiral out of control until it brings down the entire application. --- Source: https://www.flippercloud.io/docs/guides/backup-providers # Feature Flags for Backup Providers > Learn how to use feature flags to prevent downtime by switching to a backup service provider in real time. With any web application, it's rarely a matter of _if_ an external vendor will have performance issues or go offline so much as _when_ they will. For example, when an application relies entirely on a single email provider, when that provider is down or suffering from degraded performance, the application can't send password resets or other critical emails reliably. That can lead to frustrated users, increased support requests, or countless other problems. To avoid this, it's often useful to maintain a backup provider that can quickly be enabled for critical services. While there are several ways to manage primary and backup providers, using [circuit breaker feature flags](/docs/guides/circuit-breakers) can be one of the most efficient solutions because it enables making adjustments between providers in real-time without having to deploy new code or even restart the application. While this guide focuses on maintaining a permanent backup option, much of this approach works similarly for [minimizing or eliminating downtime when swapping back-end services as well](/blog/double-your-cache-double-your-fun). We'll look at an example of how Flipper can be used to determine the right email provider for a few scenarios where a primary provider is completely offline, experiencing degraded performance, or when you just prefer to split email delivery across two services. ## Why set up backup providers? The case in favor of using backup providers revolves around minimizing downtime and interruptions, and so the justification for having a backup provider for critical services is pretty basic. Any external service can become unreachable for a variety of reasons. Downtime. API changes. Bugs. And even going out of business. Given the relative simplicity of the reasons why any team _would_ want a backup provider, the more useful question here will be to address why someone _wouldn't_ want to set up a backup provider. Backup providers can provide resilience, but they also create new code paths and complexity. Similarly, if the backup provider isn't tested regularly, there's no guarantee that it will work reliably when you need it most. In some cases, testing the backup provider can be handled with automated tests, but in other cases, some tools may need more manual verification that the backup provider is working as expected. For example, if we're talking about email backup providers, it's entirely possible that the API request to send the email works, but the DKIM, SPF, or DMARC settings could be out-of-date. So while it would pass a basic automated test, the provider could still fail to get the emails to inboxes. Or if the provider modifies the headers or structure of their emails, that can create unintended delivery consequences as well. Alternatively, if a backup provider hasn't been used in a while, it's possible the account was locked due to failed payment or an expired credit card. That can't be monitored with automated tests, and that means someone has to be staying on top of billing for a provider the team may be barely using most of the time. Suffice it to say that while backup providers _can_ be helpful, they do increase the amount of work we need to do in order to ensure we can rely on the backup when the time comes. For larger apps, the case may be easy to justify, but for newer applications or those with smaller audiences, the resiliency may not be worth it. ## Where can backup providers help? We've touched on email, but backup provider can help reduce interruptions in plenty of additional scenarios. For the most part, the best candidates are the services where the end user likely wouldn't even notice the difference–things like email, SMS, payment processors, or CDN's. And when a framework like Rails enables swapping a provider by only changing some configuration values, like with ActionMailer or ActiveJob, that's a good indicator the provider might be better off with a backup as well. Let's walk through some scenarios where having a backup provider can have a significant impact on reducing service interruptions. As we explore scenarios, we'll assume that the default state is to send 100% of requests to the primary provider. Then each scenario adjusts according to the needs of that scenario.
A diagram showing a primary and secondary provider with 100% of the traffic being directed to the primary provider.
Under perfect circumstances, primary providers can handle everything on their own, but having a standby ready can help when something goes wrong.
### 1. Primary Provider is Fully Offline When the primary provider is fully offline or otherwise not working at all, having a backup provider comes through big time by making it trivial to switch all traffic to the backup provider for as long as needed. This is the simplest and most critical benefit of using backup providers, but it's far from the only benefit.
A diagram showing a primary and secondary provider with 100% of the traffic being directed to the secondary provider while the primary provider is offline.
In the worst case scenario where a provider is completely unreachable, being able to quickly replace it with a backup provider can significantly reduce inconvenience for end users.
### 2. Primary Provider has Degraded Performance In other cases, the primary provider may not be entirely broken but may be experiencing delays or other types of intermittent issues that aren't quite show-stoppers. In those cases, we may want to adjust which provider receives which types of traffic based on more nuanced decisions. For example, if our primary email provider is experiencing sending delays of five or ten minutes, all emails are still being delivered—eventually. But for critical and time-sensitive emails like password resets, that delay could significantly increase support requests and/or dissatisfaction. So in that case, we may only want to re-route critical emails to the backup provider. Alternatively, if our application has a freemium model, we may be alright leaving free customers with the primary provider and instead sending only our paying customers to the backup provider. This can be especially true if the backup provider has significantly higher costs.
A diagram showing a primary and secondary provider where the primary is online but with degraded performance. The diagram shows freemium accounts being directed to the primary provider but directing traffic for paying customers to the backup provider.
When a primary provider is limping along but not entirely unreachable, a team may want to prioritize one group of end users so they're unaffected.
### 3. Balance Traffic Across Providers Sometimes backup providers aren't just about being the last line of defense. We can also use backup providers in order to spread the workload across multiple providers in order to not entirely beholden to the whims of a single provider. The added bonus with this approach means that all of the providers are always in rotation, and that means we can be more confident if we every need to temporarily shift all of the traffic to one provider or the other.
A diagram showing a primary and secondary provider where the traffic is balanced across both providers.
With multiple providers in place, traffic can be split evenly as a way to ensure that both providers are always ready.
## Using Rails with Multiple Email Providers Before we get into the specifics of using Flipper to dynamically choose an email provider at delivery time, let's get the lay of the land for configuring email providers in Rails. We have several factors to consider, and we'll also discuss the pros and cons of relying purely on Rails for switching providers vs. using a solution like Flipper. ### Credentials & Settings The latest versions of rails offer [encrypted credentials](https://guides.rubyonrails.org/security.html#custom-credentials) for storing secure configuration values as well as unencrypted YAML for [custom configuration values](https://guides.rubyonrails.org/configuring.html#custom-configuration) that can be loaded using `Rails::Application.config_for` to convert it from YAML into a Ruby hash. With these options, we can define everything we need to use multiple email providers, but we can't easily switch between providers at runtime without a little more work. Also, we'd have to restart the application in order to pick up configuration-only changes. That's a little less convenient, but it's still better than having to wait for the primary provider to recover to 100%. ### Environment Variables Rails can also access environment variables like `ENV["email_back_provider"]` and use those to change values, but that too requires the application to be reloaded. The upside is that some hosting providers that make it easy to specify environment variables via a web interface would make it relatively simple to update an environment variable value. Since they (usually) automatically reload the application after changes to environment variables, it would just be a matter of specifying a different value, and the application would restart automatically. ### Environment Configuration Files So far, we've looked at ways to store and access values related to configuring the providers, but we haven't looked at how we set those values within our codebase. For the most part, these should already be at least somewhat familiar to anyone who has worked with Rails. Rails also provides environment configuration files so we can specify settings on a per-environment basis. The configuration for `application.rb`, `development.rb`, `test.rb`, `production.rb`, and other environments could be used to determine a provider, but that limits changes to when the application is loaded. So we'd still have to ensure our application restarts in order to pick up changes. Moreover, we're not looking to make environment-specific adjustments when it comes to backup providers because all of the value of having a backup provider flows directly to production. So logically, the environment configuration files aren't the ideal place to manage which provider we're using. ### ApplicationMailer If we'd like to be able to dynamically determine an email provider, the simplest solution involves updating our `ApplicationMailer` class so that it choose the provider automatically. By adding a `before_action` callback, we could design it choose the sending provider at the last moment. ```ruby class ApplicationMailer < ActionMailer::Base before_action :assign_email_provider # ... private def assign_email_provider self.smtp_settings = if Flipper.enabled?(:backup_email_provider) { # ... Backup Provider Settings } else { # ... Primary Provider Settings } end end end ``` For each of those settings, we can update any of [the relevant ActionMailer settings](https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration). It's not the exact implementation I'd choose in the long run, but it would work. We'll look at a more complete and well-designed solution shortly. ### Individual Mailers & Emails In addition to selecting the email provider entirely through _ApplicationMailer_, we can also choose the provider for individual mailers or even specify unique options for each individual email. To override the provider for an entire mailer, we could use a similar approach as above from the _ApplicationMailer_ example, but to override the sender for individual emails, we'd have to [dynamically override the delivery options](https://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-dynamic-delivery-options). ## Flipping Providers Efficiently While the built-in options from Rails can work, most would require at least a restart of the application in order to pick up the new settings. Similarly, these approaches are mostly all-or-nothing. The options that don't require a restart would require a significant amount of code to be sprinkled around the mailers since they can't easily distinguish which provider to use on their own. With Flipper, however, we can perform the relevant changes in a variety of ways in real time. Plus we can design everything to be well-contained and easier to follow. While the earlier _ApplicationMailer_ is pretty close conceptually, it would be nice to keep the `Flipper.enabled?` checks to a minimum. And if they can be tucked away in a class, even better. So if we wanted to update the application mailer, we need to specify `:delivery_method` and `:_settings` (ex. `:smtp_settings`, `:sendmail_settings`, etc.) ```ruby class ApplicationMailer < ActionMailer::Base before_action :assign_email_provider default from: "from@example.com" layout "mailer" private def assign_email_provider # The logic to know which email provider to use is entirely in # our EmailProvider class. This approach ignores considering # whether the specific recipient or email should be routed # routed differently. provider = EmailProvider.current # ex. :smtp, :sendmail, :file, :test, etc. self.delivery_method = provider.delivery_method.to_sym # Get name of delivery-method-dependent settings attribute # assignment. # ex. .smtp_settings=, .sendmail_settings=, .file_settings= settings_method = "#{provider.delivery_method}_settings=" # Assign provider settings to relevant settings attribute self.public_send(settings_method.to_sym, provider.settings) end end ``` Then we could design our `EmailProvider` to retrieve settings from credentials and set it up so that `EmailProvider.current` will always give us the relevant email provider. There's endless ways to approach this, but here's an example with some tests to help serve as a starting point that can be customized for your application. (An example of the credentials file format is included at the end for reference.) ```ruby class EmailProvider # It's convenient if we're able to directly compare # providers for testing and related logic include Comparable attr_accessor :delivery_method, :settings # Initialize the two values that we need to configure # the delivery method for our mailers. def initialize(delivery_method:, settings:) @delivery_method = delivery_method @settings = settings end # We can use the hash to check for equality, but # it also streamlines debugging def to_h { delivery_method: delivery_method, settings: settings } end def <=>(other) self.to_h <=> other.to_h end class << self # Designed to support checking specific ators, but # our current logic doesn't take advantage of it. def current(...) if Flipper.enabled?(:backup_email_provider, ...) secondary else primary end end def primary new(**settings_for(:primary)) end def secondary new(**settings_for(:secondary)) end def settings_for(email_provider) # Loading the values from credentials the same way # that they'd be used to configure mailers makes it nice Rails.application.credentials.dig( :email_provider, email_provider.to_sym ) end end end ``` The other advantage to encapsulating our email provider logic is that we can focus our tests primarily on ensuring that `EmailProvider.current` always gives us what we expect. This comes in handy since testing mailers will set `delivery_method` to `:test`. So we can't simply test that a mailer instance's delivery method corresponds to the correct provider. So with the encapsulation, we can be very thorough in terms of testing the provider switching, but then we can focus a test mailer on running once with the backup provider enabled and once with it disabled will give us the test coverage we need on the `ApplicationMailer` object. ```ruby require "test_helper" class EmailProviderTest < ActiveSupport::TestCase User = Struct.new(:id) do def flipper_id "User;#{id}" end end setup do @user = User.new(1) end test "defaults to primary provider" do Flipper.disable(:backup_email_provider) assert_equal EmailProvider.primary, EmailProvider.current end test "uses secondary provider when enable" do Flipper.enable(:backup_email_provider) assert_equal EmailProvider.secondary, EmailProvider.current end test "supports checking against actors" do Flipper.disable(:backup_email_provider) assert_equal EmailProvider.primary, EmailProvider.current(@user) Flipper.enable(:backup_email_provider) assert_equal EmailProvider.secondary, EmailProvider.current(@user) end test "uses correct providers for users individual actor" do other_user = User.new(0) Flipper.enable(:backup_email_provider, @user) assert_equal EmailProvider.primary, EmailProvider.current(other_user) assert_equal EmailProvider.secondary, EmailProvider.current(@user) end end ``` An example of the values in the credentials file. These correlate directly to the [ActionMailer configuration options](https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration) for the various delivery methods. ```ruby email_provider: primary: delivery_method: 'smtp' settings: address: 'smtp.primary.example.com' domain: 'example.com' user_name: '' password: '' authentication: 'plain' enable_starttls: 'true' secondary: delivery_method: 'sendmail' settings: location: '/usr/sbin/sendmail' arguments: - '-i' ``` A stock mailer for testing that the `ApplicationMailer` `before_action` doesn't cause any errors. ```ruby class BackupsMailer < ApplicationMailer def example @greeting = "Hi" mail to: "to@example.org" end end ``` We test the example mailer once with the flag enabled and once with the flag disabled. The test will still use the `:test` delivery method, but ensuring that it succeeds with each path gives us coverage while relying primarily on our `EmailProvider` tests for the underlying logic. ```ruby class BackupsMailerTest < ActionMailer::TestCase test "primary" do Flipper.disable(:email_backup_provider) mail = BackupsMailer.example assert_equal "Primary", mail.subject assert_equal ["to@example.org"], mail.to assert_equal ["from@example.com"], mail.from assert_match "Hi", mail.body.encoded end test "primary via backup provider" do Flipper.enable(:email_backup_provider) mail = BackupsMailer.example assert_equal "Primary", mail.subject assert_equal ["to@example.org"], mail.to assert_equal ["from@example.com"], mail.from assert_match "Hi", mail.body.encoded end end ``` With this logic, it simplifies the process of switching to a backup email provider, but the same concepts will work with most back-end services. While this implementation would only work with the flag fully-enabled, fully-disabled, or enabled for a percentage of time, it could be extended to take the recipient into account based the recipient's attributes that determine whether they should receive priority treatment or not. Keep in mind that emails with multiple recipients could lead to scenarios where some recipient should receive priority treatment and some shouldn't. So in those cases, it can be handy to choose the mail server based on if _any_ recipients should receive priority treatment. --- Source: https://www.flippercloud.io/docs/cli # CLI > Since 1.2.0, Flipper comes with a CLI to inspect the current state of your feature flags, and to enable or disable them. ## Installation The Flipper CLI is distributed as part of the `flipper` gem. Add it to your Gemfile with: $ bundle add flipper Or install it yourself with: $ gem install flipper ## Usage ``` $ flipper --help Usage: flipper [options] Commands: enable Enable a feature disable Disable a feature list List defined features show Show a defined feature Options: -r path The path to load your application. Default: ./config/environment -h, --help Print help message ``` ## Examples You can list your features: ```bash $ bundle exec flipper list administrator is ◯ enabled for 1 actor docsearch is ⏺ enabled expressions is ◯ enabled for an expression github_auth is ⏺ enabled google_auth is ⏺ enabled hubspot is ⏺ enabled rack_mini_profiler is ⏺ enabled scoped_tokens is ⏺ enabled seo is ⏺ enabled subscriptions is ⏺ enabled telemetry_receiving is ⏺ enabled trial_on_create is ⏺ enabled trial_lifecycle_emails is ⏺ enabled webhooks is ⏺ enabled adapter_request_logs is ⦸ disabled github_sync is ⦸ disabled fathom is ⏺ enabled fathom_masked is ⦸ disabled neutral_edit_feature is ⏺ enabled feature_stats is ⏺ enabled stats is ⦸ disabled version_check is ⏺ enabled userlist_onboarding is ⏺ enabled new_landing is ⏺ enabled ``` Look at a specific feature: ```bash bundle exec flipper show administrator administrator is ◯ conditionally enabled for: 1 actor - User;830138774 ``` And enable or disable a feature: ```bash bundle exec flipper disable fathom fathom is ⦸ disabled ``` --- Source: https://www.flippercloud.io/docs/optimization # Optimization > Learn the various options for optimizing the performance of feature flag checks based on your application's configuration and performance requirements. By default, Flipper will preload and memoize all features to ensure one adapter call per request. This means no matter how many times you check features, Flipper will only make one network request to Postgres, MySQL, Redis, Mongo or whatever adapter you are using for the length of the request. In some cases, you may need to optimize those settings. ## Memoization Memoization ensures that only one adapter call is made per feature per request. This is the default behavior and is recommended. You can prevent memoization (and thus preloading) on specific requests by setting `memoize`: ```ruby # config/initializers/flipper.rb Rails.application.configure do config.flipper.memoize = ->(request) { !request.path.start_with?("/assets") } # or disable memoization entirely config.flipper.memoize = false end ``` Disabling memoization will also disable preloading. ### Preloading Flipper will preload all features before each request by default, which is recommended if: * you have a limited number of features (< 100?) * most of your requests depend on most of your features * you have limited gate data combined across all features (< 1k enabled gates, like individual actors, across all features) The reason for these recommendations is that *more features and gates means more data being preloaded* for every request. The general rule is: leave preloading on until performance is negatively affected at which point it has served its purpose and should be turned off. You can track performance by [instrumenting](/docs/instrumentation) flipper usage to your favorite metrics system. If you need to customize preloading, set the `preload` config: ```ruby # config/initializers/flipper.rb Rails.application.configure do # Load specific features that are used on most requests config.flipper.preload = [:stats, :search, :some_feature] # Or a proc that returns true/false depending on the request config.flipper.preload = -> (request) { !request.path.start_with?('/assets') } # Or, return specific features to preload config.flipper.preload = -> (request) { request.path.starts_with?('/admin') ? [:stats, :search] : false } # Or disable preloading config.flipper.preload = false end ``` Features that are not preloaded are still memoized, ensuring one adapter call per feature during a request. ### Advanced (non-Rails usage) Memoization is implemented as a Rack middleware, which can be used manually in any Ruby app: ```ruby use Flipper::Middleware::Memoizer, preload: true, unless: ->(request) { request.path.start_with?("/assets") } ``` **Also Note**: If you need to customize the instance of Flipper used by the memoizer, you can pass the instance to `SetupEnv`: ```ruby use Flipper::Middleware::SetupEnv, -> { Flipper.new(...) } use Flipper::Middleware::Memoizer ``` ## Cache Adapters Cache adapters allow you to cache adapter calls for longer than a single request and should be used alongside the memoization middleware to add another caching layer. ### Dalli > Dalli is a high performance pure Ruby client for accessing memcached servers. https://github.com/petergoldstein/dalli Example using the Dalli cache adapter with the Memory adapter and a TTL of 600 seconds: ```ruby Flipper.configure do |config| config.adapter do dalli = Dalli::Client.new('localhost:11211') adapter = Flipper::Adapters::Memory.new Flipper::Adapters::Dalli.new(adapter, dalli, 600) end end ``` ### RedisCache Applications using [Redis](https://redis.io/) via the [redis-rb](https://github.com/redis/redis-rb) client can take advantage of the RedisCache adapter. Initialize `RedisCache` with a flipper [adapter](/docs/adapters), a Redis client instance, and an optional TTL in seconds. TTL defaults to 3600 seconds. Example using the RedisCache adapter with the Memory adapter and a TTL of 4800 seconds: ```ruby require 'flipper/adapters/redis_cache' Flipper.configure do |config| config.adapter do redis = Redis.new(url: ENV['REDIS_URL']) memory_adapter = Flipper::Adapters::Memory.new Flipper::Adapters::RedisCache.new(memory_adapter, redis, 4800) end end ``` ### ActiveSupportCacheStore Rails applications can cache Flipper calls in any [ActiveSupport::Cache::Store](http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html) implementation. Add it to your application's Gemfile with: $ bundle add flipper-active_support_cache_store Or install it yourself with: $ gem install flipper-active_support_cache_store Example using the ActiveSupportCacheStore adapter with ActiveSupport's [MemoryStore](http://api.rubyonrails.org/classes/ActiveSupport/Cache/MemoryStore.html), Flipper's [Memory adapter](https://github.com/flippercloud/flipper/blob/main/lib/flipper/adapters/memory.rb), and a TTL of 5 minutes. ```ruby require 'active_support/cache' require 'flipper/adapters/active_support_cache_store' Flipper.configure do |config| config.adapter do Flipper::Adapters::ActiveSupportCacheStore.new( Flipper::Adapters::Memory.new, ActiveSupport::Cache::MemoryStore.new, # Or Rails.cache 5.minutes ) end end ``` Setting `expires_in` is optional and will set an expiration time on Flipper cache keys. If specified, all flipper keys will use this `expires_in` over the `expires_in` passed to your ActiveSupport cache constructor. --- Source: https://www.flippercloud.io/docs/instrumentation # Instrumentation > Learn how to instrument Flipper to be notified of feature operations and events. Flipper comes with built-in instrumentation. Rails apps are pre-configured to use [ActiveSupport Instrumentation](https://guides.rubyonrails.org/active_support_instrumentation.html). See [Advanced Setup](#advanced-setup) to manually configure outside of Rails. ## Subscribing to feature operations Flipper publishes events under the `feature_operation.flipper` key whenever a feature is checked or modified. So to get notified when your code calls `Flipper.enabled?(:my_feature)` or any other operation, you can add a subscriber in an initializer: ```ruby # config/initializers/flipper.rb ActiveSupport::Notifications.subscribe('feature_operation.flipper') do |event| case event.payload[:operation] when :enabled? puts "#{event.payload[:feature_name]} enabled? #{event.payload[:result]}" when :enable puts "#{event.payload[:feature_name]} enabled!" when :disable puts "#{event.payload[:feature_name]} disabled!" when :add puts "#{event.payload[:feature_name]} added!" when :remove puts "#{event.payload[:feature_name]} removed!" when :exist? puts "#{event.payload[:feature_name]} exist?" when :clear puts "#{event.payload[:feature_name]} cleared!" end end ``` The payload contains: - `:feature_name` - The name of the feature that Flipper is performing the operation on. For example, `:search` when you call `Flipper.enabled?(:search)`. - `:operation` - One of `:enabled?`, `:enable`, `:disable`, `:add`, `:remove`, `:exist?`, and `:clear`. - `:result` - The result returned when calling the operation. ## Subscribing to adapter operations If you need to know exactly what's happening at the adapter level, you can use the `Instrumented` adapter to subscribe to `adapter_operation.flipper` events. You'll need to manually configure your Flipper adapter before you can subscribe. ```ruby # config/initializers/flipper.rb Flipper.configure do |config| # To instrument `adapter_operation` events config.adapter do Flipper::Adapters::Instrumented.new( Flipper::Adapters::Memory.new, instrumenter: ActiveSupport::Notifications ) end end ActiveSupport::Notifications.subscribe('adapter_operation.flipper') do |event| puts event.inspect end ``` ## Advanced Setup If you are using Flipper outside of Rails, or want to use a different instrumentation library than `ActiveSupport::Notifications`, you can manually configure it by passing the `instrumenter` option to the Flipper instance, and optionally wrap your adapter with the `Instrumented` adapter to get `adapter_operation` events: ```ruby require 'active_support/notifications' Flipper.configure do |config| # To instrument `adapter_operation` events config.adapter do Flipper::Adapters::Instrumented.new( Flipper::Adapters::Memory.new, instrumenter: ActiveSupport::Notifications ) end # To instrument `feature_operation` events config.default do Flipper.new(config.adapter, instrumenter: ActiveSupport::Notifications ) end end ``` ## Pre-built Subscribers Flipper comes with a few pre-built subscribers. ### Logging The log subscriber is enabled by default in Rails apps. To use it outside of Rails, just require it: ```ruby # Gemfile gem "activesupport" # config/initializers/flipper.rb (or wherever you want it) require "flipper/instrumentation/log_subscriber" ``` ### StatsD To use the statsd instrumentation in Flipper 1.1.0 or later: ```ruby # Gemfile gem "activesupport" gem "statsd-ruby" # config/initializers/flipper.rb (or wherever you want it) Flipper.configure do |config| config.statsd = Statsd.new # or whatever your statsd instance is end ```
Prior to Flipper 1.1.0 ```ruby require "flipper/instrumentation/statsd" Flipper::Instrumentation::StatsdSubscriber.client = Statsd.new # or whatever your statsd instance is ```
--- Source: https://www.flippercloud.io/product/benefits/ai # Let your AI assistant clean up feature flags. > Connect Claude Code, Codex or Cursor to Flipper Cloud, ask which flags are ready to remove, get answers grounded in what's actually running, and let your assistant create, change and remove flags. Many feature flags are promises to come back and clean up later. Most teams never do, and old flags pile up until nobody remembers which ones are safe to delete. Flipper Cloud's [MCP server](/docs/cloud/mcp) gives your AI coding assistant what it needs to keep that promise for you. ## Ask which flags are done Ask "Which Flipper flags can we remove?" and your assistant checks every environment at once. A flag that's on in production but off in staging isn't done, and a flag someone changed yesterday isn't either. You get a short list, strongest first, with the reason for each: fully enabled everywhere, fully disabled everywhere, or always returning the same answer. ## Answers from real usage, not guesses Most tools call a flag stale because nobody touched it in a while. Flipper Cloud knows more than that. With [telemetry](/docs/cloud/telemetry), it knows how often your apps check each flag and what they got back, so it can tell a flag that's quietly returning true for everyone from one that's mid-rollout. With [audit history](/docs/cloud/audit-history), it knows who changed a flag and when. Your assistant sees the evidence and tells you how confident to be. ## Then remove the code Your assistant already has your codebase open. Once it knows a flag has been fully enabled everywhere, it can remove the check, keep the code path that's actually running, and leave you a small diff to review. Deploy that, and if you've allowed it, your assistant deletes the flag from Flipper Cloud too. ## And manage flags as you build The same assistant can create the flag for the feature it's building, turn it on for your team in staging, then roll it out to a percentage of production. You decide how far it goes: creating flags, changing them outside production, changing them in production, and removing them are separate choices. ## Safe by design Your assistant changes flags only where you allowed it when you connected it, and changing production or removing flags are never pre-checked. It signs in as you, sees only the projects you can see, changes only what your role allows, records every change under your name in the audit history, and loses access the moment you disconnect it. Assistants see your teammates' names, never their email addresses, and never your customers' actor IDs. ## Works with your assistant Claude, Claude Code, Codex, Cursor, and any MCP client: sign in with your Flipper Cloud account or use an API key. [Set it up in two minutes](/docs/cloud/mcp), and pair it with our [AGENTS.md section for coding agents](/docs/agents) so new flags get cleaned up too. --- Source: https://www.flippercloud.io/product/benefits/flexibility # Feature flags aren't just for features any more. > Remove the friction from countless development tasks and tools with controls for anything in personal development environments. ## Internal Tools Enable team members to toggle internal tools like performance monitoring, analytics, or chat widgets in their development environment.
Screenshot of a 'rack-mini-profile' feature that's disabled everywhere except for two actors in production.
Tools like rack-mini-profiler can live behind a flag so different team members can enable or disable it based on the work they're doing and the environment they're working with.
```ruby class ApplicationController < ActionController::Base before_action :setup_rack_mini_profiler private def setup_rack_mini_profiler if Flipper.enabled?(:rack_mini_profiler, current_user) Rack::MiniProfiler.authorize_request end end end ``` ## Circuit Breakers & Maintenance Use feature flags to disable individual features for maintenance while leaving other functionality unaffected. For example, if you're making significant updates to your search indexing, you can temporarily disable the search interface while the rest of the application can still be fully usable. So instead of fielding endless support questions or taking your application offline, you can temporarily turn off search while leaving everything else unaffected. ```ruby if Flipper.enabled?(:search) # Enable Search UI in Views else # Disable Search UI in Views # - Show maintenance tooltip with estimated return end ``` ## Fast Backup Provider Cutovers Leverage controls to make it easier to swap to backup providers any time your primary vendor is down or sluggish. For example, when using a third-party email provider, you'll like have a preferred vendor, but even the best apps occasionally have issues. With Flipper, you can set up a backup vendor, and then if your primary provider has any temporary issues, you can quickly cutover to your backup provider. Since Flipper Cloud is optimized for mobile, you can even make the change from your phone. ```ruby class EmailProvider def current Flipper.enabled?(:backup_email_provider) ? secondary : primary end def primary # Preferred Vendor Details end def secondary # Backup Vendor Details end end ``` ## Block Bad Actors Every web app eventually has to deal with bad actors. Whether intentional or unintentional, if a single user causes problems, you can temporarily disable access for only that user—either for a single feature or for your entire application. Feature flags can work with individuals actors or a group of "bad actors" to provide a way to disable access to specific features for specific users. For example, if a bot is spamming your contact form, you can replace the contact form with a message that it's temporarily offline for maintenance—but only for that specific user. ```ruby Flipper.register(:bad_actors) do |actor, context| actor.respond_to?(:bad_actor?) && actor.bad_actor? end Flipper.disable_group :contact_form, :bad_actors if Flipper.enabled?(:contact_form, current_user) # Show contact form else # Show maintenance message for just that user end ``` --- Source: https://www.flippercloud.io/product/benefits/organization # Seamlessly Organize and Manage Feature Flags > Projects, environments, and permissions that ensure you control the feature flags rather than having them control you. ## Assign feature owners With feature owners, there's neve any question who to ask for updates or how to know if the team has plans for a given feature flag in the near future.
A screenshot of the new feature form with focus on the 'Owner' field which is a drop down list of project team member names.
Assign owners to features so everyone knows who to check with.
## Know when flags are safe to delete Flipper lets know the last time each flag was checked for each environment so temporary flags can be removed and deleted safely. Flipper lets know the last time each flag was checked for each environment so you always [know when those temporary flags can be removed and deleted safely](/blog/how-to-tell-when-its-safe-to-remove-a-feature-flag).
Screenshot of a feature flag's status summary. The heading says 'Fully Enabled in Prodution', then the last change is shown to be about one month ago, and the feature flag was last checked from production about two minutes ago.
Flipper lets you know a feature flag's current state in production, when it was last changed, and whether it has been checked in production recently so you know if it's ready to delte.
## Tag related features Temporary or permanent flag? Circuit breaker? Which area of the application does it affect? Tags help stay on top of all of your flags ([quick demo](/blog/early-gifts-under-the-tree#tag-picker)).
Screenshot of the edit feature form showing the tags input which displays a list of the most-used tags below it.
Temporary or permanent? What module of the application does it affect? Add tags to create a predictable organization structure for your team's flags.
## Leverage unlimited projects and environments You can never have too many projects or environments, and you never have to worry about having too many. Keeping features organized is easier than ever.
In addition to features, there's no limit on projects or environments so you can structure and organize controls the way that works best with your application's release process and architecture.
## Find anything instantly with Command+K No matter how many features, projects, or environments you have, finding what you need is just a keystroke away. Press `Cmd+K` (or `Ctrl+K` on Windows/Linux) to open the [search modal](/docs/search) and start typing ([quick demo](/blog/early-gifts-under-the-tree#super-search)). Search across features, environments, projects, and organizations instantly.
Screenshot of the Command+K search modal showing search results for 'google' with several feature flags listed including google_auth, trusted_domains, and google_analytics, each showing their environment and project breadcrumb.
Press Cmd+K to instantly search across all your features, projects, and environments.
The search is context-aware too. When you're viewing a specific environment, quick actions appear for common tasks like viewing history, managing credentials, or configuring webhooks. It's the fastest way to navigate Flipper Cloud. [Learn more about search →](/docs/search) ## Stay current with the latest features Managing dependencies and versions is just part of the process, but with Flipper, it's a little easier. If Flipper, Rails, or Ruby ever start to fall behind the target versions, you'll know ahead of time to help plan for any necessary updates.
Screenshot of the projects list showing a 'New Project' button and an 'Environments' menu that let's people navigate to a specific environment or add a new one.
Flipper proactively helps stay on top of version upgrades for it and its primary dependencies.
## Unlimited team members While Flipper UI provides a great interface for managing feature flags, it doesn't support multiple team members and the resulting audit history as individuals make changes. With Flipper Cloud, not only are team members connected with their activity, but each team member has their own personal environment so they can develop against the flag data they need without stepping on anybody else's toes. Getting people onboarded is easy too. Invite teammates directly, or verify your company's email domain and anyone who signs up with Google using that domain is automatically added to your organization. No manual invitations needed — your whole team can get started in seconds with the right access from day one. ## Automated testing as a first-class citizen Introducing feature flags means introducing alternative code paths, and that means testing those code paths. Flipper Cloud makes it easy to test your code with feature flags by providing a simple way to [enable and disable features in tests](/docs/testing). ```ruby require 'test_helper' class DocumentationControllerTest < ActionDispatch::IntegrationTest test "returns 404 for documentation when feature disabled" do Flipper.disable(:docs) get documentation_path assert_response :not_found end test "renders documentation when feature enabled" do Flipper.enable(:docs) get documentation_path assert_response :success end end ``` --- Source: https://www.flippercloud.io/product/benefits/resiliency # Your feature flag data and no blocking requests. > Flipper is designed to never take your app down—even if Flipper Cloud goes offline temporarily. ## Keep it local With multiple levels of adapters and reads that are local to your application, you'll have blazing fast feature checks that are always available and in sync, even if Flipper Cloud isn't for some reason. We've even written about this in detail. ## Store data your way Flipper uses [adapters](/docs/adapters) so you can store your flag data in a relational database, non-relational database, or anywhere really. You can use on of our existing adapters or [write your own](/docs/adapters/new).
Storage You definitely need one of these.
ActiveRecord Production Rails apps
Moneta Production Ruby apps already using Moneta
Mongo Production Ruby apps already using Mongo
Redis Production Ruby apps already using Redis
Sequel Production Ruby apps already using Sequel
Cache Reduce calls to storage to speed things up.
ActiveSupportCacheStore Production Rails apps with aggressive caching needs
Dalli Production Ruby apps already using Dalli
Redis Cache Production Rails apps with aggressive caching needs
Extras Additional functionality to complement primary adapters.
ActorLimit Limits the number of actors that can be enabled for a feature (default: 100)
Failover Increasing reliability by failing over to a secondary adapter if primary is unavailable
Failsafe Graceful failures when an exception is raised
Instrumented Instrumenting all adapter operations with ActiveSupport::Notifications
Read Only Preventing writes from a Production console
Strict Raising an error if an unrecognized flag is used
Internal You probably dont need these but here they are.
Dual Write Read from one adapter but write to two (used by Cloud)
Memoizable Prevent subsquent calls to an adapter for the same feature (used by memoizing middleware)
Memory Testing Environments
Operation Logger Stores all adapter operations in memory for verification in tests
Poll Polls for changes from a remote adapter in a background thread but updates local adapter in main thread (used by Cloud)
Sync Keeping two adapters in sync (bits are used in Cloud)
Niche Highly specialized adapters outside of day-to-day usage.
HTTP Connecting to Flipper::Api
PStore When a local file is enough or you need something that works with multiple processes like some system tests
Rollout Migrating from Rollout to Flipper
## Keep multiple servers in sync Flipper always keeps a copy of flag data locally for each system using it, but with multiple servers, that data needs to stay in sync so that all of the systems are on the same page about each feature. Flipper Cloud can then serve as the source of truth for all of the systems and proactively notify them when they need to pull down the latest updates to your feature flag data. ## Rest easy with backups With Flipper Cloud as the source of truth, you can rest easy knowing that your feature flag data is automatically backed up and safe. So if you need to bring new systems online or recover from other issues, you'll always have a backup of your feature flag data in the Cloud. That way, your local copies and local backups always have the ultimate backup with Flipper Cloud. --- Source: https://www.flippercloud.io/product/benefits/safety # Launches and deploys can be much less stressful. > Roll out new features gradually over time, and roll back instantly and effortlessly if something goes wrong. Coordinating deployments with feature releases is the past. With feature flags, the development team can deploy whenever the code is finished, and the product/marketing team can enable and announce new features to whoever they want, whenever they want. And with feature flags in the mix, pull requests can be smaller and more focused—making them easier to both review and deploy with less risk. Instead of one large release, you can break a large feature up into multiple pieces with everything behind a feature flag until you're flip the switch. ## Roll out gradually Not only can pull requests be smaller and more frequent, but by gradually building and releasing a new feature behind a feature flag, the team can catch problems sooner and fix them ahead of the full launch. And since it's easy to gradually expand the audience for a new feature, you can start with a small percentage of users and expand the audience as your confidence increases.
Screenshot of a feature's audit history where the percentage of time has been gradually increased every hour or two.
Steadily increase or decrease acceess to a feature over time.
## Roll back instantly Every now and then a release doesn't go as planned. Without feature flags, roll back a change could mean waiting for the entire application to re-deploy. With feature flags, however, it's as simple as flipping a switch, and all affected systems will be instantly rolled back to the previous state. Even better, the problematic code is still available in production. That way, the feature can be re-enabled for the relevant team members to troubleshoot.
A screenshot of a feature audit history even with a large button labeled 'Rollback to this state'
Every event in your audit history can be used for point-in-time rollbacks that ensure all dependent systems are updated.
## Protect critical environments While every Flipper users receives their own personal development environment, some environments like staging or production can benefit from a little extra protection. With Flipper, you can restrict who can control the state of a feature flag in any environment. Anyone else on the team can still view the state of a flag in any environment and mirror that state for their own environment, but mission-critical environments can be protected from accidental changes.
A screenshot of environment settings with radio buttons for three groups: project team members, organization team members, or environment owners.
Restrict toggling features in each environment to team members, organization members, or select environment owners.
## Review audit histories Flipper logs every change by every user to every feature in every environment. That way, you can always know when a feature was enabled, disabled, or adjusted in any environment and who made the change. Even better, you can roll back the change directly from the audit history.
A screenshot of a list of audit history events with changes and rollbacks.
Every time a control is changed or updated, Flipper records the change to the log for a full history and convenient rollbacks.
## Get notified in Slack When a feature flag changes, your team should know about it. Connect Flipper Cloud to Slack and receive real-time notifications whenever a flag is enabled, disabled, or modified. Each notification includes what changed, who made the change, and a direct link back to the flag—so everyone stays informed without having to check the dashboard. ## Team members all have personal environments Since every team member automatically receives their own personal environment, they can enable or disable features without affecting other team members, but they can also mirror the state of the feature in production to ensure their environment is as close to production as possible.
A screenshot of a feature disabled with a button to 'Mirror' the production environment state.
Flipper ensures it always fast to set up other environments to mirror prodution.
--- Source: https://www.flippercloud.io/product/benefits/strategies # Strategically release new features and functionality. > Roll out new features on your schedule—not just when the code is deployed. And if something is off, roll it back without redeploying either. Never give a second thought to coordinating deployments that involve feature releases. With feature flags, the development team can deploy whenever the code is finished, and the product/marketing team can enable and announce new features to whoever they want, whenever they want. Since feature flags aren't just on for everybody or off for everybody, you decide which launch strategy works best for the new features or functionality and your customers. You can manage the state of a flag from [Flipper UI](/docs/ui), [Flipper Cloud](/), or [using Ruby and the API](/docs/features). ## Enable for individual actors With Flipper, you can enable features in any environment for any user. Let internal team members review new functionality in production before enabling it for customers. Or let key customers get early access to new features. Or enable a feature for a single user to help troubleshoot an issue. With feature flags, releasing new stuff is no longer an all-or-nothing proposition—it's more scalpel than sledgehammer.
Screenshot of a form with an auto-suggest input field for adding an actor to a feature.
Select individual actors to enable features on a one-off basis.
```ruby Flipper.enable_actor :new_design, current_user Flipper.enabled?(:new_design, current_user) # => true ``` ## Enable for specific groups of actors If you're comfortable expanding access to new functionality even further, you can set up a group for early access for those customers that always help troubleshoot and provide detailed feedback. Or you can create a dedicated group to let customers opt-in to new stuff early and on their timeline.
Screenshot of a form with an auto-suggest input field for adding a group to a feature.
Create groups to enable features for batches of people.
```ruby Flipper.enable_group :new_design, :paying_customers Flipper.enabled?(:new_design, paying_customer) # => true ``` ## Enable for a percentage of actors Ready to let more customers in but not quite ready for the full wave of performance implications or customer support questions? Enable the new feature for a percentage of users to get a feel for how it's going to go, and expand the percentage as your confidence increases.
Screenshot of a slider input adjacent to a numeric input with the slider about halfway across and the numeric value at 50%
You can gradually increase a percentage of actors to expand access to a new feature cautiously.
```ruby Flipper.enable_percentage_of_actors(:new_design, 25) # Returns true or false consistently for the # same enabled percentage and actor Flipper.enabled?(:new_design, user) ``` ## Enable for a percentage of time Swapping out caching strategies or background job infrastructure? Split the percentage of traffic sent to the old and new systems to ensure the new system is ready to go before you flip the switch for everybody. And since you can gradually increase the percentage of traffic, it's no longer a cross-your-fingers-all-or-nothing proposition.
Screenshot of a slider input adjacent to a numeric input with the slider about one-fifth of the way across and the numeric value at 20%
Try out new functionality in production without immediately throwing 100% of requests at it.
```ruby Flipper.enable_percentage_of_time(:new_design, 25) # Returns true for ~25% of the enabled? calls # regardless of the actor provided. Flipper.enabled?(:new_design) Flipper.enabled?(:new_design, user) ``` ## Enable with expressions Need more control? [Expressions](/blog/early-gifts-under-the-tree#expressions) let you define rules based on actor properties like plan type, country, account age, or any other attribute. Combine conditions with AND/OR logic to create sophisticated targeting rules—all stored as JSON and synced across your servers automatically.
Screenshot of the expression builder interface showing conditions for plan equals premium, age greater than 20, and country equals usa combined with AND/OR logic.
Build complex targeting rules using the visual expression builder with AND/OR logic.
```ruby # Enable for premium users in the US who are over 21 premium = Flipper.property(:plan).eq("premium") us_based = Flipper.property(:country).eq("US") of_age = Flipper.property(:age).gte(21) Flipper.enable :vip_lounge, Flipper.all(premium, us_based, of_age) Flipper.enabled?(:vip_lounge, user) # Evaluates the expression ```