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 integerID or URL-encoded path of the project
page
Query
IntegerPage number of results to retrieve
Default: 1
Example: 1
per_page
Query
IntegerNumber of items to list 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
StringFilter environments by state. If omitted, returns all environments
Allowed values: stopped, stopping, available

Responses

CodeDescriptionSchema
200OKArray of APIEntitiesEnvironment
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 integerID or URL-encoded path of the project

Request body (application/json)

PropertyTypeDescription
auto_stop_settingStringAuto stop setting for the environment
Allowed values: always, with_action
cluster_agent_idIntegerID of the cluster agent to associate with the environment. When updating an environment, set to null to remove it
descriptionStringDescription of the environment
external_urlStringURL to link to for the environment
flux_resource_pathStringFlux resource path to associate with the environment, for example helm.toolkit.fluxcd.io/v2/namespaces/gitlab-agent/helmreleases/gitlab-agent. When updating an environment, set to null to remove it
kubernetes_namespaceStringKubernetes namespace to associate with the environment. When updating an environment, set to null to remove it
name
Required
StringName of the environment
tierStringTier of the environment
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 integerID or URL-encoded path of the project
before
Query
String (date-time)Date before which environments can be deleted. Defaults to 30 days ago
limit
Query
IntegerMaximum number of environments to delete
Default: 100
Maximum: 1000
Minimum: 1
dry_run
Query
BooleanIf true, performs a dry run where no deletion is actually performed. If false, deletes 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 integerID or URL-encoded path of the project

Request body (application/json)

PropertyTypeDescription
before
Required
String (date-time)Stop environments that were modified or deployed to before the specified date. Valid inputs are between 10 years ago and 1 week ago

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 integerID or URL-encoded path of the project
environment_id
Path, required
IntegerID 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 integerID or URL-encoded path of the project
environment_id
Path, required
IntegerID of the environment

Request body (application/json)

PropertyTypeDescription
auto_stop_settingStringAuto stop setting for the environment
Allowed values: always, with_action
cluster_agent_idIntegerID of the cluster agent to associate with the environment. When updating an environment, set to null to remove it
descriptionStringDescription of the environment
external_urlStringNew URL to link to for the environment
flux_resource_pathStringFlux resource path to associate with the environment, for example helm.toolkit.fluxcd.io/v2/namespaces/gitlab-agent/helmreleases/gitlab-agent. When updating an environment, set to null to remove it
kubernetes_namespaceStringKubernetes namespace to associate with the environment. When updating an environment, set to null to remove it
tierStringTier of the environment
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. When the environment_delete_in_batches feature flag is enabled, a large environment is deleted over several requests: each request returns 409 until the environment is gone, and the rows deleted count toward a per-user rate limit (environment_delete_rows_limit_per_user application setting). Until the rate_limit_environment_delete_rows feature flag is enabled, requests over this limit are logged but not blocked.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
environment_id
Path, required
IntegerID of the environment

Responses

CodeDescriptionSchema
200OKAPIEntitiesEnvironment
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
409Conflict—
422Unprocessable entity—
429Too many requests—

Stop an environment

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

Stops a specified running environment.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
environment_id
Path, required
IntegerID of the environment

Request body (application/json)

PropertyTypeDescription
forceBooleanIf true, stops the environment 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)Timestamp when the pipeline was created
Example: 2022-10-21T16:49:48.000+02:00
idInteger (int64)ID of the pipeline
Example: 1
iidIntegerInternal ID of the pipeline
Example: 2
project_idInteger (int64)ID of the project of the pipeline
Example: 3
refStringGit reference of the pipeline
Example: feature-branch
shaStringSHA of the commit the pipeline runs for
Example: 0ec9e58fdfca6cdd6652c083c9edb53abc0bad52
sourceStringSource that triggered the pipeline
Example: push
statusStringStatus of the pipeline
Example: success
updated_atString (date-time)Timestamp when the pipeline was last updated
Example: 2022-10-21T16:49:48.000+02:00
web_urlStringURL of the pipeline in the GitLab UI
Example: https://gitlab.example.com/gitlab-org/gitlab-foss/-/pipelines/61

APIEntitiesCiRunner

