Help Center/ CodeArts Repo/ API Reference/ APIs/ Repository/ Creating a Protected Tag

Creating a Protected Tag

Updated on 2025-05-15 GMT+08:00

Function

This API is used to create a tag protection rule.

URI

POST /v2/repositories/{repository_id}/protected-tags

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Explanation:

Repository primary key ID.

Constraints:

Mandatory

Range:

1–2147483647

Default value:

None

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation:

User token. It can be obtained by calling the corresponding IAM API. The value of X-Subject-Token in the response header is the user token.

Constraints:

Mandatory

Range:

1–100,000 characters.

Default value:

None

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

No

String

Explanation:

Tag protection rule, which corresponds to tag name on the console.

Constraints:

None

Range:

1–500 characters. Do not use spaces.

Default value:

None

create_access_level

No

Integer

Explanation:

Permissions for creating protected tags.

Constraints:

None

Range:

  • 0: No one is allowed to create tags defined by this rule.
  • 30: Developers, committers, the project manager, and the administrator can create tags defined by this rule.
  • 40: The project manager and administrator can modify or delete tags defined by this rule.

Default value:

None

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error.

result

AddProtectTagResponse object

Explanation:

Response result.

status

String

Explanation:

Response status.

Range:

  • success: The tag protection rule is successfully created.
  • fail: The tag protection rule fails to be created.
Table 5 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

See Error Codes.

message

String

Explanation:

Error message.

Range:

Character string.

Table 6 AddProtectTagResponse

Parameter

Type

Description

name

String

Explanation:

Tag protection rule, which corresponds to tag name on the console.

Range:

1–500 characters.

create_access_levels

CreateAccessLevels object

Explanation:

Permissions for protected tags.

Table 7 CreateAccessLevels

Parameter

Type

Description

access_level

Integer

Explanation:

Permissions for creating protected tags.

Range:

  • 0: No one is allowed to create tags defined by this rule.
  • 30: Developers, committers, the project manager, and the administrator can create tags defined by this rule.
  • 40: The project manager and administrator can create tags defined by this rule.

access_level_description

String

Explanation:

Permission description.

Range:

  • Maintainers: project manager and administrator
  • Developers + Committer + Maintainers: developers, committers, project manager, and administrator
  • No one: none

Example Requests

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

{
  "name" : "test",
  "create_access_level" : 40
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "name" : "test",
    "create_access_levels" : {
      "access_level" : 40,
      "access_level_description" : "Maintainers"
    }
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback