provider Feature flags POST /api/v2/flags/{projectKey}
@utdk/launchdarkly /api/v2/flags/{projectKey}
Create a feature flag
Create a feature flag with the given name, key, and variations. <details> <summary>Click to expand instructions for <strong>creating a migration flag</strong></summary> ### Creating a migration flag When you create a migration flag, the variations are pre-determined based on the number of stages in the migration. To create a migration flag, omit the `variations` and `defaults` information. Instead, provide a `purpose` of `migration`, and `migrationSettings`. If you create a migration flag with six stages, `contextKind` is required. Otherwise, it should be omitted. Here's an example: ```json { "key": "flag-key-123", "purpose": "migration", "migrationSettings": { "stageCount": 6, "contextKind": "account" } } ``` To learn more, read [Migration Flags](https://launchdarkly.com/docs/home/flags/migration). </details>
projectKey path required
The project key
string
clone query
The key of the feature flag to be cloned. The key identifies the flag in your code. For example, setting `clone=flagKey` copies the full targeting configuration for all environments, including `on/off` state, from the original flag to the new flag.
string

Try it

Authentication
Configure credentials for LaunchDarkly REST API
Gateway
The gateway proxies requests and injects credentials server-side. Configure credentials above, then enter your gateway URL.

Saved automatically to browser storage.

postfeatureflag
POST/api/v2/flags/{projectKey}
Create a feature flag with the given name, key, and variations. <details> <summary>Click to expand instructions for <strong>creating a migration flag</strong></summary> ### Creating a migration flag When you create a migration flag, the variations are pre-determined based on the number of stages in the migration. To create a migration flag, omit the `variations` and `defaults` information. Instead, provide a `purpose` of `migration`, and `migrationSettings`. If you create a migration flag with six stages, `contextKind` is required. Otherwise, it should be omitted. Here's an example: ```json { "key": "flag-key-123", "purpose": "migration", "migrationSettings": { "stageCount": 6, "contextKind": "account" } } ``` To learn more, read [Migration Flags](https://launchdarkly.com/docs/home/flags/migration). </details>

Parameters

required

The project key

The key of the feature flag to be cloned. The key identifies the flag in your code. For example, setting `clone=flagKey` copies the full targeting configuration for all environments, including `on/off` state, from the original flag to the new flag.

Input

required

A human-friendly name for the feature flag

required

A unique key used to reference the flag in your code

Description of the feature flag. Defaults to an empty string.

Deprecated, use <code>clientSideAvailability</code>. Whether this flag should be made available to the client-side JavaScript SDK. Defaults to <code>false</code>.

An array of possible variations for the flag. The variation values must be unique. If omitted, two boolean variations of <code>true</code> and <code>false</code> will be used.

Whether the flag is a temporary flag. Defaults to <code>true</code>.

Tags for the feature flag. Defaults to an empty array.

Purpose of the flag

The ID of the member who maintains this feature flag

The key of the team that maintains this feature flag

Initial set of prerequisite flags for all environments

Whether to automatically turn the flag on across all environments at creation. Defaults to <code>false</code>.

Enter a gateway URL above to enable sending.

Code snippet
Updates live as you fill in the form above.

TypeScript

import launchdarkly from '@utdk/launchdarkly';

await launchdarkly.postfeatureflag()