Use this API to run CI/CD jobs on a runner: request the next job, update its state, append to its log, and transfer its artifacts.

GitLab Runner uses these endpoints itself.

Request a job

POST /api/v4/jobs/request

Requests a job for a runner to execute.

Request body (application/json)

PropertyTypeDescription
infoObjectRunner’s metadata
info.architectureStringRunner’s architecture
info.configObjectRunner’s config
info.config.gpusStringGPUs enabled
info.executorStringRunner’s executor
info.featuresObjectRunner’s features
info.labelsObjectRunner’s labels
info.nameStringRunner’s name
info.platformStringRunner’s platform
info.revisionStringRunner’s revision
info.versionStringRunner’s version
last_updateStringRunner’s queue last_update token
sessionObjectRunner’s session data
session.authorizationStringSession’s authorization
session.certificateStringSession’s certificate
session.urlStringSession’s url
system_idStringRunner’s system identifier
token
Required
StringRunner’s authentication token

Responses

CodeDescriptionSchema
201Job was scheduledAPIEntitiesCiJobRequestResponse
204No job for Runner—
400Bad Request—
403Forbidden—
409Conflict—
422Runner is orphaned—
429Too Many Requests—

Update a job

PUT /api/v4/jobs/{id}

Parameters

NameTypeDescription
id
Path, required
IntegerJob’s ID

Request body (application/json)

PropertyTypeDescription
checksumStringJob’s trace CRC32 checksum
exit_codeIntegerJob’s exit code
failure_reasonStringJob’s failure_reason
outputObjectBuild log state
output.bytesizeIntegerJob’s trace size in bytes
output.checksumStringJob’s trace CRC32 checksum
runtime_environment_keyStringRuntime environment key emitted by the runner on job suspension
Maximum length: 512
stateStringJob’s status: running, success, failed
token
Required
StringJob’s authentication token

Responses

CodeDescriptionSchema
200Job was updated—
202Update accepted—
400Unknown parameters—
403Forbidden—
404Not Found—
409Conflict—
429Too Many Requests—

Download job artifacts

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

Downloads artifacts for a specified job.

Parameters

NameTypeDescription
id
Path, required
IntegerJob’s ID
token
Query
StringJob’s authentication token
direct_download
Query
BooleanPerform direct download from remote storage instead of proxying artifacts
Default: false

Responses

CodeDescriptionSchema
200Download allowedString (binary) (application/octet-stream)
302FoundString (binary) (application/octet-stream)
400Bad Request—
401Unauthorized—
403Forbidden—
404Artifact not found—
429Too Many Requests—

Upload job artifacts

POST /api/v4/jobs/{id}/artifacts

Uploads artifacts for a specified job.

Parameters

NameTypeDescription
id
Path, required
IntegerJob’s ID

Request body (multipart/form-data)

PropertyTypeDescription
accessibilityStringSpecify accessibility level of artifact private/public
artifact_formatStringThe format of artifact
Allowed values: raw, zip, gzip
Default: zip
artifact_typeStringThe type of artifact
Allowed 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
Default: archive
expire_inStringSpecify when artifact should expire
file
Required
String (binary)The artifact file to store (generated by Multipart middleware)
metadataString (binary)The artifact metadata to store (generated by Multipart middleware)
tokenStringJob’s authentication token

Responses

CodeDescriptionSchema
201Created—
400Bad request—
403Forbidden—
404Not Found—
405Artifacts support not enabled—
413File too large—
429Too Many Requests—

Authorize artifacts upload

POST /api/v4/jobs/{id}/artifacts/authorize

Authorizes uploading artifacts for a specified job.

Parameters

NameTypeDescription
id
Path, required
IntegerJob’s ID

Request body (application/json)

PropertyTypeDescription
artifact_typeStringThe type of artifact
Allowed 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
Default: archive
filesizeIntegerSize of artifact file
tokenStringJob’s authentication token

Responses

CodeDescriptionSchema
200Upload allowed—
400Bad Request—
403Forbidden—
404Not Found—
405Artifacts support not enabled—
413File too large—
429Too Many Requests—

Append a patch to the job trace

PATCH /api/v4/jobs/{id}/trace

Parameters

NameTypeDescription
id
Path, required
IntegerJob’s ID

