# Create feature flag

Create a new feature flag with configurable on/off states, default treatments, targeting rules, and custom metadata for controlled feature rollouts.

Endpoint: POST /resources/feature-flags/v1
Version: 1.0
Security: bearer

## Security:

  - `bearer` (unknown)
    http bearer JWT

## Request fields (application/json):

  - `name` (string, required)
    String that represent the feature flag name
    Example: Test Feature Flag

  - `on` (boolean, required)
    Boolean indicating whether the feature flag is on
    Example: true

  - `offTreatment` (string, required)
    Enum that represents the treatment in case feature flag is off
    Enum: "true", "false"

  - `defaultTreatment` (string, required)
    Enum that represents the default treatment
    Enum: "true", "false"

  - `featureId` (string, required)
    UUID string that represents the related feature ID
    Example: 26f1b6b8-0317-452c-becd-68a5f782417d 

  - `description` (string)
    String the represents the feature flag description
    Example: This is a test feature flag

  - `metadata` (string)
    JSON String that represents additional custom metadata to the feature flag entity
    Example: {}

  - `rules` (array)
    Array of rules that represents the set of conditions targeting the feature

  - `rules.description` (string, required)
    String that represents the description of the rule
    Example: This is the first rule

  - `rules.conditionLogic` (string, required)
    Enum that represents the rule conditions logic
    Enum: "and"

  - `rules.conditions` (array, required)
    Array of conditions

  - `rules.conditions.attribute` (string, required)
    String representing an attribute with a subset of condition(s) that is used in code to enact targeting rules
    Example: myCustomAttribute

  - `rules.conditions.attributeType` (string, required)
    Enum that represents the attribute type (`frontegg` or `custom`)
    Enum: "custom", "frontegg"

  - `rules.conditions.negate` (boolean, required)
    Boolean that indicates whether the condition should negate the operation
    Example: false

  - `rules.conditions.op` (string, required)
    Enum that represents the operation applied to the condition
    Enum: "in_list", "starts_with", "ends_with", "contains", "matches", "equal", "greater_than", "greater_than_equal", "lower_than", "lower_than_equal", "between_numeric", "is", "on", "between_date", "on_or_after", "on_or_before"

  - `rules.conditions.value` (object, required)
    Object that contains the condition data according to selected operation, each operation requires different structure (see [documentation](https://docs.frontegg.com/docs/entitlements-backend-sdk#operations-and-corresponding-object-structure))
    Example: {"list":["valueA","valueB"]}

  - `rules.treatment` (string, required)
    String that represents the treatment for this rule
    Enum: "true", "false"

## Response 200 fields (application/json):

  - `id` (string)
    UUID string that represents the feature flag ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `name` (string)
    String that represent the feature flag name
    Example: Test Feature Flag

  - `on` (boolean)
    Boolean indicating whether the feature flag is on
    Example: true

  - `offTreatment` (string)
    Enum that represents the treatment in case feature flag is off
    Enum: "true", "false"

  - `defaultTreatment` (string)
    Enum that represents the default treatment
    Enum: "true", "false"

  - `feature` (object)
    Object that represents the related feature

  - `feature.id` (string)
    UUID string representing the feature ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `feature.key` (string)
    String representing the feature key
    Example: test-feature

  - `feature.name` (string)
    String representing the feature name
    Example: Test Feature

  - `description` (string)
    String the represents the feature flag description
    Example: This is a test feature flag

  - `metadata` (string)
    JSON String that represents additional custom metadata to the feature flag entity
    Example: {}

  - `rules` (array)
    Array of rules that represents the set of conditions targeting the feature

  - `rules.description` (string, required)
    String that represents the description of the rule
    Example: This is the first rule

  - `rules.conditionLogic` (string, required)
    Enum that represents the rule conditions logic
    Enum: "and"

  - `rules.conditions` (array, required)
    Array of conditions

  - `rules.conditions.attribute` (string, required)
    String representing an attribute with a subset of condition(s) that is used in code to enact targeting rules
    Example: myCustomAttribute

  - `rules.conditions.attributeType` (string, required)
    Enum that represents the attribute type (`frontegg` or `custom`)
    Enum: "custom", "frontegg"

  - `rules.conditions.negate` (boolean, required)
    Boolean that indicates whether the condition should negate the operation
    Example: false

  - `rules.conditions.op` (string, required)
    Enum that represents the operation applied to the condition
    Enum: "in_list", "starts_with", "ends_with", "contains", "matches", "equal", "greater_than", "greater_than_equal", "lower_than", "lower_than_equal", "between_numeric", "is", "on", "between_date", "on_or_after", "on_or_before"

  - `rules.conditions.value` (object, required)
    Object that contains the condition data according to selected operation, each operation requires different structure (see [documentation](https://docs.frontegg.com/docs/entitlements-backend-sdk#operations-and-corresponding-object-structure))
    Example: {"list":["valueA","valueB"]}

  - `rules.treatment` (string, required)
    String that represents the treatment for this rule
    Enum: "true", "false"

  - `updatedAt` (string)
    Date when feature flag was created
    Example: 2022-01-01T00:00:00

  - `createdAt` (string)
    Date when feature flag was last updated
    Example: 2022-01-01T00:00:00

