<!-- llms.txt: https://workos.com/llms.txt -->

# Feature Flag

A Feature Flag controls feature availability for organizations and users in your application.

## Disable a feature flag

Disables a feature flag in the current environment.

:::code-group

```bash language="curl" title="Request" tab="1"
curl --request PUT \
  --url "https://api.workos.com/feature-flags/advanced-analytics/disable" \
  --header "Authorization: Bearer sk_example_123456789"
```

```js language="js" title="Request" tab="1"
import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

const featureFlag =
  await workos.featureFlags.disableFeatureFlag('advanced-analytics');

console.log(featureFlag);
```

```rb language="ruby" title="Request" tab="1"
require "workos"

WorkOS.configure do |config|
  config.api_key = "sk_example_123456789"
end

WorkOS.client.feature_flags.disable_feature_flag(slug: "advanced-analytics")
```

```py language="python" title="Request" tab="1"
from workos import WorkOSClient

client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789")

client.feature_flags.disable_feature_flag(slug="advanced-analytics")
```

```go language="go" title="Request" tab="1"
package main

import (
	"context"

	"github.com/workos/workos-go/v10"
)

func main() {
	client := workos.NewClient("sk_example_123456789")

	_, err := client.FeatureFlags().Disable(context.Background(), "advanced-analytics")
	if err != nil {
		panic(err)
	}
}
```

```php language="php" title="Request" tab="1"
<?php

use WorkOS\WorkOS;

$workos = new WorkOS(
    apiKey: "sk_example_123456789",
    clientId: "client_123456789",
);

$workos->featureFlags()->disableFeatureFlag(slug: "advanced-analytics");
```

```java language="java" title="Request" tab="1"
import com.workos.WorkOS;

WorkOS workos = new WorkOS("sk_example_123456789");

workos.featureFlags.disableFeatureFlag("advanced-analytics");
```

```cs language="dotnet" title="Request" tab="1"
using WorkOS;

var client = new WorkOSClient(new WorkOSOptions {
    ApiKey = "sk_example_123456789",
    ClientId = "client_123456789",
});

await client.FeatureFlags.DisableAsync("advanced-analytics");
```

```rust language="rust" title="Request" tab="1"
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()
        .disable_feature_flag("advanced-analytics")
        .await?;

    Ok(())
}
```

```json language="json" title="Response" tab="2"
{
  "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": false,
  "default_value": false,
  "created_at": "2026-01-15T12:00:00.000Z",
  "updated_at": "2026-01-15T12:00:00.000Z"
}
```

:::

## Enable a feature flag

Enables a feature flag in the current environment.

:::code-group

```bash language="curl" title="Request" tab="1"
curl --request PUT \
  --url "https://api.workos.com/feature-flags/advanced-analytics/enable" \
  --header "Authorization: Bearer sk_example_123456789"
```

```js language="js" title="Request" tab="1"
import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

const featureFlag =
  await workos.featureFlags.enableFeatureFlag('advanced-analytics');

console.log(featureFlag);
```

```rb language="ruby" title="Request" tab="1"
require "workos"

WorkOS.configure do |config|
  config.api_key = "sk_example_123456789"
end

WorkOS.client.feature_flags.enable_feature_flag(slug: "advanced-analytics")
```

```py language="python" title="Request" tab="1"
from workos import WorkOSClient

client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789")

client.feature_flags.enable_feature_flag(slug="advanced-analytics")
```

```go language="go" title="Request" tab="1"
package main

import (
	"context"

	"github.com/workos/workos-go/v10"
)

func main() {
	client := workos.NewClient("sk_example_123456789")

	_, err := client.FeatureFlags().Enable(context.Background(), "advanced-analytics")
	if err != nil {
		panic(err)
	}
}
```

```php language="php" title="Request" tab="1"
<?php

use WorkOS\WorkOS;

$workos = new WorkOS(
    apiKey: "sk_example_123456789",
    clientId: "client_123456789",
);

$workos->featureFlags()->enableFeatureFlag(slug: "advanced-analytics");
```

```java language="java" title="Request" tab="1"
import com.workos.WorkOS;

WorkOS workos = new WorkOS("sk_example_123456789");

workos.featureFlags.enableFeatureFlag("advanced-analytics");
```

```cs language="dotnet" title="Request" tab="1"
using WorkOS;

var client = new WorkOSClient(new WorkOSOptions {
    ApiKey = "sk_example_123456789",
    ClientId = "client_123456789",
});

await client.FeatureFlags.EnableAsync("advanced-analytics");
```

```rust language="rust" title="Request" tab="1"
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()
        .enable_feature_flag("advanced-analytics")
        .await?;

    Ok(())
}
```

```json language="json" title="Response" tab="2"
{
  "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"
}
```

:::

## Get a feature flag

Get the details of an existing feature flag by its slug.

:::code-group

```bash language="curl" title="Request" tab="1"
curl "https://api.workos.com/feature-flags/advanced-analytics" \
  --header "Authorization: Bearer sk_example_123456789"
```

```js language="js" title="Request" tab="1"
import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

const featureFlag =
  await workos.featureFlags.getFeatureFlag('advanced-analytics');

console.log(featureFlag);
```

```rb language="ruby" title="Request" tab="1"
require "workos"

WorkOS.configure do |config|
  config.api_key = "sk_example_123456789"
end

WorkOS.client.feature_flags.get_feature_flag(slug: "advanced-analytics")
```

