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

Viewing the General Policies of a Repository

Function

This API is used to view the general policies of the repository.

Debugging

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

Authorization Information

Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

codeartsrepo:repository:getRepository

Read

-

-

-

-

URI

GET 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

Default Value

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 one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token.

Constraints

N/A

Range

1–100,000 characters.

Default Value

N/A

Response Parameters

Status code: 200

Table 3 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 4 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

None

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"
  } ]
}

Status Codes

Status Code

Description

200

General policies of a repository.

Error Codes

See Error Codes.