Updated on 2026-01-08 GMT+08:00

Adding a Tag

Description

This API is used to add a tag.

URI

POST /v2/repositories/{repository_id}/tags

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Repository primary key ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

tag_name

Yes

String

Tag name

ref

Yes

String

Branch name

message

No

String

Remarks

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error

result

AddTagsResponse object

Response result

status

String

Response status

Table 5 Error

Parameter

Type

Description

code

String

Error Codes

message

String

Error message

Table 6 AddTagsResponse

Parameter

Type

Description

name

String

Tag name

message

String

Remarks

commit

CommitRepoV2 object

Commit message

Table 7 CommitRepoV2

Parameter

Type

Description

id

String

SHA ID of a commit

short_id

String

Short SHA ID of a commit

created_at

String

Creation time

title

String

Commit title

parent_ids

Array of strings

Parent commit ID

message

String

Commit message

author_name

String

Author

committer_name

String

Committer

committed_date

String

Commit time

Request Examples

POST https://{endpoint}/v2/repositories/{repository_id}/tags

{
  "tag_name" : "test20220920",
  "ref" : "master",
  "message" : "test20220920"
}

Response Examples

Status code: 200

Request succeeded

{
  "result" : {
    "name" : "test_tag_name",
    "message" : "test message",
    "commit" : {
      "id" : "3b68902cf0eb7de3d5c8757e4a990bc3fe0af349",
      "short_id" : "3b68902c",
      "created_at" : "2022-03-08T03:14:39.000Z",
      "title" : "Create a File",
      "parent_ids" : [ "08618c900a4048aae7e4cd88913d3d521eae02eb" ],
      "message" : "Create a file",
      "author_name" : "repo",
      "committer_name" : "repo",
      "committed_date" : "2022-03-08T03:14:39.000Z"
    }
  },
  "status" : "success"
}

Status Codes

Status Codes

Description

200

Request succeeded

Error Codes

See Error Codes.