```py language="python" title="Request" tab="1"
from workos import WorkOSClient

client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789")

client.feature_flags.get_feature_flag(slug="advanced-analytics")
```

```go language="go" title="Request" tab="1"
package main

import (
	"context"

	"github.com/workos/workos-go/v10"
)

func main() {
	client := workos.NewClient("sk_example_123456789")

	_, err := client.FeatureFlags().Get(context.Background(), "advanced-analytics")
	if err != nil {
		panic(err)
	}
}
```

```php language="php" title="Request" tab="1"
<?php

use WorkOS\WorkOS;

$workos = new WorkOS(
    apiKey: "sk_example_123456789",
    clientId: "client_123456789",
);

$workos->featureFlags()->getFeatureFlag(slug: "advanced-analytics");
```

```java language="java" title="Request" tab="1"
import com.workos.WorkOS;

WorkOS workos = new WorkOS("sk_example_123456789");

workos.featureFlags.getFeatureFlag("advanced-analytics");
```

```cs language="dotnet" title="Request" tab="1"
using WorkOS;

var client = new WorkOSClient(new WorkOSOptions {
    ApiKey = "sk_example_123456789",
    ClientId = "client_123456789",
});

await client.FeatureFlags.GetAsync("advanced-analytics");
```

```rust language="rust" title="Request" tab="1"
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()
        .get_feature_flag("advanced-analytics")
        .await?;

    Ok(())
}
```

```json language="json" title="Response" tab="2"
{
  "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 feature flags

Get a list of all of your existing feature flags matching the criteria specified.

:::code-group

```bash language="curl" title="Request" tab="1"
curl "https://api.workos.com/feature-flags" \
  --header "Authorization: Bearer sk_example_123456789"
```

```js language="js" title="Request" tab="1"
import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

const featureFlags = await workos.featureFlags.listFeatureFlags();

console.log(featureFlags.data);
```

```rb language="ruby" title="Request" tab="1"
require "workos"

WorkOS.configure do |config|
  config.api_key = "sk_example_123456789"
end

WorkOS.client.feature_flags.list_feature_flags
```

```py language="python" title="Request" tab="1"
from workos import WorkOSClient

client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789")

client.feature_flags.list_feature_flags()
```

```go language="go" title="Request" tab="1"
package main

import (
	"context"

	"github.com/workos/workos-go/v10"
)

func main() {
	client := workos.NewClient("sk_example_123456789")

	_, err := client.FeatureFlags().List(context.Background())
	if err != nil {
		panic(err)
	}
}
```

```php language="php" title="Request" tab="1"
<?php

use WorkOS\WorkOS;

$workos = new WorkOS(
    apiKey: "sk_example_123456789",
    clientId: "client_123456789",
);

$workos->featureFlags()->listFeatureFlags();
```

```java language="java" title="Request" tab="1"
import com.workos.WorkOS;

WorkOS workos = new WorkOS("sk_example_123456789");

workos.featureFlags.listFeatureFlags();
```

```cs language="dotnet" title="Request" tab="1"
using WorkOS;

var client = new WorkOSClient(new WorkOSOptions {
    ApiKey = "sk_example_123456789",
    ClientId = "client_123456789",
});

await client.FeatureFlags.ListAsync();
```

```rust language="rust" title="Request" tab="1"
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_feature_flags()
        .await?;

    Ok(())
}
```

```json language="json" title="Response" tab="2"
{
  "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"
  }
}
```

:::

### feature_flag

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | "feature_flag" | Yes | Distinguishes the Feature Flag object |
| `id` | string | Yes | Unique identifier of the Feature Flag. |
| `name` | string | Yes | A descriptive name for the Feature Flag. This field does not need to be unique. |
| `slug` | string | Yes | A unique key to reference the Feature Flag. |
| `description` | string \| null | Yes | A description for the Feature Flag. |
| `tags` | array | Yes | Labels assigned to the Feature Flag for categorizing and filtering. |
| `enabled` | boolean | Yes | Specifies whether the Feature Flag is active for the current environment. |
| `default_value` | boolean | Yes | The value returned for users and organizations who don't match any configured targeting rules. |
| `created_at` | string | Yes | The timestamp when the Feature Flag was last created. |
| `updated_at` | string | Yes | The timestamp when the Feature Flag was last updated. |

### PUT /feature-flags/{slug}/disable

#### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | Yes | A unique key to reference the Feature Flag. |

#### Returns

| Field | Type | Description |
| --- | --- | --- |
| `feature_flag` | object | Distinguishes the Feature Flag object. |

### PUT /feature-flags/{slug}/enable

#### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | Yes | A unique key to reference the Feature Flag. |

#### Returns

| Field | Type | Description |
| --- | --- | --- |
| `feature_flag` | object | Distinguishes the Feature Flag object. |

### GET /feature-flags/{slug}

#### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | Yes | A unique key to reference the Feature Flag. |

#### Returns

| Field | Type | Description |
| --- | --- | --- |
| `feature_flag` | object | Distinguishes the Feature Flag object. |

### GET /feature-flags

#### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `before` | string | No | An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. |
| `after` | string | No | An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. |
| `limit` | integer | No | Upper limit on the number of objects to return, between `1` and `100`. Defaults to `10`. |
| `order` | "normal" \| "desc" \| "asc" | No | Order the results by the creation time. Defaults to `normal`. |