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

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20
name
Query
StringReturn the environment with this name. Mutually exclusive with search
search
Query
StringReturn list of environments matching the search criteria. Must be at least 3 characters. Mutually exclusive with name
states
Query
StringList all environments that match a specific state. Accepted values: available, stopping, or stopped. If no state value given, returns all environments
Allowed values: stopped, stopping, available

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironment
400Bad Request—
401Unauthorized—
404Not found—

Create an environment

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

Creates an environment for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user

Request body (application/json)

PropertyTypeDescription
auto_stop_settingStringThe auto stop setting for the environment. Allowed values are always and with_action
Allowed values: always, with_action
cluster_agent_idIntegerThe ID of the Cluster Agent to associate with this environment
descriptionStringThe description of the environment
external_urlStringPlace to link to for this environment
flux_resource_pathStringThe Flux resource path to associate with this environment
kubernetes_namespaceStringThe Kubernetes namespace to associate with this environment
name
Required
StringThe name of the environment
tierStringThe tier of the new environment. Allowed values are production, staging, testing, development, and other
Allowed values: production, staging, testing, development, other

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesEnvironment
400Bad request—
401Unauthorized—
404Not 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

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
before
Query
String (date-time)The date before which environments can be deleted. Defaults to 30 days ago. Expected in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
limit
Query
IntegerMaximum number of environments to delete. Defaults to 100
Default: 100
Maximum: 1000
Minimum: 1
dry_run
Query
BooleanDefaults to true for safety reasons. It performs a dry run where no actual deletion will be performed. Set to false to actually delete the environment
Default: true

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironmentBasic
400Bad request—
401Unauthorized—
404Not found—
409Conflict—

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

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user

Request body (application/json)

PropertyTypeDescription
before
Required
String (date-time)Stop all environments that were last modified or deployed to before this date

Responses

CodeDescriptionSchema
201Created—
400Bad request—
401Unauthorized—
404Not Found—

Retrieve an environment

GET /api/v4/projects/{id}/environments/{environment_id}

Retrieves a specified environment for a project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
environment_id
Path, required
IntegerThe ID of the environment

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironment
400Bad Request—
401Unauthorized—
404Not found—

Update an existing environment

PUT /api/v4/projects/{id}/environments/{environment_id}

Updates an existing environment for a project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
environment_id
Path, required
IntegerThe ID of the environment

Request body (application/json)

PropertyTypeDescription
auto_stop_settingStringThe auto stop setting for the environment. Allowed values are always and with_action
Allowed values: always, with_action
cluster_agent_idIntegerThe ID of the Cluster Agent to associate with this environment
descriptionStringThe description of the environment
external_urlStringThe new URL on which this deployment is viewable
flux_resource_pathStringThe Flux resource path to associate with this environment
kubernetes_namespaceStringThe Kubernetes namespace to associate with this environment
tierStringThe tier of the new environment. Allowed values are production, staging, testing, development, and other
Allowed values: production, staging, testing, development, other

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironment
400Bad request—
401Unauthorized—
404Not 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

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
environment_id
Path, required
IntegerThe ID of the environment

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironment
400Bad Request—
401Unauthorized—
404Not found—

Stop an environment

POST /api/v4/projects/{id}/environments/{environment_id}/stop

Stops a specified running environment.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project owned by the authenticated user
environment_id
Path, required
IntegerThe ID of the environment

Request body (application/json)

PropertyTypeDescription
forceBooleanForce environment to stop without executing on_stop actions
Default: false

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesEnvironment
400Bad request—
401Unauthorized—
404Not found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesBasicProjectDetails

PropertyTypeDescription
avatar_urlStringExample: http://example.com/uploads/project/avatar/3/uploads/avatar.png
created_atString (date-time)Example: 2020-05-07T04:27:17.016Z
custom_attributesAPIEntitiesCustomAttribute—
default_branchStringExample: main
descriptionStringExample: desc
forks_countIntegerExample: 1
http_url_to_repoStringExample: https://gitlab.example.com/gitlab/gitlab.git
idInteger (int64)Example: 1
last_activity_atString (date-time)Example: 2013-09-30T13:46:02Z
licenseAPIEntitiesLicenseBasic—
license_urlStringExample: https://gitlab.example.com/gitlab/gitlab/blob/master/LICENCE
nameStringExample: project1
name_with_namespaceStringExample: John Doe / project1
namespaceAPIEntitiesNamespaceBasic—
pathStringExample: project1
path_with_namespaceStringExample: namespace1/project1
readme_urlStringExample: https://gitlab.example.com/gitlab/gitlab/blob/master/README.md
repository_storageStringExample: default
ssh_url_to_repoStringExample: git@gitlab.example.com:gitlab/gitlab.git
star_countIntegerExample: 1
tag_listArray of stringsExample: ["tag"]
topicsArray of stringsExample: ["topic"]
visibilityStringExample: public
web_urlStringExample: https://gitlab.example.com/gitlab/gitlab