PropertyTypeDescription
activeBooleanIf true, the runner is allowed to receive jobs. Deprecated. Use paused instead
Example: true
created_atString (date-time)Example: 2025-05-03T00:00:00.000Z
created_byAPIEntitiesUserBasic—
descriptionStringExample: test-1-20150125
idInteger (int64)Example: 8
ip_addressStringAlways null. Deprecated. Use the runner manager fields in the GraphQL API instead
Example: 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_emailStringEmail address of the commit author
Example: john@example.com
author_nameStringName of the commit author
Example: John Smith
authored_dateString (date-time)Date and time when the commit was authored
Example: 2012-05-28T04:42:42-07:00
committed_dateString (date-time)Date and time when the commit was committed
Example: 2012-05-28T04:42:42-07:00
committer_emailStringEmail address of the committer
Example: jack@example.com
committer_nameStringName of the committer
Example: Jack Smith
created_atString (date-time)Date and time when the commit was created. Identical to committed_date
Example: 2017-07-26T11:08:53.000+02:00
extended_trailersObjectGit trailers parsed from the commit message, with every value for each key
Example: {"Signed-off-by":["John Doe \u003cjohndoe@gitlab.com\u003e","Jane Doe \u003cjanedoe@gitlab.com\u003e"]}
idStringFull SHA of the commit
Example: 2695effb5807a22ff3d138d593fd856244e155e7
messageStringFull commit message
Example: Initial commit
parent_idsArray of stringsSHAs of the parent commits
Example: ["2a4b78934375d7f53875269ffd4f45fd83a84ebe"]
short_idStringShort SHA of the commit
Example: 2695effb
titleStringTitle of the commit message
Example: Initial commit
trailersObjectGit trailers parsed from the commit message. Duplicate keys include the last value only
Example: {"Merged-By":"Jane Doe janedoe@gitlab.com"}
web_urlStringURL to view the commit in the GitLab UI
Example: 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_urlStringURL of the namespace avatar. For a group, null if no avatar is set
Example: https://example.com/avatar/12345
full_pathStringFull path of the namespace, including the paths of its parent groups
Example: group/my_project
idInteger (int64)ID of the namespace
Example: 2
kindStringType of the namespace: user, group, or project
Example: project
nameStringName of the namespace
Example: project
parent_idInteger (int64)ID of the parent namespace. null for top-level namespaces
Example: 1
pathStringPath of the namespace
Example: my_project
web_urlStringWeb URL of the namespace. For a user namespace, the URL of the user profile
Example: 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_urlStringURL of the user’s avatar
Example: https://gravatar.com/avatar/1
bioStringBiography of the user
botBoolean—
created_atString (date-time)Creation date and time of the user account in ISO 8601 format
custom_attributesArray of APIEntitiesCustomAttribute—
discordStringDiscord user ID of the user
followersString—
followingString—
githubStringGitHub username of the user
idInteger (int64)ID of the user
Example: 1
is_followedString—
job_titleStringJob title of the user
linkedinStringLinkedIn username of the user
local_timeString—
locationStringLocation of the user
lockedBooleanIf true, the user account is locked, and the user cannot sign in until the lock expires or an administrator unlocks the account
nameStringName of the user. For a bot user, **** if the current user cannot read the bot’s project or group
Example: Administrator
organizationStringOrganization of the user
pronounsStringPronouns of the user
public_emailStringPublic email address of the user
Example: john@example.com
stateStringState of the user account. Possible values: active, blocked, ldap_blocked, blocked_pending_approval, banned, or deactivated
Example: active
twitterStringTwitter username of the user
usernameStringUsername of the user
Example: admin
web_urlStringURL of the user’s profile
Example: https://gitlab.example.com/root
website_urlStringWebsite of the user
work_informationString—

APIEntitiesUserBasic

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringURL of the user’s avatar
Example: https://gravatar.com/avatar/1
custom_attributesArray of APIEntitiesCustomAttribute—
idInteger (int64)ID of the user
Example: 1
lockedBooleanIf true, the user account is locked, and the user cannot sign in until the lock expires or an administrator unlocks the account
nameStringName of the user. For a bot user, **** if the current user cannot read the bot’s project or group
Example: Administrator
public_emailStringPublic email address of the user
Example: john@example.com
stateStringState of the user account. Possible values: active, blocked, ldap_blocked, blocked_pending_approval, banned, or deactivated
Example: active
usernameStringUsername of the user
Example: admin
web_urlStringURL of the user’s profile
Example: https://gitlab.example.com/root