Help Center/ CodeArts Repo/ API Reference/ APIs/ V2Project/ Create projects and repositories.
Updated on 2023-09-12 GMT+08:00

Create projects and repositories.

Function

After a project is created, the parameters for creating a warehouse group are generated in the background. The parameters include the warehouse name, template ID, whether to import project members, and home project.

URI

POST /v2/projects/repositories

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

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

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

import_members

No

Integer

Indicates whether to import project members. The options are as follows: 0->Do not import project members; 1->Import project members

project_name

Yes

String

Project name. The options are as follows: The value can contain uppercase letters, lowercase letters, digits, hyphens (-), and underscores (_), and must start with a letter.

repo_name

Yes

String

Repository name. The options are as follows: The value can contain uppercase letters, lowercase letters, digits, hyphens (-), and underscores (_), and must start with a letter.

Minimum: 2

Maximum: 128

type

No

String

Project type. The options are normal and scrum.

visibility_level

No

Integer

Whether the warehouse is a public warehouse

external_project_info

No

ExternalKeyMessage object

Third-party service information

Table 3 ExternalKeyMessage

Parameter

Mandatory

Type

Description

external_key_message

No

String

Key information stored by third parties in code hosting

external_service

No

String

External Service Name

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error.

result

ProjectRepository object

Result

status

String

Status code in a response

Table 5 Error

Parameter

Type

Description

code

String

Error Codes

message

String

Error message

Table 6 ProjectRepository

Parameter

Type

Description

projectUuid

String

Specifies the UUID of the created project.

Minimum: 32

Maximum: 32

repositoryUuid

String

UUID of the repository to be created.

Minimum: 32

Maximum: 32

Example Requests

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

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

Example Responses

Status code: 200

OK

{
  "result" : {
    "repositoryUuid" : "02637c34ba954ab5bd37ff9537fe05b4",
    "projectUuid" : "1aeda7a6070d4119b7d8b45e5641599b"
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.