1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/website/docs/reference/api/legacy/unleash/admin/features.md

400 lines
9.9 KiB
Markdown
Raw Normal View History

---
title: /api/admin/features
---
:::caution Deprecation notice
Most of this API was removed in Unleash v5 (after being deprecated since Unleash v4.3). You should use [the project-based API (/api/admin/projects/:projectId)](/reference/api/legacy/unleash/admin/features-v2.mdx) instead.
:::
:::info
refactor: move docs into new structure / fix links for SEO (#2416) ## What This (admittedly massive) PR updates the "physical" documentation structure and fixes url inconsistencies and SEO problems reported by marketing. The main points are: - remove or move directories : advanced, user_guide, deploy, api - move the files contained within to the appropriate one of topics, how-to, tutorials, or reference - update internal doc links and product links to the content - create client-side redirects for all the urls that have changed. A number of the files have been renamed in small ways to better match their url and to make them easier to find. Additionally, the top-level api directory has been moved to /reference/api/legacy/unleash (see the discussion points section for more on this). ## Why When moving our doc structure to diataxis a while back, we left the "physical' files lying where they were, because it didn't matter much to the new structure. However, that did introduce some inconsistencies with where you place docs and how we organize them. There's also the discrepancies in whether urls us underscores or hyphens (which isn't necessarily the same as their file name), which has been annoying me for a while, but now has also been raised by marketing as an issue in terms of SEO. ## Discussion points The old, hand-written API docs have been moved from /api to /reference/api/legacy/unleash. There _is_ a /reference/api/unleash directory, but this is being populated by the OpenAPI plugin, and mixing those could only cause trouble. However, I'm unsure about putting /legacy/ in the title, because the API isn't legacy, the docs are. Maybe we could use another path? Like /old-docs/ or something? I'd appreciate some input on this.
2022-11-22 10:05:30 +01:00
In order to access the admin API endpoints you need to identify yourself. Unless you're using the `none` authentication method, you'll need to [create an **admin** token](/how-to/how-to-create-api-tokens) and add an Authorization header using the token.
:::
## Fetching Feature Flags {#fetching-feature-toggles}
:::caution Deprecation notice
This endpoint was removed in Unleash v5. Please use the [project-based endpoint to fetch all flags](/reference/api/legacy/unleash/admin/features-v2.mdx#fetching-toggles) instead.
:::
2016-09-06 21:23:56 +02:00
2017-06-28 10:17:48 +02:00
`GET: http://unleash.host.com/api/admin/features`
2016-09-06 21:23:56 +02:00
This endpoint is the one all admin ui should use to fetch all available feature flags from the _unleash-server_. The response returns all active feature flags and their current strategy configuration. A feature flag will have _at least_ one configured strategy. A strategy will have a `name` and `parameters` map.
2016-09-06 21:23:56 +02:00
**Example response:**
2018-11-22 11:20:28 +01:00
2016-09-06 21:23:56 +02:00
```json
{
2017-06-28 10:17:48 +02:00
"version": 2,
2016-09-06 21:23:56 +02:00
"features": [
{
"name": "Feature.A",
"description": "lorem ipsum",
"type": "release",
2016-09-06 21:23:56 +02:00
"enabled": false,
"stale": false,
2016-09-06 21:23:56 +02:00
"strategies": [
{
"name": "default",
"parameters": {}
}
2018-01-30 15:57:12 +01:00
],
"variants": [
{
"name": "variant1",
2019-01-24 11:26:07 +01:00
"weight": 50
2018-01-30 15:57:12 +01:00
},
{
"name": "variant2",
2019-01-24 11:26:07 +01:00
"weight": 50
2018-01-30 15:57:12 +01:00
}
],
"tags": [
{
"id": 1,
"type": "simple",
"value": "TeamRed"
}
2017-06-28 10:17:48 +02:00
]
2016-09-06 21:23:56 +02:00
},
{
"name": "Feature.B",
"description": "lorem ipsum",
"enabled": true,
"stale": false,
2016-09-06 21:23:56 +02:00
"strategies": [
{
"name": "ActiveForUserWithId",
"parameters": {
"userIdList": "123,221,998"
}
},
{
"name": "GradualRolloutRandom",
"parameters": {
"percentage": "10"
}
}
2018-01-30 15:57:12 +01:00
],
"variants": [],
"tags": []
2016-09-06 21:23:56 +02:00
}
]
}
```
### Filter feature flags {#filter-feature-toggles}
Supports three params for now
- `tag` - filters for features tagged with tag
- `project` - filters for features belonging to project
- `namePrefix` - filters for features beginning with prefix
For `tag` and `project` performs OR filtering if multiple arguments
To filter for any feature tagged with a `simple` tag with value `taga` or a `simple` tag with value `tagb` use
`GET https://unleash.host.com/api/admin/features?tag[]=simple:taga&tag[]simple:tagb`
To filter for any feature belonging to project `myproject` use
`GET https://unleash.host.com/api/admin/features?project=myproject`
Response format is the same as `api/admin/features`
## Fetch specific feature flag {#fetch-specific-feature-toggle}
:::caution Removal notice
This endpoint was removed in Unleash v5 (deprecated since v4). Please use the [project-based endpoint to fetch specific flags](/reference/api/legacy/unleash/admin/features-v2.mdx#get-toggle) instead.
:::
2017-06-28 10:17:48 +02:00
`GET: http://unleash.host.com/api/admin/features/:featureName`
2016-09-06 21:23:56 +02:00
2018-11-22 11:20:28 +01:00
Used to fetch details about a specific featureToggle. This is mostly provded to make it easy to debug the API and should not be used by the client implementations.
2016-09-06 21:23:56 +02:00
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
2016-09-06 21:23:56 +02:00
"enabled": false,
"stale": false,
2016-09-06 21:23:56 +02:00
"strategies": [
{
"name": "default",
"parameters": {}
}
2018-01-30 15:57:12 +01:00
],
"variants": [],
"tags": []
2016-09-06 21:23:56 +02:00
}
```
## Create a new Feature Flag {#create-a-new-feature-toggle}
:::caution Removal notice
This endpoint was removed in Unleash v5 (deprecated since v4). Please use the [project-based endpoint to create feature flags](/reference/api/legacy/unleash/admin/features-v2.mdx#create-toggle) instead.
:::
2016-09-06 21:23:56 +02:00
2017-06-28 10:17:48 +02:00
`POST: http://unleash.host.com/api/admin/features/`
2016-09-06 21:23:56 +02:00
**Body:**
2018-11-22 11:20:28 +01:00
```json
2016-09-06 21:23:56 +02:00
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
2016-09-06 21:23:56 +02:00
"enabled": false,
"stale": false,
2016-09-06 21:23:56 +02:00
"strategies": [
{
"name": "default",
"parameters": {}
}
]
}
```
Used by the admin-dashboard to create a new feature flags.
**Notes:**
- _name_ **must be globally unique**, otherwise you will get a _403-response_.
- _type_ is optional. If not defined it defaults to `release`
2016-09-06 21:23:56 +02:00
Returns 200-response if the feature flag was created successfully.
2016-09-06 21:23:56 +02:00
## Update a Feature Flag {#update-a-feature-toggle}
:::caution Removal notice
This endpoint was removed in Unleash v5. Please use the [project-based endpoint to update a feature flag](/reference/api/legacy/unleash/admin/features-v2.mdx#update-toggle) instead.
:::
2016-09-06 21:23:56 +02:00
2017-06-28 10:17:48 +02:00
`PUT: http://unleash.host.com/api/admin/features/:toggleName`
2016-09-06 21:23:56 +02:00
**Body:**
2018-11-22 11:20:28 +01:00
```json
2016-09-06 21:23:56 +02:00
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
2016-09-06 21:23:56 +02:00
"enabled": false,
"stale": false,
2016-09-06 21:23:56 +02:00
"strategies": [
{
"name": "default",
"parameters": {}
}
2018-01-30 15:57:12 +01:00
],
"variants": []
2016-09-06 21:23:56 +02:00
}
```
Used by the admin dashboard to update a feature flags. The name has to match an existing features flag.
2016-09-06 21:23:56 +02:00
Returns 200-response if the feature flag was updated successfully.
2016-09-06 21:23:56 +02:00
## Tag a Feature Flag {#tag-a-feature-toggle}
`POST https://unleash.host.com/api/admin/features/:featureName/tags`
Used to tag a feature
If the tuple (type, value) does not already exist, it will be added to the list of tags. Then Unleash will add a relation between the feature name and the tag.
**Body:**
```json
{
"type": "simple",
"value": "Team-Green"
}
```
2021-05-18 13:22:28 +02:00
**Success**
- Returns _201-CREATED_ if the feature was tagged successfully
- Creates the tag if needed, then connects the tag to the existing feature
2021-05-18 13:22:28 +02:00
**Failures**
- Returns _404-NOT-FOUND_ if the `type` was not found
## Remove a tag from a Feature Flag {#remove-a-tag-from-a-feature-toggle}
`DELETE https://unleash.host.com/api/admin/features/:featureName/tags/:type/:value`
Removes the specified tag from the `(type, value)` tuple from the Feature Flag's list of tags.
2021-05-18 13:22:28 +02:00
**Success**
- Returns _200-OK_
2021-05-18 13:22:28 +02:00
**Failures**
- Returns 404 if the tag does not exist
- Returns 500 if the database could not be reached
## Archive a Feature Flag {#archive-a-feature-toggle}
:::caution Removal notice
This endpoint was removed in v5. Please use the [project-based endpoint to archive flags](/reference/api/legacy/unleash/admin/features-v2.mdx#archive-toggle) instead.
:::
2016-09-07 12:12:17 +02:00
2017-06-28 10:17:48 +02:00
`DELETE: http://unleash.host.com/api/admin/features/:toggleName`
2016-09-07 12:12:17 +02:00
Used to archive a feature flag. A feature flag can never be totally be deleted, but can be archived. This is a design decision to make sure that a old feature flag does not suddenly reappear because someone else is re-using the same name.
2016-09-07 12:12:17 +02:00
## Enable a Feature Flag {#enable-a-feature-toggle}
:::caution Removal notice
This endpoint was removed in v5. Please use the [project-based endpoint to enable feature flags](/reference/api/legacy/unleash/admin/features-v2.mdx#enable-env) instead.
:::
`POST: http://unleash.host.com/api/admin/features/:featureName/toggle/on`
Used to enable a feature flag. The :featureName must match an existing Feature Flag. Returns 200-response if the feature flag was enabled successfully.
**Body**
None
**Example response:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
"enabled": true,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}
```
## Disable a Feature Flag {#disable-a-feature-toggle}
:::caution Removal notice
This endpoint was removed in v5. Please use the [project-based endpoint to disable feature flags](/reference/api/legacy/unleash/admin/features-v2.mdx#disable-env) instead.
:::
`POST: http://unleash.host.com/api/admin/features/:featureName/toggle/off`
Used to disable a feature flag. The :featureName must match an existing Feature Flag. Returns 200-response if the feature flag was disabled successfully.
**Body**
None
**Example response:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
"enabled": false,
"stale": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}
```
## Mark a Feature Flag as "stale" {#mark-a-feature-toggle-as-stale}
:::caution Removal notice
This endpoint was removed in v5. Please use the [project-based endpoint to patch a feature flag and mark it as stale](/reference/api/legacy/unleash/admin/features-v2.mdx#patch-toggle) instead.
:::
`POST: http://unleash.host.com/api/admin/features/:featureName/stale/on`
Used to mark a feature flag as stale (deprecated). The :featureName must match an existing Feature Flag. Returns 200-response if the feature flag was enabled successfully.
**Body**
None
**Example response:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
"enabled": true,
"stale": true,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}
```
## Mark a Feature Flag as "active" {#mark-a-feature-toggle-as-active}
:::caution Removal notice
This endpoint was removed in v5. Please use the [project-based endpoint to patch a feature flag and mark it as not stale](/reference/api/legacy/unleash/admin/features-v2.mdx#patch-toggle) instead.
:::
`POST: http://unleash.host.com/api/admin/features/:featureName/stale/off`
Used to mark a feature flag active (remove stale marking). The :featureName must match an existing Feature Flag. Returns 200-response if the feature flag was disabled successfully.
**Body**
None
**Example response:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"type": "release",
"enabled": false,
"stale": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}
```