1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00
unleash.unleash/website/docs/reference/api/legacy/unleash/admin/strategies.md
2025-11-19 16:09:53 +01:00

3.4 KiB

title
/api/admin/strategies

import SearchPriority from '@site/src/components/SearchPriority';

Fetch Strategies

GET: http://unleash.host.com/api/admin/strategies

Used to fetch all defined strategies and their defined parameters.

Response

{
  "version": 1,
  "strategies": [
    {
      "name": "default",
      "description": "Default on/off strategy.",
      "parameters": []
    },
    {
      "name": "gradualRollout",
      "description": "Gradual rollout to logged in users",
      "parameters": [
        {
          "name": "percentage",
          "type": "percentage",
          "description": "How many percent should the new feature be active for.",
          "required": false
        },
        {
          "name": "group",
          "type": "string",
          "description": "Group key to use when hasing the userId. Makes sure that the same user get different value for different groups",
          "required": false
        }
      ]
    }
  ]
}

Create strategy

POST: http://unleash.host.com/api/admin/strategies

Body

{
    "name": "gradualRollout",
    "description": "Gradual rollout to logged in users",
    "parameters": [
        {
            "name": "percentage",
            "type": "percentage",
            "description": "How many percent should the new feature be active for.",
            "required": false
        },
        {
            "name": "group",
            "type": "string",
            "description": "Group key to use when hasing the userId. Makes sure that the same user get different value for different groups",
            "required": false
        }
    ]
},

Used to create a new Strategy. Name is required and must be unique. It is also required to have a parameters array, but it can be empty.

Update strategy

PUT: http://unleash.host.com/api/admin/strategies/:name

Body

{
    "name": "gradualRollout",
    "description": "Gradual rollout to logged in users with updated desc",
    "parameters": [
        {
            "name": "percentage",
            "type": "percentage",
            "description": "How many percent should the new feature be active for.",
            "required": false
        },
        {
            "name": "group",
            "type": "string",
            "description": "Group key to use when hasing the userId. Makes sure that the same user get different value for different groups",
            "required": false
        }
    ]
},

Used to update a Strategy definition. Name can't be changed. PS! I can be dangerous to change an implemented strategy as the implementation also might need to be changed

Deprecate strategy

POST: https://unleash.host.com/api/admin/strategies/:name/deprecate

Used to deprecate a strategy definition. This will set the deprecated flag to true. If the strategy is already deprecated, this will be a noop.

Errors

404 NOT FOUND - if :name does not exist

Reactivate strategy

POST: https://unleash.host.com/api/admin/strategies/:name/reactivate

Used to reactivate a deprecated strategy definition. This will set the deprecated flag back to false. If the strategy is not deprecated this is a noop and will still return 200.

Errors

404 NOT FOUND - if :name does not exist