Use this API to interact with CI/CD jobs.

Retrieve a job by job token

GET /api/v4/job

Retrieves a job that was generated by a specified job token.

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJob
400Bad request—
401Unauthorized—
404Not found—

List all jobs for a project

GET /api/v4/projects/{id}/jobs

Lists all jobs for a specified project. By default, this request returns 20 results at a time because the API results are paginated.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
scope
Query
Array of stringsThe scope of builds to show
Example: ["pending","running"]
ref
Query
StringThe branch name (ref) to filter jobs by
Example: feature-branch
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Retrieve a job

GET /api/v4/projects/{id}/jobs/{job_id}

Retrieves a job with the specified job ID.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a job
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Cancel a job

POST /api/v4/projects/{id}/jobs/{job_id}/cancel

Cancels a specified job in a project.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a job
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Request body (application/json)

PropertyTypeDescription
forceBooleanForce cancellation for a job with a state of canceling
Example: true

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Erase a job

POST /api/v4/projects/{id}/jobs/{job_id}/erase

Erases a specified job in a project. This removes job artifacts and the job log.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a build
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
409Conflict—

Run a job

POST /api/v4/projects/{id}/jobs/{job_id}/play

Runs a specified job. For a job in manual status, triggers an action to start the job.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a Job
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Request body (application/json)

PropertyTypeDescription
job_inputsObjectInput values for the job
Example: {"environment":"production"}
job_variables_attributesArray of objectsUser defined variables that will be included when running the job
job_variables_attributes[].key
Required
StringThe name of the variable
Example: foo
job_variables_attributes[].value
Required
StringThe value of the variable
Example: bar

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJobBasic
400Bad request—
401Unauthorized—
403Forbidden—
404Not found—

Retry a job

POST /api/v4/projects/{id}/jobs/{job_id}/retry

Retries a specified job in a project.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a job
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Request body (application/json)

PropertyTypeDescription
inputsObjectInput values for the job
Example: {"environment":"production"}

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Get the runtime environment key for a job

GET /api/v4/projects/{id}/jobs/{job_id}/runtime_environment_key

Retrieves the runtime environment key linked to a job, if the job is resuming a suspended environment.

Parameters

NameTypeDescription
job_id
Path, required
IntegerThe ID of a job
Example: 88
id
Path, required
String or integerThe ID or URL-encoded path of the project
Example: 11

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiRuntimeEnvironmentKey
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Get a trace of a specific job of a project

GET /api/v4/projects/{id}/jobs/{job_id}/trace

Retrieves a log file for a job.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
job_id
Path, required
IntegerThe ID of a job
Example: 88
byte_offset
Query
IntegerByte offset to start reading from
Minimum: 0
Example: 0
byte_limit
Query
IntegerMaximum number of bytes to return
Maximum: 512000
Minimum: 1
Example: 51200

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJob
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Schemas

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

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

APIEntitiesCiJobBasic

PropertyTypeDescription
allow_failureBoolean—
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
stageStringExample: deploy
started_atString (date-time)Example: 2015-12-24T17:54:30.733Z
statusStringExample: waiting_for_resource
tagBoolean—
userAPIEntitiesUser—
web_urlStringExample: https://example.com/foo/bar/-/jobs/1

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

APIEntitiesCiRuntimeEnvironmentKey

PropertyTypeDescription
runtime_environment_keyStringExample: 42/s_machineid/data

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

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