Help Center/ CodeArts Repo/ API Reference/ APIs/ Project (V2)/ Creating a Project and Forking a Repository
Updated on 2025-01-14 GMT+08:00

Creating a Project and Forking a Repository

Function

After a repository is created, parameters transferred to the fork repository include the repository name, whether to import project members, and home project.

URI

POST /v2/projects/repositories/fork

Request Parameters

Table 1 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 2 Request body parameters

Parameter

Mandatory

Type

Description

import_members

No

Integer

Explanation:

Whether to import project members.

Range:

  • 0: No
  • 1: Yes

project_name

Yes

String

Explanation:

Project name.

Range:

Start with a letter and use only letters, digits, hyphens (-), and underscores (_).

repo_name

Yes

String

Explanation:

Repository name.

Range:

Start with a letter and use only letters, digits, hyphens (-), and underscores (_).

Minimum length: 2

Maximum length: 128

template_id

Yes

String

Explanation:

ID of the template to use.

type

No

String

Explanation:

Project type, such as scrum.

visibility_level

No

Integer

Explanation:

Repository visibility.

Constraints:

None

Range:

  • Private: Only repository members can read, write, and access the repository. Value: 0.
  • Public:
    1. For project members: Project members can view and search for the repository in the repository list of the project and repository group. Value: 10.
    2. For tenant members: Tenant members can view and search for the repository in the repository list of the project and repository group. Value: 10.
    3. For all visitors: All visitors can view and search for the repository in the repository list of the project and repository group. Value: 20.

Default value:

0

external_project_info

No

ExternalKeyMessage object

Explanation:

Third-party service information.

Table 3 ExternalKeyMessage

Parameter

Mandatory

Type

Description

external_key_message

No

String

Explanation:

Key information stored by third parties in CodeArts Repo.

external_service

No

String

Explanation:

External service name.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error.

result

ProjectRepository object

Explanation:

Response result.

status

String

Explanation:

Response status.

Table 5 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

message

String

Explanation:

Error message.

Table 6 ProjectRepository

Parameter

Type

Description

projectUuid

String

Explanation:

Project ID. For details, see Obtaining a Project ID.

Range:

Minimum length: 32

Maximum length: 32

repositoryUuid

String

Explanation:

Repository UUID.

Range:

Minimum length: 32

Maximum length: 32

Example Requests

POST https://{endpoint}/v2/projects/{project_uuid}/repositories/fork

{
  "project_name" : "testworld",
  "repo_name" : "demotest1",
  "template_id" : 453489,
  "import_members" : 0,
  "visibility_level" : 20,
  "type" : "normal"
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "repositoryUuid" : "9a780fd55cd64333b668ba26132629d2",
    "projectUuid" : "278a03286efe45c6b788122bfc166976"
  },
  "status" : "success"
}

Status Codes

Status Codes

Description

200

OK

Error Codes

See Error Codes.