Feature Flags
Manage rollout of new features for specific users and organizations with Feature Flags.

Feature flags are a tool that allows teams to control the rollout of features in real time. They enable businesses to separate feature delivery from code deployment, creating a more agile and risk-managed approach to launching and managing product experiences.
WorkOS Feature Flags provides a developer-friendly solution that integrates seamlessly with your existing authentication flow. Create and manage flags through the dashboard then access them through a user’s access token. Feature flags can target organizations, individual users, or resources from your own application. This approach lets you safely roll out new functionality, enable beta programs for select customers, and manage premium feature access without deploying code changes.
- Targeted rollouts: Enable features for specific organizations before a general release
- Beta programs: Allow early access to new features for select customers
- Holdouts: Keep a feature off for a few organizations while everyone else has it
- Premium features: Restrict advanced functionality to organizations on higher-tier plans
Common targeting setups walks through building each of these in the editor.
To get the most out of these guides, you’ll need:
-
An existing organization in your WorkOS Dashboard

- Organization
- Describes an organization whose users sign in with a SSO Connection, or whose users are synced with a Directory Sync Connection.
- User
- Describes a user who can be targeted with feature flags.
- Sign in to your WorkOS dashboard account and navigate to the Feature Flags page.
- Click the
Create feature flagbutton and enter a name, slug, and description.

Feature flags are created across all environments in a project, allowing you to test your feature flag in a sandbox environment before enabling it in production.
Open the flag to see how it evaluates in your active environment. The editor is laid out in the order the flag is evaluated:
- The environment card turns the flag on or off. While the flag is off, it evaluates to
falsefor everyone, no matter which rules are configured. The card’s summary states who can currently see the feature, such as “On for Foo Corp, off for everyone else”. - Targeting rules each name a set of targets and the value to serve when one of them matches,
TrueorFalse. Rules are checked from top to bottom, and the first rule that matches decides the value. Drag a rule to reorder it. - The
Everyone elsevalue – the flag’s default – is served when no rule matches.

To target the users and organizations that should have access:
- Click
Add ruleand chooseTarget organizationsorTarget users. To target a resource WorkOS doesn’t model, such as a workspace or a pricing plan, chooseAdd a custom targeting rule– the custom targets guide covers these. - Select the rule’s targets in the panel that opens.
- Set the value the rule serves.
Truegrants the feature to the rule’s targets.Falsewithholds it from them, even when a later rule or theEveryone elsevalue would grant it. - Set the
Everyone elsevalue:Falsewhile rolling out to a list of targets,Trueonce the feature should be on for everyone not excluded by a rule.
A flag can have up to two organization rules and two user rules – typically one serving each value – along with custom rules, up to 50 rules in total.
Nothing takes effect while you edit. Clicking Save changes lists every staged change and asks you to confirm the environment name before applying them.
To configure the flag in another environment, switch your active environment with the environment selector. Rules are configured separately in each environment.
Once the rules are in place, turn the flag on with the switch in the editor and save. When the flag evaluates to true for a user, its slug is included in the feature_flags claim of their access token the next time they authenticate or their session refreshes.
The environment card confirms the result, for example “On for Foo Corp, off for everyone else.”