Request body (application/json)

PropertyTypeDescription
debug_traceBooleanEnable or disable the debug trace
tokenStringJob’s authentication token

Responses

CodeDescriptionSchema
202Trace was patched—
400Missing Content-Range header—
403Forbidden—
404Not Found—
416Range not satisfiable—
429Too Many Requests—

List all jobs processed by a runner

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

Lists all jobs that are being processed or were processed by a specified runner. The list of jobs is limited to projects where the user has the Reporter, Developer, Maintainer, or Owner role.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of a runner
system_id
Query
StringSystem ID associated with the runner manager
status
Query
StringStatus of the job
Allowed values: created, waiting_for_resource, preparing, waiting_for_callback, pending, running, success, failed, canceling, canceled, skipped, manual, scheduled
order_by
Query
StringOrder by id
Allowed values: id
sort
Query
StringSort by asc or desc order. Specify order_by as well, including for id
Allowed values: asc, desc
Default: desc
cursor
Query
StringCursor for obtaining the next set of records
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiJobBasicWithProject
400Bad Request—
401Unauthorized—
403No access granted—
404Runner not found—

Schemas

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

APIEntitiesCiJobBasicWithProject

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—
projectAPIEntitiesProjectIdentity—
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

APIEntitiesCiJobRequestArtifacts

PropertyTypeDescription
artifact_formatString—
artifact_typeString—
excludeString—
expire_inString—
nameString—
pathsString—
untrackedString—
whenString—

APIEntitiesCiJobRequestCache

PropertyTypeDescription
fallback_keysString—
keyString—
pathsString—
policyString—
untrackedString—
whenString—

APIEntitiesCiJobRequestCredentials

PropertyTypeDescription
passwordString—
typeString—
urlString—
usernameString—

APIEntitiesCiJobRequestGitInfo

PropertyTypeDescription
before_shaString—
depthString—
protectedString—
refString—
ref_typeString—
refspecsString—
repo_object_formatString—
repo_urlString—
shaString—

APIEntitiesCiJobRequestHook

PropertyTypeDescription
nameString—
scriptString—

APIEntitiesCiJobRequestImage

PropertyTypeDescription
entrypointString—
executor_optsString—
nameString—
portsAPIEntitiesCiJobRequestPort—
pull_policyString—

APIEntitiesCiJobRequestJobInfo

PropertyTypeDescription
idString—
instance_idString—
instance_uuidString—
nameString—
namespace_idString—
organization_idString—
pipeline_idString—
project_full_pathString—
project_idString—
project_jobs_running_on_instance_runners_countString—
project_nameString—
queue_depthString—
queue_sizeString—
root_namespace_idString—
scoped_user_idString—
stageString—
time_in_queue_secondsString—
user_idString—

APIEntitiesCiJobRequestPort

PropertyTypeDescription
nameString—
numberString—
protocolString—

APIEntitiesCiJobRequestResponse

PropertyTypeDescription
allow_git_fetchString—
artifactsAPIEntitiesCiJobRequestArtifacts—
cacheAPIEntitiesCiJobRequestCache—
credentialsAPIEntitiesCiJobRequestCredentials—
dependenciesString—
featuresString—
git_infoAPIEntitiesCiJobRequestGitInfo—
hooksAPIEntitiesCiJobRequestHook—
idString—
imageAPIEntitiesCiJobRequestImage—
inputsString—
job_infoAPIEntitiesCiJobRequestJobInfo—
runString—
runner_infoAPIEntitiesCiJobRequestRunnerInfo—
secretsString—
servicesAPIEntitiesCiJobRequestService—
stepsAPIEntitiesCiJobRequestStep—
suspend_optionsString—
tokenString—
variablesString—

APIEntitiesCiJobRequestRunnerInfo

PropertyTypeDescription
runner_session_urlString—
timeoutString—
uuidString—

APIEntitiesCiJobRequestService

PropertyTypeDescription
aliasString—
commandString—
entrypointString—
executor_optsString—
nameString—
portsAPIEntitiesCiJobRequestPort—
pull_policyString—
variablesString—

APIEntitiesCiJobRequestStep

PropertyTypeDescription
allow_failureString—
nameString—
scriptString—
timeoutString—
whenString—

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

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

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—