Use this API to interact with GitLab environments.
List all environments
GET /api/v4/projects/{id}/environments
Lists all environments for a specified project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
nameQuery | String | Return the environment with this name.search |
searchQuery | String | Return list of environments matching the search criteria.name |
statesQuery | String | List all environments that match a specific state.available,stopping,stopped.Allowed values: stopped,stopping,available |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
401 | Unauthorized | — |
404 | Not found | — |
Create an environment
POST /api/v4/projects/{id}/environments
Creates an environment for a specified project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
auto_ | String | The auto stop setting for the environment.always and with_Allowed values: always,with_ |
cluster_ | Integer | The ID of the Cluster Agent to associate with this environment |
description | String | The description of the environment |
external_ | String | Place to link to for this environment |
flux_ | String | The Flux resource path to associate with this environment |
kubernetes_ | String | The Kubernetes namespace to associate with this environment |
nameRequired | String | The name of the environment |
tier | String | The tier of the new environment.production,staging,testing,development,otherAllowed values: production,staging,testing,development,other |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not found | — |
Schedule multiple stopped review apps for deletion
DELETE /api/v4/projects/{id}/environments/review_apps
Schedules multiple stopped review apps for deletion. The deletion is performed after 1 week. By default, only environments 30 days or older are deleted.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
beforeQuery | String (date- | The date before which environments can be deleted.YYYY-) |
limitQuery | Integer | Maximum number of environments to delete. Default: 100Maximum: 1000Minimum: 1 |
dry_Query | Boolean | Defaults to true for safety reasons. Default: true |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not found | — |
409 | Conflict | — |
Stop stale environments
POST /api/v4/projects/{id}/environments/stop_stale
Stops all environments that were last modified or deployed to before a specified date. Excludes protected environments.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
beforeRequired | String (date- | Stop all environments that were last modified or deployed to before this date |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | — |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not Found | — |
Retrieve an environment
GET /api/v4/projects/{id}/environments/{environment_id}
Retrieves a specified environment for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
environment_Path, | Integer | The ID of the environment |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
401 | Unauthorized | — |
404 | Not found | — |
Update an existing environment
PUT /api/v4/projects/{id}/environments/{environment_id}
Updates an existing environment for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
environment_Path, | Integer | The ID of the environment |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
auto_ | String | The auto stop setting for the environment.always and with_Allowed values: always,with_ |
cluster_ | Integer | The ID of the Cluster Agent to associate with this environment |
description | String | The description of the environment |
external_ | String | The new URL on which this deployment is viewable |
flux_ | String | The Flux resource path to associate with this environment |
kubernetes_ | String | The Kubernetes namespace to associate with this environment |
tier | String | The tier of the new environment.production,staging,testing,development,otherAllowed values: production,staging,testing,development,other |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not found | — |
Delete an environment
DELETE /api/v4/projects/{id}/environments/{environment_id}
Deletes an environment from a project. The environment must be stopped first.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
environment_Path, | Integer | The ID of the environment |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
401 | Unauthorized | — |
404 | Not found | — |
Stop an environment
POST /api/v4/projects/{id}/environments/{environment_id}/stop
Stops a specified running environment.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
environment_Path, | Integer | The ID of the environment |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
force | Boolean | Force environment to stop without executing on_ actionsDefault: false |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesBasicProjectDetails
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:http: |
created_ | String (date- | Example:2020- |
custom_ | APIEntities | — |
default_ | String | Example:main |
description | String | Example:desc |
forks_ | Integer | Example:1 |
http_ | String | Example:https: |
id | Integer (int64) | Example:1 |
last_ | String (date- | Example:2013- |
license | APIEntities | — |
license_ | String | Example:https: |
name | String | Example:project1 |
name_ | String | Example:John Doe / |
namespace | APIEntities | — |
path | String | Example:project1 |
path_ | String | Example:namespace1/ |
readme_ | String | Example:https: |
repository_ | String | Example:default |
ssh_ | String | Example:git@gitlab. |
star_ | Integer | Example:1 |
tag_ | Array of strings | Example:["tag"] |
topics | Array of strings | Example:["topic"] |
visibility | String | Example:public |
web_ | String | Example:https: |
APIEntitiesCiJob
| Property | Type | Description |
|---|---|---|
allow_ | Boolean | — |
archived | Boolean | Example:false |
artifacts | Array of APIEntities | — |
artifacts_ | String (date- | Example:2016- |
artifacts_ | APIEntities | — |
commit | APIEntities | — |
coverage | Number (float) | Example:98. |
created_ | String (date- | Example:2015- |
duration | Number (float) | Time spent running Example: 0. |
erased_ | String (date- | Example:2015- |
failure_ | String | Example:script_ |
finished_ | String (date- | Example:2015- |
id | Integer (int64) | Example:1 |
name | String | Example:deploy_ |
pipeline | APIEntities | — |
project | Object | — |
project. | String | Example:false |
queued_ | Number (float) | Time spent enqueued Example: 0. |
ref | String | Example:main |
runner | APIEntities | — |
runner_ | APIEntities | — |
stage | String | Example:deploy |
started_ | String (date- | Example:2015- |
status | String | Example:waiting_ |
tag | Boolean | — |
tag_ | Array of strings | Example:["ubuntu18", |
user | APIEntities | — |
web_ | String | Example:https: |
APIEntitiesCiJobArtifact
| Property | Type | Description |
|---|---|---|
file_ | String | Allowed values:raw,zip,gzipExample: zip |
file_ | String | Allowed values:archive,metadata,trace,junit,sast,dependency_,container_,dast,codequality,license_,performance,metrics,metrics_,network_,lsif,dotenv,cobertura,terraform,accessibility,cluster_,secret_,requirements,coverage_,browser_,load_,api_,cluster_,cyclonedx,requirements_,annotations,repository_,jacoco,sarifExample: archive |
filename | String | Example:artifacts. |
size | Integer | Example:1000 |
APIEntitiesCiJobArtifactFile
| Property | Type | Description |
|---|---|---|
filename | String | Example:artifacts. |
size | Integer | Example:1000 |
APIEntitiesCiPipelineBasic
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2022- |
id | Integer (int64) | Example:1 |
iid | Integer | Example:2 |
project_ | Integer (int64) | Example:3 |
ref | String | Example:feature- |
sha | String | Example:0ec9e58fdfca6cdd6652 |
source | String | Example:push |
status | String | Example:success |
updated_ | String (date- | Example:2022- |
web_ | String | Example:https: |
APIEntitiesCiRunner
| Property | Type | Description |
|---|---|---|
active | Boolean | Example:true |
created_ | String (date- | Example:2025- |
created_ | APIEntities | — |
description | String | Example:test- |
id | Integer (int64) | Example:8 |
ip_ | String | Example:127. |
is_ | Boolean | Example:true |
job_ | String | Allowed values:active,idleExample: idle |
name | String | Example:test |
online | Boolean | Example:true |
paused | Boolean | Example:false |
runner_ | String | Allowed values:instance_,group_,project_Example: instance_ |
status | String | Example:online |
APIEntitiesCiRunnerManager
| Property | Type | Description |
|---|---|---|
architecture | String | Example:amd64 |
contacted_ | String | Example:2023- |
created_ | String | Example:2023- |
id | Integer (int64) | Example:8 |
ip_ | String | Example:127. |
job_ | String | Allowed values:active,idleExample: idle |
platform | String | Example:linux |
revision | String | Example:91a27b2a |
status | String | Example:online |
system_ | String | Example:runner- |
version | String | Example:16. |
APIEntitiesClustersAgent
| Property | Type | Description |
|---|---|---|
config_ | APIEntities | — |
created_ | String (date- | — |
created_ | Integer (int64) | Example:1 |
id | Integer (int64) | Example:1 |
name | String | — |
APIEntitiesCommit
| Property | Type | Description |
|---|---|---|
author_ | String | Example:john@example. |
author_ | String | Example:John Smith |
authored_ | String (date- | Example:2012- |
committed_ | String (date- | Example:2012- |
committer_ | String | Example:jack@example. |
committer_ | String | Example:Jack Smith |
created_ | String (date- | Example:2017- |
extended_ | Object | Example:{"Signed- |
id | String | Example:2695effb5807a22ff3d1 |
message | String | Example:Initial commit |
parent_ | Array of strings | Example:["2a4b78934375d7f53875 |
short_ | String | Example:2695effb |
title | String | Example:Initial commit |
trailers | Object | Example:{"Merged- |
web_ | String | Example:https: |
APIEntitiesCustomAttribute
| Property | Type | Description |
|---|---|---|
key | String | Example:foo |
value | String | Example:bar |
APIEntitiesDeployment
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2016- |
deployable | APIEntities | — |
environment | APIEntities | — |
id | Integer (int64) | Example:41 |
iid | Integer | Example:1 |
ref | String | Example:main |
sha | String | Example:99d03678b90d914dbb1b |
status | String | Example:created |
updated_ | String (date- | Example:2016- |
user | APIEntities | — |
APIEntitiesEnvironment
| Property | Type | Description |
|---|---|---|
auto_ | String (date- | Example:2019- |
auto_ | String | Example:always |
cluster_ | APIEntities | — |
created_ | String (date- | Example:2019- |
description | String | Example:description |
external_ | String | Example:https: |
flux_ | String | — |
id | Integer (int64) | Example:1 |
kubernetes_ | String | — |
last_ | APIEntities | — |
name | String | Example:deploy |
project | APIEntities | — |
slug | String | Example:deploy |
state | String | Example:available |
tier | String | Example:development |
updated_ | String (date- | Example:2019- |
APIEntitiesEnvironmentBasic
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2019- |
external_ | String | Example:https: |
id | Integer (int64) | Example:1 |
name | String | Example:deploy |
slug | String | Example:deploy |
updated_ | String (date- | Example:2019- |
APIEntitiesLicenseBasic
| Property | Type | Description |
|---|---|---|
html_ | String | Example:http: |
key | String | Example:gpl- |
name | String | Example:GNU General Public License v3. |
nickname | String | Example:GNU GPLv3 |
source_ | String | — |
APIEntitiesNamespaceBasic
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:https: |
full_ | String | Example:group/ |
id | Integer (int64) | Example:2 |
kind | String | Example:project |
name | String | Example:project |
parent_ | Integer (int64) | Example:1 |
path | String | Example:my_ |
web_ | String | Example:https: |
APIEntitiesProjectIdentity
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2020- |
description | String | Example:desc |
id | Integer (int64) | Example:1 |
name | String | Example:project1 |
name_ | String | Example:John Doe / |
path | String | Example:project1 |
path_ | String | Example:namespace1/ |
APIEntitiesUser
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:/ |
avatar_ | String | Example:https: |
bio | String | — |
bot | Boolean | — |
created_ | String | — |
custom_ | Array of APIEntities | — |
discord | String | — |
followers | String | — |
following | String | — |
github | String | — |
id | Integer (int64) | Example:1 |
is_ | String | — |
job_ | String | — |
linkedin | String | — |
local_ | String | — |
location | String | — |
locked | Boolean | — |
name | String | Example:Administrator |
organization | String | — |
pronouns | String | — |
public_ | String | Example:john@example. |
state | String | Example:active |
twitter | String | — |
username | String | Example:admin |
web_ | String | Example:https: |
website_ | String | — |
work_ | String | — |
APIEntitiesUserBasic
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:/ |
avatar_ | String | Example:https: |
custom_ | Array of APIEntities | — |
id | Integer (int64) | Example:1 |
locked | Boolean | — |
name | String | Example:Administrator |
public_ | String | Example:john@example. |
state | String | Example:active |
username | String | Example:admin |
web_ | String | Example:https: |