APIEntitiesCiJob

PropertyTypeDescription
allow_failureBoolean—
archivedBooleanExample: false
artifactsArray of APIEntitiesCiJobArtifact—
artifacts_expire_atString (date-time)Example: 2016-01-19T09:05:50.355Z
artifacts_fileAPIEntitiesCiJobArtifactFile—
commitAPIEntitiesCommit—
coverageNumber (float)Example: 98.29
created_atString (date-time)Example: 2015-12-24T15:51:21.880Z
durationNumber (float)Time spent running
Example: 0.465
erased_atString (date-time)Example: 2015-12-24T18:00:29.728Z
failure_reasonStringExample: script_failure
finished_atString (date-time)Example: 2015-12-24T17:54:31.198Z
idInteger (int64)Example: 1
nameStringExample: deploy_to_production
pipelineAPIEntitiesCiPipelineBasic—
projectObject—
project.ci_job_token_scope_enabledStringExample: false
queued_durationNumber (float)Time spent enqueued
Example: 0.123
refStringExample: main
runnerAPIEntitiesCiRunner—
runner_managerAPIEntitiesCiRunnerManager—
stageStringExample: deploy
started_atString (date-time)Example: 2015-12-24T17:54:30.733Z
statusStringExample: waiting_for_resource
tagBoolean—
tag_listArray of stringsExample: ["ubuntu18","docker runner"]
userAPIEntitiesUser—
web_urlStringExample: https://example.com/foo/bar/-/jobs/1

APIEntitiesCiJobArtifact

PropertyTypeDescription
file_formatStringAllowed values: raw, zip, gzip
Example: zip
file_typeStringAllowed values: archive, metadata, trace, junit, sast, dependency_scanning, container_scanning, dast, codequality, license_scanning, performance, metrics, metrics_referee, network_referee, lsif, dotenv, cobertura, terraform, accessibility, cluster_applications, secret_detection, requirements, coverage_fuzzing, browser_performance, load_performance, api_fuzzing, cluster_image_scanning, cyclonedx, requirements_v2, annotations, repository_xray, jacoco, sarif
Example: archive
filenameStringExample: artifacts.zip
sizeIntegerExample: 1000

APIEntitiesCiJobArtifactFile

PropertyTypeDescription
filenameStringExample: artifacts.zip
sizeIntegerExample: 1000

APIEntitiesCiPipelineBasic

PropertyTypeDescription
created_atString (date-time)Example: 2022-10-21T16:49:48.000+02:00
idInteger (int64)Example: 1
iidIntegerExample: 2
project_idInteger (int64)Example: 3
refStringExample: feature-branch
shaStringExample: 0ec9e58fdfca6cdd6652c083c9edb53abc0bad52
sourceStringExample: push
statusStringExample: success
updated_atString (date-time)Example: 2022-10-21T16:49:48.000+02:00
web_urlStringExample: https://gitlab.example.com/gitlab-org/gitlab-foss/-/pipelines/61

APIEntitiesCiRunner

PropertyTypeDescription
activeBooleanExample: true
created_atString (date-time)Example: 2025-05-03T00:00:00.000Z
created_byAPIEntitiesUserBasic—
descriptionStringExample: test-1-20150125
idInteger (int64)Example: 8
ip_addressStringExample: 127.0.0.1
is_sharedBooleanExample: true
job_execution_statusStringAllowed values: active, idle
Example: idle
nameStringExample: test
onlineBooleanExample: true
pausedBooleanExample: false
runner_typeStringAllowed values: instance_type, group_type, project_type
Example: instance_type
statusStringExample: online

APIEntitiesCiRunnerManager

PropertyTypeDescription
architectureStringExample: amd64
contacted_atStringExample: 2023-10-24T01:27:06.549Z
created_atStringExample: 2023-10-24T01:27:06.549Z
idInteger (int64)Example: 8
ip_addressStringExample: 127.0.0.1
job_execution_statusStringAllowed values: active, idle
Example: idle
platformStringExample: linux
revisionStringExample: 91a27b2a
statusStringExample: online
system_idStringExample: runner-1
versionStringExample: 16.11.0

APIEntitiesClustersAgent

PropertyTypeDescription
config_projectAPIEntitiesProjectIdentity—
created_atString (date-time)—
created_by_user_idInteger (int64)Example: 1
idInteger (int64)Example: 1
nameString—

APIEntitiesCommit

