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_updateStringlast_update token of the runner queue
sessionObjectSession data of the runner
session.authorizationStringAuthorization of the session
session.certificateStringCertificate of the session
session.urlStringURL of the session
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}

Updates the state and other attributes of a job. Used by runners while executing a job.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the job

Request body (application/json)

PropertyTypeDescription
checksumStringCRC32 checksum of the job trace
exit_codeIntegerExit code of the job
failure_reasonStringFailure reason of the job
outputObjectBuild log state
output.bytesizeIntegerSize of the job’s trace output, in bytes
output.checksumStringCRC32 checksum of the job trace
runtime_environment_keyStringRuntime environment key emitted by the runner on job suspension
Maximum length: 512
stateStringStatus of the job: running, success, or failed
token
Required
StringAuthentication token of the job

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
IntegerID of the job
token
Query
StringAuthentication token of the job
direct_download
Query
BooleanIf true, performs a direct download of artifacts from remote storage instead of proxying them
Default: false
download_mode
Query
StringRequested download transfer mode (proxy or direct). Only honored when allowed by the object storage configuration
Allowed values: proxy, direct

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
IntegerID of the job

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_typeStringType 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)
tokenStringAuthentication token of the job

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
IntegerID of the job

Request body (application/json)

PropertyTypeDescription
artifact_typeStringType 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 the artifact file
tokenStringAuthentication token of the job

Responses

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

Get the runtime environment key for a job

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

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

Parameters

NameTypeDescription
id
Path, required
IntegerID of the job
token
Query
StringAuthentication token of the job

Responses

CodeDescriptionSchema
200OKAPIEntitiesCiRuntimeEnvironmentKey
400Bad Request—
403Forbidden—
404Not found—
429Too Many Requests—

Update the trace of a job

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

Updates the trace of a job by appending a chunk of log output. Used by runners while executing a job.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the job

Request body (application/json)

PropertyTypeDescription
debug_traceBooleanIf true, enables debug tracing for the job
tokenStringAuthentication token of the job

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. When the ci_rate_limit_rest_runner_job_list_completed_statuses feature flag is enabled, requests filtered by success, failed, or canceled are rate limited per user (runner_job_list_completed_statuses_limit_per_user application setting), and statuses a runner’s jobs cannot have, such as pending, match no jobs. Until the ci_enforce_runner_job_list_completed_statuses_limit feature flag is enabled, requests over this limit are logged but not blocked. Requests that list only jobs from the user’s projects, which is every user except administrators in Admin Mode and auditors, are rate limited per user (runner_job_list_project_filtered_limit_per_user application setting). Until the ci_rate_limit_rest_runner_job_list_project_filtered feature flag is enabled, requests over this limit are logged but not blocked.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the 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
StringSort results by the specified field
Allowed values: id
sort
Query
StringSort results in ascending or descending 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
IntegerPage number of results to retrieve
Default: 1
Example: 1
per_page
Query
IntegerNumber of items to list per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKArray of APIEntitiesCiJobBasicWithProject
400Bad Request—
401Unauthorized—
403No access granted—
404Runner not found—
429Too Many Requests—

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—
excludeArray of strings—
expire_inString—
nameString—
pathsArray of strings—
untrackedBoolean—
whenString—

APIEntitiesCiJobRequestCache

PropertyTypeDescription
fallback_keysArray of strings—
keyString—
pathsArray of strings—
policyString—
untrackedBoolean—
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—
scriptArray of strings—

APIEntitiesCiJobRequestImage

PropertyTypeDescription
entrypointString—
executor_optsString—
nameString—
portsArray of APIEntitiesCiJobRequestPort—
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—
tag_listArray of stringsExample: ["docker","ruby"]
time_in_queue_secondsString—
user_idString—

APIEntitiesCiJobRequestPort

PropertyTypeDescription
nameString—
numberInteger—
protocolString—

APIEntitiesCiJobRequestResponse

PropertyTypeDescription
allow_git_fetchString—
artifactsArray of APIEntitiesCiJobRequestArtifacts—
cacheArray of APIEntitiesCiJobRequestCache—
credentialsArray of APIEntitiesCiJobRequestCredentials—
dependenciesString—
featuresString—
git_infoAPIEntitiesCiJobRequestGitInfo—
hooksArray of APIEntitiesCiJobRequestHook—
idString—
imageAPIEntitiesCiJobRequestImage—
inputsString—
job_infoAPIEntitiesCiJobRequestJobInfo—
policy_optionsString—
runString—
runner_infoAPIEntitiesCiJobRequestRunnerInfo—
secretsString—
servicesArray of APIEntitiesCiJobRequestService—
stepsArray of APIEntitiesCiJobRequestStep—
suspend_optionsString—
tokenString—
variablesString—

APIEntitiesCiJobRequestRunnerInfo

PropertyTypeDescription
runner_session_urlString—
timeoutString—
uuidString—

APIEntitiesCiJobRequestService

PropertyTypeDescription
aliasString—
commandString—
entrypointString—
executor_optsString—
nameString—
portsArray of APIEntitiesCiJobRequestPort—
pull_policyString—
variablesString—

APIEntitiesCiJobRequestStep

PropertyTypeDescription
allow_failureBoolean—
nameString—
scriptArray of strings—
timeoutInteger—
whenString—

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

APIEntitiesCiRuntimeEnvironmentKey

PropertyTypeDescription
runtime_environment_keyStringExample: 42/s_machineid/data

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

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—