Skip to content

Create a feature flag

POST
/api/v4/projects/{id}/feature_flags

Creates a feature flag for a specified project.

id
required
One of:
string

The ID or URL-encoded path of the project

Media type application/json
object
name
required

The name of the feature flag

string
nullable
description

The description of the feature flag

string
nullable
active

The active state of the flag. Defaults to true. Supported in GitLab 13.3 and later

boolean
nullable
strategies

Array of feature flag strategies

Array<object>
nullable
object
name
required

The strategy name. Can be default, gradualRolloutUserId, userWithId, or gitlabUserList. In GitLab 13.5 and later, can be flexibleRollout

string
nullable
parameters

The strategy parameters as a JSON-formatted string e.g. {"userIds":"user1"}

object
user_list_id

The ID of the feature flag user list. If strategy is gitlabUserList.

integer
nullable
scopes

Array of scopes for the strategy

Array<object>
nullable
object
environment_scope
required

The environment scope of the scope

string
nullable
Example generated
{
"name": "example",
"description": "example",
"active": true,
"strategies": [
{
"name": "example",
"parameters": {},
"user_list_id": 1,
"scopes": [
{
"environment_scope": "example"
}
]
}
]
}

Created

Media type application/json
object
name
string
description
string
active
boolean
version
string
created_at
string format: date-time
updated_at
string format: date-time
scopes
array
strategies
object
id
integer format: int64
name
string
parameters
string
scopes
object
id
integer format: int64
environment_scope
string
user_list
object
id
integer format: int64
iid
integer
name
string
user_xids
string
Example
{
"name": "merge_train",
"description": "merge train feature flag",
"version": "new_version_flag",
"created_at": "2019-11-04T08:13:51.423Z",
"updated_at": "2019-11-04T08:13:51.423Z",
"strategies": {
"id": 1,
"name": "userWithId",
"parameters": "{\"userIds\": \"user1\"}",
"scopes": {
"id": 1,
"environment_scope": "production"
},
"user_list": {
"id": 1,
"iid": 1,
"name": "user_list",
"user_xids": "user1,user2"
}
}
}

Bad request

Unauthorized

Forbidden

Not Found