PropertyTypeDescription
author_emailStringExample: john@example.com
author_nameStringExample: John Smith
authored_dateString (date-time)Example: 2012-05-28T04:42:42-07:00
committed_dateString (date-time)Example: 2012-05-28T04:42:42-07:00
committer_emailStringExample: jack@example.com
committer_nameStringExample: Jack Smith
created_atString (date-time)Example: 2017-07-26T11:08:53.000+02:00
extended_trailersObjectExample: {"Signed-off-by":["John Doe \u003cjohndoe@gitlab.com\u003e","Jane Doe \u003cjanedoe@gitlab.com\u003e"]}
idStringExample: 2695effb5807a22ff3d138d593fd856244e155e7
messageStringExample: Initial commit
parent_idsArray of stringsExample: ["2a4b78934375d7f53875269ffd4f45fd83a84ebe"]
short_idStringExample: 2695effb
titleStringExample: Initial commit
trailersObjectExample: {"Merged-By":"Jane Doe janedoe@gitlab.com"}
web_urlStringExample: https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746

APIEntitiesCustomAttribute

PropertyTypeDescription
keyStringExample: foo
valueStringExample: bar

APIEntitiesDeployment

PropertyTypeDescription
created_atString (date-time)Example: 2016-08-11T11:32:35.444Z
deployableAPIEntitiesCiJob—
environmentAPIEntitiesEnvironmentBasic—
idInteger (int64)Example: 41
iidIntegerExample: 1
refStringExample: main
shaStringExample: 99d03678b90d914dbb1b109132516d71a4a03ea8
statusStringExample: created
updated_atString (date-time)Example: 2016-08-11T11:32:35.444Z
userAPIEntitiesUserBasic—

APIEntitiesEnvironment

PropertyTypeDescription
auto_stop_atString (date-time)Example: 2019-05-25T18:55:13.252Z
auto_stop_settingStringExample: always
cluster_agentAPIEntitiesClustersAgent—
created_atString (date-time)Example: 2019-05-25T18:55:13.252Z
descriptionStringExample: description
external_urlStringExample: https://deploy.gitlab.example.com
flux_resource_pathString—
idInteger (int64)Example: 1
kubernetes_namespaceString—
last_deploymentAPIEntitiesDeployment—
nameStringExample: deploy
projectAPIEntitiesBasicProjectDetails—
slugStringExample: deploy
stateStringExample: available
tierStringExample: development
updated_atString (date-time)Example: 2019-05-25T18:55:13.252Z

APIEntitiesEnvironmentBasic

PropertyTypeDescription
created_atString (date-time)Example: 2019-05-25T18:55:13.252Z
external_urlStringExample: https://deploy.gitlab.example.com
idInteger (int64)Example: 1
nameStringExample: deploy
slugStringExample: deploy
updated_atString (date-time)Example: 2019-05-25T18:55:13.252Z

APIEntitiesLicenseBasic

PropertyTypeDescription
html_urlStringExample: http://choosealicense.com/licenses/gpl-3.0
keyStringExample: gpl-3.0
nameStringExample: GNU General Public License v3.0
nicknameStringExample: GNU GPLv3
source_urlString—

APIEntitiesNamespaceBasic

PropertyTypeDescription
avatar_urlStringExample: https://example.com/avatar/12345
full_pathStringExample: group/my_project
idInteger (int64)Example: 2
kindStringExample: project
nameStringExample: project
parent_idInteger (int64)Example: 1
pathStringExample: my_project
web_urlStringExample: https://example.com/group/my_project

APIEntitiesProjectIdentity

PropertyTypeDescription
created_atString (date-time)Example: 2020-05-07T04:27:17.016Z
descriptionStringExample: desc
idInteger (int64)Example: 1
nameStringExample: project1
name_with_namespaceStringExample: John Doe / project1
pathStringExample: project1
path_with_namespaceStringExample: namespace1/project1

APIEntitiesUser

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringExample: https://gravatar.com/avatar/1
bioString—
botBoolean—
created_atString—
custom_attributesArray of APIEntitiesCustomAttribute—
discordString—
followersString—
followingString—
githubString—
idInteger (int64)Example: 1
is_followedString—
job_titleString—
linkedinString—
local_timeString—
locationString—
lockedBoolean—
nameStringExample: Administrator
organizationString—
pronounsString—
public_emailStringExample: john@example.com
stateStringExample: active
twitterString—
usernameStringExample: admin
web_urlStringExample: https://gitlab.example.com/root
website_urlString—
work_informationString—

APIEntitiesUserBasic

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringExample: https://gravatar.com/avatar/1
custom_attributesArray of APIEntitiesCustomAttribute—
idInteger (int64)Example: 1
lockedBoolean—
nameStringExample: Administrator
public_emailStringExample: john@example.com
stateStringExample: active
usernameStringExample: admin
web_urlStringExample: https://gitlab.example.com/root