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 an 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);
{ "object": "list", "data": [ { "object": "feature_flag", "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT", "slug": "advanced-analytics", "name": "Advanced Analytics", "description": "Enable advanced analytics dashboard feature", "owner": { "email": "jane@example.com", "first_name": "Jane", "last_name": "Doe" }, "tags": [ "reports" ], "enabled": true, "default_value": false, "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } ], "list_metadata": { "before": "flag_01HXYZ123456789ABCDEFGHIJ", "after": "flag_01HXYZ987654321KJIHGFEDCBA" } }
| curl "https://api.workos.com/organizations/org_01EHZNVPK3SFK441A1RGBFSHRT/feature-flags" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| 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); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.feature_flags.list_organization_feature_flags(organization_id: "org_01EHZNVPK3SFK441A1RGBFSHRT") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.feature_flags.list_organization_feature_flags( | |
| organization_id="org_01EHZNVPK3SFK441A1RGBFSHRT" | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.FeatureFlags().ListOrganizationFeatureFlags(context.Background(), "org_01EHZNVPK3SFK441A1RGBFSHRT") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->featureFlags() | |
| ->listOrganizationFeatureFlags( | |
| organizationId: "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| ); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.featureFlags.listOrganizationFeatureFlags("org_01EHZNVPK3SFK441A1RGBFSHRT"); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.FeatureFlags.ListOrganizationFeatureFlagsAsync("org_01EHZNVPK3SFK441A1RGBFSHRT"); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .feature_flags() | |
| .list_organization_feature_flags("org_01EHZNVPK3SFK441A1RGBFSHRT") | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "object": "feature_flag", | |
| "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT", | |
| "slug": "advanced-analytics", | |
| "name": "Advanced Analytics", | |
| "description": "Enable advanced analytics dashboard feature", | |
| "owner": { | |
| "email": "jane@example.com", | |
| "first_name": "Jane", | |
| "last_name": "Doe" | |
| }, | |
| "tags": [ | |
| "reports" | |
| ], | |
| "enabled": true, | |
| "default_value": false, | |
| "created_at": "2026-01-15T12:00:00.000Z", | |
| "updated_at": "2026-01-15T12:00:00.000Z" | |
| } | |
| ], | |
| "list_metadata": { | |
| "before": "flag_01HXYZ123456789ABCDEFGHIJ", | |
| "after": "flag_01HXYZ987654321KJIHGFEDCBA" | |
| } | |
| } |
GET/organizations /:organizationId /feature-flagsParameters Returns 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);
{ "object": "list", "data": [ { "object": "feature_flag", "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT", "slug": "advanced-analytics", "name": "Advanced Analytics", "description": "Enable advanced analytics dashboard feature", "owner": { "email": "jane@example.com", "first_name": "Jane", "last_name": "Doe" }, "tags": [ "reports" ], "enabled": true, "default_value": false, "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } ], "list_metadata": { "before": "flag_01HXYZ123456789ABCDEFGHIJ", "after": "flag_01HXYZ987654321KJIHGFEDCBA" } }
| curl "https://api.workos.com/user_management/users/user_01E4ZCR3C56J083X43JQXF3JK5/feature-flags" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| 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); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.feature_flags.list_user_feature_flags(user_id: "user_01E4ZCR3C56J083X43JQXF3JK5") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.feature_flags.list_user_feature_flags(user_id="user_01E4ZCR3C56J083X43JQXF3JK5") |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.FeatureFlags().ListUserFeatureFlags(context.Background(), "user_01E4ZCR3C56J083X43JQXF3JK5") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->featureFlags() | |
| ->listUserFeatureFlags(userId: "user_01E4ZCR3C56J083X43JQXF3JK5"); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.featureFlags.listUserFeatureFlags("user_01E4ZCR3C56J083X43JQXF3JK5"); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.FeatureFlags.ListUserFeatureFlagsAsync("user_01E4ZCR3C56J083X43JQXF3JK5"); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .feature_flags() | |
| .list_user_feature_flags("user_01E4ZCR3C56J083X43JQXF3JK5") | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "object": "feature_flag", | |
| "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT", | |
| "slug": "advanced-analytics", | |
| "name": "Advanced Analytics", | |
| "description": "Enable advanced analytics dashboard feature", | |
| "owner": { | |
| "email": "jane@example.com", | |
| "first_name": "Jane", | |
| "last_name": "Doe" | |
| }, | |
| "tags": [ | |
| "reports" | |
| ], | |
| "enabled": true, | |
| "default_value": false, | |
| "created_at": "2026-01-15T12:00:00.000Z", | |
| "updated_at": "2026-01-15T12:00:00.000Z" | |
| } | |
| ], | |
| "list_metadata": { | |
| "before": "flag_01HXYZ123456789ABCDEFGHIJ", | |
| "after": "flag_01HXYZ987654321KJIHGFEDCBA" | |
| } | |
| } |
GET/user_management /users /:userId /feature-flagsParameters Returns objectEnables a feature flag for a specific target in the current environment. Currently, supported targets include users and organizations.
curl --request POST \ --url https://api.workos.com/feature-flags/test-flag/targets/org_01EHZNVPK3SFK441A1RGBFSHRT \ --header "Authorization: Bearer sk_example_123456789"
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); await workos.featureFlags.addFlagTarget({ slug: 'test-flag', targetId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', });
require "workos" WorkOS.configure do |config| config.api_key = "sk_example_123456789" end WorkOS.client.feature_flags.add_flag_target( resource_id: "user_01234567890abcdef", slug: "beta-feature" )
from workos import WorkOSClient client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") client.feature_flags.add_flag_target( resource_id="user_01234567890abcdef", slug="beta-feature" )
package main import ( "context" "github.com/workos/workos-go/v9" ) func main() { client := workos.NewClient("sk_example_123456789") _, err := client.FeatureFlags().AddFlagTarget(context.Background(), "user_01234567890abcdef", "beta-feature") if err != nil { panic(err) } }
<?php use WorkOS\WorkOS; $workos = new WorkOS( apiKey: "sk_example_123456789", clientId: "client_123456789", ); $workos ->featureFlags() ->addFlagTarget(resourceId: "user_01234567890abcdef", slug: "beta-feature");
import com.workos.WorkOS; WorkOS workos = new WorkOS("sk_example_123456789"); workos.featureFlags.addFlagTarget("user_01234567890abcdef", "beta-feature");
using WorkOS; var client = new WorkOSClient(new WorkOSOptions { ApiKey = "sk_example_123456789", ClientId = "client_123456789", }); await client.FeatureFlags.AddFlagTargetAsync("user_01234567890abcdef", "beta-feature");
use workos::Client; #[tokio::main] async fn main() -> Result<(), workos::Error> { let client = Client::builder() .api_key("sk_example_123456789") .client_id("client_123456789") .build(); let _result = client .feature_flags() .add_flag_target( "user_01234567890abcdef", "beta-feature" ) .await?; Ok(()) }
POST/feature-flags /:slug /targets /:resourceIdParameters Returns Removes a target from the feature flag’s target list in the current environment. Currently, supported targets include users and organizations.
curl --request DELETE \ --url https://api.workos.com/feature-flags/test-flag/targets/org_01EHZNVPK3SFK441A1RGBFSHRT \ --header "Authorization: Bearer sk_example_123456789"
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); await workos.featureFlags.removeFlagTarget({ slug: 'test-flag', targetId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', });
require "workos" WorkOS.configure do |config| config.api_key = "sk_example_123456789" end WorkOS.client.feature_flags.remove_flag_target( resource_id: "user_01234567890abcdef", slug: "beta-feature" )
from workos import WorkOSClient client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") client.feature_flags.remove_flag_target( resource_id="user_01234567890abcdef", slug="beta-feature" )
package main import ( "context" "github.com/workos/workos-go/v9" ) func main() { client := workos.NewClient("sk_example_123456789") _, err := client.FeatureFlags().RemoveFlagTarget(context.Background(), "user_01234567890abcdef", "beta-feature") if err != nil { panic(err) } }
<?php use WorkOS\WorkOS; $workos = new WorkOS( apiKey: "sk_example_123456789", clientId: "client_123456789", ); $workos ->featureFlags() ->removeFlagTarget( resourceId: "user_01234567890abcdef", slug: "beta-feature", );
import com.workos.WorkOS; WorkOS workos = new WorkOS("sk_example_123456789"); workos.featureFlags.removeFlagTarget("user_01234567890abcdef", "beta-feature");
using WorkOS; var client = new WorkOSClient(new WorkOSOptions { ApiKey = "sk_example_123456789", ClientId = "client_123456789", }); await client.FeatureFlags.RemoveFlagTargetAsync("user_01234567890abcdef", "beta-feature");
use workos::Client; #[tokio::main] async fn main() -> Result<(), workos::Error> { let client = Client::builder() .api_key("sk_example_123456789") .client_id("client_123456789") .build(); let _result = client .feature_flags() .remove_flag_target( "user_01234567890abcdef", "beta-feature" ) .await?; Ok(()) }
DELETE/feature-flags /:slug /targets /:resourceIdParameters Returns