Help Center/ CodeArts Repo/ API Reference/ APIs/ V4/ Repository/ Modifying the General Policies of a Repository
Updated on 2026-04-28 GMT+08:00

Modifying the General Policies of a Repository

Function

This API is used to modify the general policies of 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}/general-policy

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

disable_fork

No

Boolean

Definition:

Whether to forbid to fork this repository.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

Default value:

N/A.

generate_pre_merge_ref

No

Boolean

Definition:

Whether to pre-merge MRs.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

Default value:

N/A.

branch_name_regex

No

String

Definition:

Branch name rule.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

tag_name_regex

No

String

Definition:

Tag name rule.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

forbidden_developer_create_branch

No

Boolean

Definition:

Whether to forbid developers to create branches.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

create_branch_whitelist_user_ids

No

String

Definition:

A whitelist of developers who have the permission to create branches. Separate their IDs using commas (,).

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

disable_fork

Boolean

Definition:

Whether to forbid to fork this repository.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

Default value:

N/A.

generate_pre_merge_ref

Boolean

Definition:

Whether to pre-merge MRs.

Constraints:

N/A.

Value range:

  • true: Pre-merge MRs are not allowed.

  • false: Pre-merge MRs are allowed.

Default value:

N/A.

branch_name_regex

String

Definition:

Branch name rule.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

tag_name_regex

String

Definition:

Tag name rule.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

forbidden_developer_create_branch

Boolean

Definition:

Whether to forbid developers to create branches.

Constraints:

N/A.

Value range:

  • true: Yes.

  • false: No.

create_branch_whitelist_users

Array of PushRuleDevelopersDto objects

Definition:

A whitelist of developers who have the permission to create branches.

Table 5 PushRuleDevelopersDto

Parameter

Type

Description

id

AnyType

Definition:

Primary key ID.

Value range:

1~2147483647

user_id

AnyType

Definition:

User ID.

Value range:

1~2147483647

user_name

AnyType

Definition:

Username.

nick_name

String

Definition:

Alias.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

tenant_name

String

Definition:

Tenant name.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Example Requests

This API is used to modify the general policies of a repository.

PUT /v4/repositories/123/general-policy

{
  "disable_fork" : true,
  "generate_pre_merge_ref" : true,
  "branch_name_regex" : "^[0-9]*$",
  "tag_name_regex" : "^[0-9]*$",
  "forbidden_developer_create_branch" : true,
  "create_branch_whitelist_user_ids" : "9458,1234"
}

Example Responses

Status code: 200

General policies of a repository.

{
  "disable_fork" : true,
  "generate_pre_merge_ref" : true,
  "branch_name_regex" : "^[0-9]*$",
  "tag_name_regex" : "^[0-9]*$",
  "forbidden_developer_create_branch" : true,
  "create_branch_whitelist_users" : [ {
    "id" : "198,",
    "user_id" : "9458,",
    "user_name" : "test_01",
    "nick_name" : "test_01",
    "tenant_name" : "test"
  }, {
    "id" : "198,",
    "user_id" : "1234,",
    "user_name" : "test_02",
    "nick_name" : "test_02",
    "tenant_name" : "t"
  } ]
}

Status Codes

Status Code

Description

200

General policies of a repository.

Error Codes

See Error Codes.