Use this API to manage protected environments for a project, and protected environments for a group for a group.
The project endpoints require CI/CD to be turned on for the project. If
CI/CD is turned off,
requests return 403 Forbidden, even for users who otherwise have permission to manage protected
environments.
List protected environments for a group
GET /api/v4/groups/{id}/protected_environments
Lists the protected environments configured for a group.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Create a protected environment for a group
POST /api/v4/groups/{id}/protected_environments
Creates a protected environment and its nested configuration for a group.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
approval_ | Array of objects | — |
approval_ | Boolean | — |
approval_ | Integer | Example:40 |
approval_ | Integer | Example:3 |
approval_ | Integer | Allowed values:0,1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:2 |
deploy_ | Array of objects | — |
deploy_ | Boolean | — |
deploy_ | Integer | Example:40 |
deploy_ | Integer | Example:3 |
deploy_ | Integer | Allowed values:0,1 |
deploy_ | Integer | Example:1 |
deploy_ | Integer | Example:2 |
nameRequired | String | Allowed values:production,staging,testing,development,otherMinimum length: 1 |
required_ | Integer | Example:0 |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Retrieve a protected environment for a group
GET /api/v4/groups/{id}/protected_environments/{name}
Retrieves a protected environment configured for a group.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Allowed values:production,staging,testing,development,otherMinimum length: 1Example: production |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Update nested protected environment configuration for a group
PUT /api/v4/groups/{id}/protected_environments/{name}
Updates nested configuration without changing the protected environment name.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Allowed values:production,staging,testing,development,otherMinimum length: 1Example: production |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
approval_ | Array of objects | — |
approval_ | Boolean | — |
approval_ | Integer | Example:40 |
approval_ | Integer | Example:3 |
approval_ | Integer | Allowed values:0,1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:2 |
deploy_ | Array of objects | — |
deploy_ | Boolean | — |
deploy_ | Integer | Example:40 |
deploy_ | Integer | Example:3 |
deploy_ | Integer | Allowed values:0,1 |
deploy_ | Integer | Example:1 |
deploy_ | Integer | Example:2 |
required_ | Integer | Example:0 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Delete a protected environment from a group
DELETE /api/v4/groups/{id}/protected_environments/{name}
Deletes a protected environment and its nested configuration from a group.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Allowed values:production,staging,testing,development,otherMinimum length: 1Example: production |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
List protected environments for a project
GET /api/v4/projects/{id}/protected_environments
Lists the protected environments configured for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Create a protected environment for a project
POST /api/v4/projects/{id}/protected_environments
Creates a protected environment and its nested configuration for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
approval_ | Array of objects | — |
approval_ | Boolean | — |
approval_ | Integer | Example:40 |
approval_ | Integer | Example:3 |
approval_ | Integer | Allowed values:0,1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:2 |
deploy_ | Array of objects | — |
deploy_ | Boolean | — |
deploy_ | Integer | Example:40 |
deploy_ | Integer | Example:3 |
deploy_ | Integer | Allowed values:0,1 |
deploy_ | Integer | Example:1 |
deploy_ | Integer | Example:2 |
nameRequired | String | Example:production |
required_ | Integer | Example:0 |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
List inherited protected environments for a project
GET /api/v4/projects/{id}/protected_environments/inherited
Lists protected environments inherited from the project group hierarchy.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Retrieve a protected environment for a project
GET /api/v4/projects/{id}/protected_environments/{name}
Retrieves a protected environment configured for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Example:production |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Update nested protected environment configuration for a project
PUT /api/v4/projects/{id}/protected_environments/{name}
Updates nested configuration without changing the protected environment name.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Example:production |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
approval_ | Array of objects | — |
approval_ | Boolean | — |
approval_ | Integer | Example:40 |
approval_ | Integer | Example:3 |
approval_ | Integer | Allowed values:0,1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:1 |
approval_ | Integer | Example:2 |
deploy_ | Array of objects | — |
deploy_ | Boolean | — |
deploy_ | Integer | Example:40 |
deploy_ | Integer | Example:3 |
deploy_ | Integer | Allowed values:0,1 |
deploy_ | Integer | Example:1 |
deploy_ | Integer | Example:2 |
required_ | Integer | Example:0 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Delete a protected environment from a project
DELETE /api/v4/projects/{id}/protected_environments/{name}
Deletes a protected environment and its nested configuration from a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- Example: 11 |
namePath, | String | Example:production |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesInheritedProtectedEnvironment
| Property | Type | Description |
|---|---|---|
approval_ | Array of APIEntities | — |
deploy_ | Array of APIEntities | — |
group | APIEntities | — |
id | Integer (int64) | Example:1 |
name | String | Example:production |
required_ | Integer | Example:0 |
APIEntitiesProtectedEnvironment
| Property | Type | Description |
|---|---|---|
approval_ | Array of APIEntities | — |
deploy_ | Array of APIEntities | — |
id | Integer (int64) | Example:1 |
name | String | Example:production |
required_ | Integer | Example:0 |
APIEntitiesProtectedEnvironmentAccessLevel
| Property | Type | Description |
|---|---|---|
access_ | Integer | Example:40 |
access_ | String | Example:Maintainers |
group_ | Integer (int64) | Example:3 |
group_ | Integer | Example:0 |
id | Integer (int64) | Example:1 |
user_ | Integer (int64) | Example:2 |
APIEntitiesProtectedEnvironmentApprovalRule
| Property | Type | Description |
|---|---|---|
access_ | Integer | Example:40 |
access_ | String | Example:Maintainers |
group_ | Integer (int64) | Example:3 |
group_ | Integer | Example:0 |
id | Integer (int64) | Example:1 |
required_ | Integer | Example:1 |
user_ | Integer (int64) | Example:2 |
APIEntitiesProtectedEnvironmentOwnerGroup
| Property | Type | Description |
|---|---|---|
full_ | String | Example:Platform |
full_ | String | Example:platform |
id | Integer (int64) | Example:1 |
web_ | String | Example:/ |