Help Center/ CodeArts Repo/ API Reference/ APIs/ V4/ Commit/ Rolling Back a Commit
Updated on 2026-04-28 GMT+08:00

Rolling Back a Commit

Function

This API is used to roll back a commit.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST https://{hostURL}/v4/repositories/{repository_id}/repository/commits/{sha}/revert

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Definition

You can query the project list to obtain the repository ID by calling the API used to query user's all repositories.

Constraints

N/A.

Value range:

1~2147483647

sha

Yes

String

Definition

ID of the rolled back commit.

Range

String length: 40 characters.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. Obtain a token by calling the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the user token.

Constraints

Mandatory.

Range

1–100,000 characters.

Default Value

N/A.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

branch

Yes

String

Revert target branch

with_new_merge_request

No

Boolean

Whether to revert using the MR creation mode

message

No

String

Commit message

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

id

String

id

message

String

Message

parent_ids

Array of strings

Parent node commit ID

authored_date

String

Time when the branch was created.

author_name

String

Creator name

author_email

String

Creator's email.

committed_date

String

Code commit date and time

committer_name

String

Committer name

committer_email

String

Committer email

open_gpg_verified

Boolean

Whether to enable the GPG verification

verification_status

Integer

Verification status

Value range:

0~1

gpg_primary_key_id

String

Identifier of the GPG public key

name

String

Username

gpg_nick_name

String

Alias

gpg_tenant_name

String

Tenant name

gpg_user_name

String

Information about a specific GPG user

short_id

String

8-character commit ID

created_at

String

Creation time

title

String

Title

author_avatar_url

String

Author profile picture URL

committer_avatar_url

String

Committer profile picture URL

state

String

Use the MR creation mode to revert the result.

cherry_pick_branch_name

String

Temporary name of the cherry-pick branch

revert_branch_name

String

Temporary name of the revert branch

iid

Integer

IID of the change request, which is returned only for the change request.

Value range:

1~2147483647

Status code: 401

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error message.

Example Requests

None

Example Responses

Status code: 200

OK

{
  "id" : "131ef0cb7f641df3590980fa0fb54acb19a573c2",
  "message" : "revert",
  "parent_ids" : [ "ce25367f2d97093130bc7822ef48d1bb5bd18d86" ],
  "authored_date" : "2025-01-22T02:56:21.000Z",
  "author_name" : "example",
  "author_email" : "example@example.com",
  "committed_date" : "2025-01-22T02:56:21.000Z",
  "committer_name" : "example",
  "committer_email" : "example",
  "open_gpg_verified" : null,
  "verification_status" : 0,
  "gpg_primary_key_id" : null,
  "short_id" : "131ef0cb",
  "created_at" : "2025-01-22T02:56:21.000Z",
  "title" : "Create file Source/rusoft/BRD_RU/radiosw/cmake/utiles.cmake",
  "author_avatar_url" : "https://example.com/w3lab/rest/yellowpage/face/30042607/120",
  "committer_avatar_url" : "https://example.com/w3lab/rest/yellowpage/face/30042607/120"
}

Status code: 401

Unauthorized

{
  "error_code" : "DEV.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

OK

401

Unauthorized

Error Codes

See Error Codes.