Help Center/ CodeArts Repo/ API Reference/ APIs/ V4/ ProtectedRefs/ Updating Protected Tags in Batches in a Repository
Updated on 2026-04-28 GMT+08:00

Updating Protected Tags in Batches in a Repository

Function

This API is used to update protected tags in batches in a repository.

Debugging

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

URI

PUT https://{hostURL}/v4/repositories/{repository_id}/protected-tags

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

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

names

Yes

Array of strings

Definition:

Protected tag name or wildcard list.

Constraints:

Mandatory.

Value range:

N/A.

Default value:

N/A.

actions

No

Array of RepositoryProtectedTagActionBodyDto objects

Definition:

Permissions.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 4 RepositoryProtectedTagActionBodyDto

Parameter

Mandatory

Type

Description

enable

No

Boolean

Definition:

Whether to enable.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

Default value:

N/A.

Default value:

true

user_ids

No

Array of integers

Definition:

User ID list.

Constraints:

N/A.

Value range:

Integer

Default value:

N/A.

Value range:

1~2147483647

user_team_ids

No

Array of integers

Definition:

Member group ID list.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Value range:

1~2147483647

related_role_ids

No

Array of strings

Definition:

Associated role ID list.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

action

No

String

Definition:

Event name.

Constraints:

N/A.

Value range:

  • create: Create.

Default value:

N/A.

Enumeration values:

  • create

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

[items]

Array of RepositoryProtectedTagDto objects

Protected tag list in a repository.

Table 6 RepositoryProtectedTagDto

Parameter

Type

Description

id

Integer

Definition:

Protection tag ID.

Value range:

1–2147483647

name

String

Definition:

Branch name or wildcard.

Value range:

N/A.

actions

Array of RepositoryProtectedActionDto objects

Definition:

Event list.

Value range:

N/A.

Table 7 RepositoryProtectedActionDto

Parameter

Type

Description

action

String

Definition:

Event name.

Value range:

N/A.

enable

Boolean

Definition:

Whether to enable.

Value range:

  • true: Yes.

  • false: No.

users

Array of RepositoryUserDto objects

Definition:

Whitelisted user list.

Value range:

N/A.

user_teams

Array of UserTeamBasicDto objects

Definition:

Whitelisted user group list.

Value range:

N/A.

roles

Array of BasicRoleDto objects

Definition:

Whitelisted role list.

Value range:

N/A.

Table 8 RepositoryUserDto

Parameter

Type

Description

id

Integer

Definition

User ID.

Value range:

1~2147483647

name

String

Definition

Username.

username

String

Definition

Username.

state

String

Definition:

User status

Value range:

  • active: activated

  • blocked: disabled

Enumeration values:

  • active

  • blocked

avatar_url

String

Definition:

Profile picture URL.

Value range:

N/A.

nick_name

String

Definition:

User alias.

Value range:

N/A.

tenant_name

String

Definition:

Tenant name.

Value range:

N/A.

Table 9 UserTeamBasicDto

Parameter

Type

Description

id

Integer

Definition:

User group ID.

Value range:

1–2147483647

name

String

Definition:

User group name.

Value range:

N/A.

Table 10 BasicRoleDto

Parameter

Type

Description

id

Integer

Definition:

Role ID.

Value range:

1–2147483647

name

String

Definition:

Role name.

Value range:

N/A.

related_role_id

String

Definition:

Associated role ID.

Value range:

N/A.

chinese_name

String

Definition:

Role name in Chinese.

Value range:

N/A.

Example Requests

Update protected tags in batches in a repository.

PUT /v4/repositories/123/protected-tags

{
  "names" : [ "ttt6", "ttt5" ],
  "actions" : [ {
    "action" : "create",
    "enable" : true,
    "user_ids" : [ 9124 ],
    "user_team_ids" : [ 251 ],
    "related_role_ids" : [ "Administrator" ]
  } ]
}

Example Responses

Status code: 200

Protected tag list in a repository.

[ {
  "id" : 124607,
  "name" : "ttt7",
  "actions" : [ {
    "action" : "create",
    "enable" : true,
    "users" : [ {
      "id" : 9087,
      "name" : "test11",
      "username" : "04ef19ad5eaf4b8c9cf2451d3536202d",
      "state" : "blocked",
      "avatar_url" : "",
      "nick_name" : "",
      "tenant_name" : "t1"
    }, {
      "id" : 9090,
      "name" : "test3",
      "username" : "ba1bd837aa09470ba4ccf0cebb837f89",
      "state" : "blocked",
      "avatar_url" : "",
      "nick_name" : "",
      "tenant_name" : "t1"
    }, {
      "id" : 9093,
      "name" : "test444",
      "username" : "a225d72a70df46c3a15915285be1eeb3",
      "state" : "blocked",
      "avatar_url" : "",
      "nick_name" : "",
      "tenant_name" : "t1"
    } ],
    "user_teams" : [ {
      "id" : 247,
      "name" : "team-1"
    } ],
    "roles" : [ {
      "id" : 23836595,
      "name" : "Administrator",
      "related_role_id" : "7a96af96176e4f728f571b8af8551dec",
      "chinese_name" : "Project administrator"
    }, {
      "id" : 23836597,
      "name" : "Test manager",
      "related_role_id" : "24f72d0b611746c3a43da596ea5065f5",
      "chinese_name" : "Test manager"
    }, {
      "id" : 23836612,
      "name" : "customer_role_1",
      "related_role_id" : "31bcd56943f0491fbc2f410d163f70cc",
      "chinese_name" : "customer_role_1"
    } ]
  } ]
} ]

Status Codes

Status Code

Description

200

Protected tag list in a repository.

Error Codes

See Error Codes.