Feature flags allow you to control feature availability for organizations in your application. Flags can either be enabled for individual organizations or all organizations in an environment. Read more about how feature flags integrate with AuthKit here.
const featureFlag = { object: 'feature_flag', id: 'flag_01EHZNVPK3SFK441A1RGBFSHRT', name: 'Advanced Analytics', slug: 'advanced-analytics', description: 'Enable advanced analytics dashboard feature', createdAt: '2025-08-04T19:07:33.155Z', updatedAt: '2025-08-04T19:07:33.155Z', };
interface FeatureFlagGet the details of an existing feature flag.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlag = await workos.featureFlags.getFeatureFlag('advanced-analytics'); console.log(featureFlag);
Get a list of all of your existing feature flags matching the criteria specified.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlags = await workos.featureFlags.listFeatureFlags(); console.log(featureFlags.data);
featureFlags .listFeatureFlags()Parameters objectReturns objectGet a list of all enabled feature flags for the provided organization.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlags = await workos.organizations.listOrganizationFeatureFlags({ organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', }); console.log(featureFlags.data);
organizations .listOrganizationFeatureFlags()Parameters objectReturns objectGet a list of all enabled feature flags for the provided user. This includes feature flags enabled specifically for the user as well as any organizations that the user is a member of.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlags = await workos.userManagement.listUserFeatureFlags({ userId: 'user_01EHZNVPK3SFK441A1RGBFSHRT', }); console.log(featureFlags.data);
userManagement .listUserFeatureFlags()Parameters objectReturns objectEnables a feature flag for a specific target in the current environment. Currently, supported targets include users and organizations.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); await workos.featureFlags.addFlagTarget({ slug: 'test-flag', targetId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', });
featureFlags .addFlagTarget()Parameters Removes a target from the feature flag’s target list in the current environment. Currently, supported targets include users and organizations.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); await workos.featureFlags.removeFlagTarget({ slug: 'test-flag', targetId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', });
featureFlags .removeFlagTarget()Parameters Enables a feature flag in the current environment.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlag = await workos.featureFlags.enableFeatureFlag('advanced-analytics'); console.log(featureFlag);
Disables a feature flag in the current environment.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const featureFlag = await workos.featureFlags.disableFeatureFlag('advanced-analytics'); console.log(featureFlag);