Features

Add a strategy to a feature flag

Changed on

Add a strategy to a feature flag in the specified environment.

post/api/admin/projects/{projectId}/features/{featureName}/environments/{environment}/strategies

Request

  • Base URL
    https://app.unleash-instance.example.com
  • URL
    https://app.unleash-instance.example.com/api/admin/projects/{projectId}/features/{featureName}/environments/{environment}/strategies
  • Auth
    • API key in header Authorization
    • or HTTP bearer

Path parameters

projectIdstring required
featureNamestring required
environmentstring required

Request body

namestring required

The name of the strategy type

titlestring nullable

A descriptive title for the strategy

disabledboolean nullable

A toggle to disable the strategy. defaults to false. Disabled strategies are not evaluated or returned to the SDKs

sortOrdernumber

The order of the strategy in the list

parametersParametersSchema

A list of parameters for a strategy

segmentsnumber[]

Ids of segments to use for this strategy

Example request

{
  "name": "flexibleRollout",
  "title": "Gradual Rollout 25-Prod",
  "sortOrder": 9999,
  "constraints": [
    {
      "values": [
        "1",
        "2"
      ],
      "inverted": false,
      "operator": "IN",
      "contextName": "appName",
      "caseInsensitive": false
    }
  ],
  "variants": [
    {
      "name": "blue_group",
      "weightType": "fix",
      "stickiness": "custom.context.field",
      "payload": {
        "type": "json",
        "value": "{\"color\": \"red\"}"
      }
    }
  ],
  "segments": [
    1,
    2
  ]
}

Response

featureStrategySchema

idstring

A uuid for the feature strategy

namestring required

The name or type of strategy

titlestring nullable

A descriptive title for the strategy

disabledboolean nullable

A toggle to disable the strategy. defaults to false. Disabled strategies are not evaluated or returned to the SDKs

featureNamestring

The name or feature the strategy is attached to

sortOrdernumber

The order of the strategy in the list

segmentsnumber[]

A list of segment ids attached to the strategy

parametersParametersSchema

A list of parameters for a strategy

Example response

{
  "id": "6b5157cb-343a-41e7-bfa3-7b4ec3044840",
  "name": "flexibleRollout",
  "title": "Gradual Rollout 25-Prod",
  "featureName": "myAwesomeFeature",
  "sortOrder": 9999,
  "segments": [
    1,
    2
  ],
  "constraints": [
    {
      "contextName": "appName",
      "operator": "IN",
      "values": [
        "my-app",
        "my-other-app"
      ],
      "value": "my-app"
    }
  ],
  "variants": [
    {
      "name": "blue_group",
      "weightType": "fix",
      "stickiness": "custom.context.field",
      "payload": {
        "type": "json",
        "value": "{\"color\": \"red\"}"
      }
    }
  ]
}

Changes

    • breaking

      the // request property's minLength was increased from 0 to 1

    • warning

      added the new SEMVER_GTE enum value to the // response property for the response status

    • warning

      added the new SEMVER_LTE enum value to the // response property for the response status

    • info

      added the new SEMVER_GTE enum value to the request property //

    • info

      added the new SEMVER_LTE enum value to the request property //

    • warning

      added the new REGEX enum value to the // response property for the response status

    • info

      added the new REGEX enum value to the request property //