Targeting allows you to enable Feature Flags for specific users or organizations. When a flag is enabled for a target, that target will receive the flag’s enabled value instead of the default value.
Get 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