Turning the flag off is a kill switch: the flag evaluates to false for everyone while your targeting stays intact, ready for the next time the flag is enabled.
The access token includes the feature_flags claim, containing the user’s entitlements. You can use this information to gate access to features in your application.
Feature flags will show up in the access token the next time the user logs in or the session is refreshed. You can manually refresh the session after granting the organization access in the dashboard.
| app.get('/api/feature-flags', async (req, res) => { | |
| // load the original session | |
| const session = workos.userManagement.loadSealedSession({ | |
| cookiePassword: process.env.WORKOS_COOKIE_PASSWORD, | |
| sessionData: req.cookies['wos-session'], | |
| }); | |
| const { sealedSession, featureFlags } = await session.refresh(); | |
| // set the updated refresh session data in a cookie | |
| res.cookie('wos-session', sealedSession, { | |
| httpOnly: true, | |
| sameSite: 'lax', | |
| secure: true, | |
| }); | |
| // return the feature flags to the client | |
| res.json({ | |
| featureFlags, | |
| }); | |
| }); |
| // Fetch feature flags from your server endpoint | |
| const response = await fetch('/api/feature-flags'); | |
| const { featureFlags } = await response.json(); | |
| if (featureFlags.includes('new-feature')) { | |
| // Show new feature | |
| } |
The examples are JavaScript, but the claim travels inside the access token, so this approach works on any platform whose AuthKit SDK gives you an authenticated session.
On Node or Python, use the runtime client instead.
- Every flag in the
feature_flagsclaim takes up space in the access token, which is stored in the AuthKit session cookie. - Browsers cap how large a cookie can be and JWT templates must render to 3072 bytes or smaller. A growing flag set eats into that budget, and so do role and permission claims.
- The runtime client evaluates flags server-side without putting them in the token, so the number of flags stops being a constraint.
A flag is created in every environment of the project. Taking a flag to production means building the flag’s rules in that environment:
- Switch your active environment to production. Your staging rules stay as they are.
- Start narrow: add an organization or user rule serving
Truewith a few targets, keepEveryone elseonFalse, and confirm the feature behaves. - Widen by adding targets to the rule, then go broad by setting
Everyone elsetoTrueand deleting the rule – or keep a rule servingFalsefor any organizations staying on the old experience. - When the feature is on for everyone and the old code path is gone, delete the flag so it doesn’t outlive the rollout.
Each setup lists the rules to build in the editor. In every case the same three facts decide the outcome: rules are checked from top to bottom, the first matching rule decides the value, and the Everyone else value – the default – applies only when no rule matches.
Enable a feature for design partners or early customers before a general release.
- Click
Add ruleand chooseTarget organizations, then select the organizations. - Leave the rule serving
True. - Set
Everyone elsetoFalse.
Users in the selected organizations get the feature. Anyone else matches no rule and falls through to Everyone else. To widen the rollout, add organizations to the same rule.

Give early access to specific people, independent of which organization they belong to.
- Click
Add ruleand chooseTarget users, then select the users. - Leave the rule serving
True. - Set
Everyone elsetoFalse.
This composes with an organization rollout: a flag can carry a user rule for individual beta testers and an organization rule for fully enrolled customers at the same time.

The feature is generally available, but a few organizations asked to stay on the old experience – or you want to keep a control group.
- Set
Everyone elsetoTrue. - Click
Add ruleand chooseTarget organizations, then select the holdout organizations. - Set the rule to serve
False.
The holdout organizations match the rule and are served False. Anyone else matches no rule and falls through to Everyone else, True. There is no rule to create for the general population – that is exactly what the Everyone else value is.

Rules serving False need a current runtime client. The feature_flags access token claim always honors them, because WorkOS evaluates it server-side. The runtime client honors them in @workos-inc/node version 12.0.0 or later and in the workos Python package version 10.8.0 or later – earlier Node versions ignore rules that serve False, which would leave a holdout or an excluded user with the feature enabled. How a flag is evaluated has the details.
Roll a feature out to a customer while keeping it off for a few of their users, such as ones who opted out.
- Click
Add ruleand chooseTarget users, select the excluded users, and set the rule to serveFalse. - Click
Add ruleand chooseTarget organizations, select the organization, and leave the rule servingTrue. - Order the rules so the user rule is checked first.
- Set
Everyone elsetoFalse.
The order is what makes the exclusion work. An excluded user matches both rules, since they belong to the organization too. With the user rule first, the first match serves False and the organization rule is never reached for them. In the reverse order, the organization rule matches first and the exclusion never applies.

Restrict functionality to a pricing tier without listing every organization by hand.
- Click
Add ruleand chooseAdd a custom targeting rule. Create a rule type that names the resource, such asplan, and add the IDs of the tiers that include the feature, such asenterprise. - Leave the rule serving
True. - Set
Everyone elsetoFalse. - In your application, evaluate the flag with the runtime client, passing the organization’s plan in the evaluation context.

Custom targets are evaluated by the runtime client only. They never appear in the access token’s feature_flags claim, because AuthKit has no knowledge of your application’s resources. The custom targets guide covers choosing rule types and passing the evaluation context.
Something went wrong and the feature needs to disappear now.
- Turn the flag off with the switch in the editor.
- Save.
The flag evaluates to false for every user in the environment, regardless of its rules. The targeting stays intact, so turning the flag back on restores exactly the rollout state you had before.
Saving changes what every new evaluation returns, but it is not confirmation that every user has lost the feature. A user who already holds an access token keeps its feature_flags claim until they sign in again or their session refreshes – refresh sessions to cut existing sessions over sooner – and the runtime client applies the change on its next poll.
