Skip to main content

Create a strategy

POST <your-unleash-url>/api/admin/strategies

Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API
deprecated

This endpoint has been deprecated and may be removed in future versions of the API.

Creates a custom strategy type based on the supplied data. Custom strategies are deprecated and should not be used. Prefer using built in strategies with constraints instead.

Request

Body

required

createStrategySchema

  • name string required

    The name of the strategy type. Must be unique.

  • title string

    The title of the strategy

  • description string

    A description of the strategy type.

  • editable boolean

    Whether the strategy type is editable or not. Defaults to true.

  • deprecated boolean

    Whether the strategy type is deprecated or not. Defaults to false.

  • parameters object[]required

    The parameter list lets you pass arguments to your custom activation strategy. These will be made available to your custom strategy implementation.

  • Array [
  • name string required

    The name of the parameter

  • type string required

    Possible values: [string, percentage, list, number, boolean]

  • description string

    A description of this strategy parameter. Use this to indicate to the users what the parameter does.

  • required boolean

    Whether this parameter must be configured when using the strategy. Defaults to false

  • ]
Responses

The resource was successfully created.

Response Headers
  • location string

    The location of the newly created resource.

Schema
  • title string nullable

    An optional title for the strategy

  • name string required

    The name (type) of the strategy

  • displayName string nullable required

    A human friendly name for the strategy

  • description string nullable required

    A short description of the strategy

  • editable boolean required

    Whether the strategy can be edited or not. Strategies bundled with Unleash cannot be edited.

  • deprecated boolean required
  • parameters object[]required

    A list of relevant parameters for each strategy

  • Array [
  • name string
  • type string
  • description string
  • required boolean
  • ]

Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API

Request

Base URL
<your-unleash-url>
Security Scheme
apiKey
Body required
{
"name": "my-custom-strategy",
"title": "My awesome strategy",
"description": "Enable the feature for users who have not logged in before.",
"editable": false,
"deprecated": true,
"parameters": [
{
"name": "Rollout percentage",
"type": "percentage",
"description": "How many percent of users should see this feature?",
"required": false
}
]
}
curl / cURL
curl -L -X POST '<your-unleash-url>/api/admin/strategies' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: <API_KEY_VALUE>' \
--data-raw '{
"name": "my-custom-strategy",
"title": "My awesome strategy",
"description": "Enable the feature for users who have not logged in before.",
"editable": false,
"deprecated": true,
"parameters": [
{
"name": "Rollout percentage",
"type": "percentage",
"description": "How many percent of users should see this feature?",
"required": false
}
]
}'