2020-06-23 00:09:42 +05:30
---
stage: Release
2021-02-22 17:27:13 +05:30
group: Release
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
---
2021-11-11 11:23:49 +05:30
# Feature flags API **(FREE SELF)**
2017-09-10 17:25:29 +05:30
2020-05-24 23:13:21 +05:30
This API is for managing Flipper-based [feature flags used in development of GitLab ](../development/feature_flags/index.md ).
2017-09-10 17:25:29 +05:30
All methods require administrator authorization.
Notice that currently the API only supports boolean and percentage-of-time gate
values.
## List all features
Get a list of all persisted features, with its gate values.
2020-04-08 14:13:33 +05:30
```plaintext
2017-09-10 17:25:29 +05:30
GET /features
```
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/features"
2017-09-10 17:25:29 +05:30
```
Example response:
```json
[
{
"name": "experimental_feature",
"state": "off",
"gates": [
{
"key": "boolean",
"value": false
}
2021-02-22 17:27:13 +05:30
],
"definition": null
2017-09-10 17:25:29 +05:30
},
2020-05-24 23:13:21 +05:30
{
"name": "my_user_feature",
"state": "on",
"gates": [
{
"key": "percentage_of_actors",
"value": 34
}
2021-02-22 17:27:13 +05:30
],
"definition": {
"name": "my_user_feature",
"introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
"rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
"group": "group::ci",
"type": "development",
"default_enabled": false
}
2020-05-24 23:13:21 +05:30
},
2017-09-10 17:25:29 +05:30
{
"name": "new_library",
"state": "on",
"gates": [
{
"key": "boolean",
"value": true
}
2021-02-22 17:27:13 +05:30
],
"definition": null
}
]
```
## List all feature definitions
Get a list of all feature definitions.
```plaintext
GET /features/definitions
```
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/features/definitions"
```
Example response:
```json
[
{
2022-06-21 17:19:12 +05:30
"name": "geo_pages_deployment_replication",
"introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68662",
"rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/337676",
"milestone": "14.3",
"log_state_changes": null,
"type": "development",
"group": "group::geo",
2022-05-07 20:08:51 +05:30
"default_enabled": true
2021-02-22 17:27:13 +05:30
},
{
2022-06-21 17:19:12 +05:30
"name": "analytics_devops_adoption_codeowners",
"introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59874",
"rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/328542",
"milestone": "13.12",
"log_state_changes": null,
"type": "development",
"group": "group::optimize",
"default_enabled": true
2017-09-10 17:25:29 +05:30
}
]
```
## Set or create a feature
2021-03-08 18:12:59 +05:30
Set a feature's gate value. If a feature with the given name doesn't exist yet,
it's created. The value can be a boolean, or an integer to indicate
2017-09-10 17:25:29 +05:30
percentage of time.
2020-04-08 14:13:33 +05:30
```plaintext
2017-09-10 17:25:29 +05:30
POST /features/:name
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `name` | string | yes | Name of the feature to create or update |
| `value` | integer/string | yes | `true` or `false` to enable/disable, or an integer for percentage of time |
2020-05-24 23:13:21 +05:30
| `key` | string | no | `percentage_of_actors` or `percentage_of_time` (default) |
2017-09-10 17:25:29 +05:30
| `feature_group` | string | no | A Feature group name |
2022-07-23 23:45:48 +05:30
| `user` | string | no | A GitLab username or comma-separated multiple usernames |
| `group` | string | no | A GitLab group's path, for example `gitlab-org` , or comma-separated multiple group paths |
| `namespace` | string | no | A GitLab group or user namespace's path, for example `john-doe` , or comma-separated multiple namespace paths. [Introduced ](https://gitlab.com/gitlab-org/gitlab/-/issues/353117 ) in GitLab 15.0. |
| `project` | string | no | A projects path, for example `gitlab-org/gitlab-foss` , or comma-separated multiple project paths |
2021-03-11 19:13:27 +05:30
| `force` | boolean | no | Skip feature flag validation checks, such as a YAML definition |
2017-09-10 17:25:29 +05:30
2021-10-27 15:23:28 +05:30
You can enable or disable a feature for a `feature_group` , a `user` ,
2022-07-16 23:28:13 +05:30
a `group` , a `namespace` and a `project` in a single API call.
2017-09-10 17:25:29 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --data "value=30" --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/features/new_library"
2017-09-10 17:25:29 +05:30
```
Example response:
```json
{
"name": "new_library",
"state": "conditional",
"gates": [
{
"key": "boolean",
"value": false
},
{
"key": "percentage_of_time",
"value": 30
}
2021-02-22 17:27:13 +05:30
],
"definition": {
"name": "my_user_feature",
"introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
"rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
"group": "group::ci",
"type": "development",
"default_enabled": false
}
2017-09-10 17:25:29 +05:30
}
```
2018-05-09 12:01:36 +05:30
2020-05-24 23:13:21 +05:30
### Set percentage of actors rollout
Rollout to percentage of actors.
```plaintext
POST https://gitlab.example.com/api/v4/features/my_user_feature?private_token=< your_access_token >
Content-Type: application/x-www-form-urlencoded
value=42& key=percentage_of_actors&
```
Example response:
```json
{
"name": "my_user_feature",
"state": "conditional",
"gates": [
{
"key": "boolean",
"value": false
},
{
"key": "percentage_of_actors",
"value": 42
}
2021-02-22 17:27:13 +05:30
],
"definition": {
"name": "my_user_feature",
"introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
"rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
"group": "group::ci",
"type": "development",
"default_enabled": false
}
2020-05-24 23:13:21 +05:30
}
```
Rolls out the `my_user_feature` to `42%` of actors.
2018-05-09 12:01:36 +05:30
## Delete a feature
Removes a feature gate. Response is equal when the gate exists, or doesn't.
2020-04-08 14:13:33 +05:30
```plaintext
2018-05-09 12:01:36 +05:30
DELETE /features/:name
```