Use this API to list the statuses recorded against a commit, and to add or update the status that an external CI/CD job reports for a commit.

List all commit statuses

GET /api/v4/projects/{id}/repository/commits/{sha}/statuses

Lists all commit statuses for a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
sha
Path, required
StringCommit SHA
Example: 18f3e63d05582537db6d183d9d557be09e1f90c8
ref
Query
StringName of the branch or tag. Defaults to the default branch
Example: develop
stage
Query
StringFilter statuses by build stage. For example, test
Example: test
name
Query
StringFilter statuses by job name
Example: bundler:audit
pipeline_id
Query
IntegerFilter statuses by pipeline ID. Introduced in GitLab 17.9
Example: 1234
all
Query
BooleanIf true, includes all statuses instead of only the latest
order_by
Query
StringSort results by the specified field. With pipeline_id, statuses of the same pipeline are also sorted by id in the sort direction. Introduced in GitLab 17.9
Allowed values: id, pipeline_id
Default: id
sort
Query
StringSort statuses in ascending or descending order. Defaults to asc. Introduced in GitLab 17.9
Allowed values: asc, desc
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 APIEntitiesCommitStatus
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Create or update a commit pipeline status

POST /api/v4/projects/{id}/statuses/{sha}

Creates or updates the status of a commit represented by a job in an external stage. If the commit is associated with a merge request, target the commit in the merge request source branch. The job is added to the newest matching pipeline for the commit. If no matching pipeline exists, a new pipeline is created with CI_PIPELINE_SOURCE: external. When duplicate pipelines exist for the same commit, the newest one receives the status. If the matching pipeline exceeds the maximum number of jobs in a pipeline, a 422 error is returned when pipeline_id is specified. Otherwise, a new pipeline is created. If an update is already in progress for the same SHA and ref, a 409 error is returned, and the request can be retried.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
sha
Path, required
StringCommit SHA
Example: 18f3e63d05582537db6d183d9d557be09e1f90c8

Request body (application/json)

PropertyTypeDescription
contextStringString label to differentiate this status from the status of other systems. Default is default
Example: coverage
coverageNumberTotal code coverage
Example: 100
descriptionStringShort description of the status. Must be 255 characters or fewer
nameStringString label to differentiate this status from the status of other systems. Default is default
Example: coverage
pipeline_idIntegerID of the pipeline to set the status for. Use when multiple pipelines exist for the same commit SHA
refStringBranch or tag that the status refers to. Must be 255 characters or fewer
Example: develop
state
Required
StringState of the status
Allowed values: pending, running, success, failed, canceled, skipped
Minimum length: 1
target_urlStringTarget URL to associate with this status. Must be 255 characters or fewer
Example: https://gitlab.example.com/janedoe/gitlab-foss/builds/91

Responses

CodeDescriptionSchema
200OKAPIEntitiesCommitStatus
400Bad request—
401Unauthorized—
403Forbidden—
404Not found—
409Another update to this commit status is in progress—

Schemas

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

APIEntitiesCommitStatus

PropertyTypeDescription
allow_failureBooleanIf true, the status is allowed to fail
Example: false
authorAPIEntitiesUserBasicUser who created the status
coverageNumber (float)Code coverage percentage
Example: 98.29
created_atString (date-time)Date and time when the status was created
Example: 2016-01-19T09:05:50.355Z
descriptionStringDescription of the status
finished_atString (date-time)Date and time when the status finished
Example: 2016-01-21T08:40:25.832Z
idInteger (int64)ID of the status
Example: 93
nameStringName of the status
Example: default
pipeline_idInteger (int64)Example: 101
refStringBranch or tag of the commit
Example: develop
shaStringSHA of the commit
Example: 18f3e63d05582537db6d183d9d557be09e1f90c8
started_atString (date-time)Date and time when the status started
Example: 2016-01-20T08:40:25.832Z
statusStringStatus of the commit
Example: success
target_urlStringTarget URL associated with the status
Example: https://gitlab.example.com/janedoe/gitlab-foss/builds/91

APIEntitiesCustomAttribute

PropertyTypeDescription
keyStringExample: foo
valueStringExample: bar

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