Updated on 2026-01-27 GMT+08:00

Creating a Repository

Function

This API is used to create a repository on a specified project with the specified name. Input parameters: repository name, template ID, whether to import project members, and home project

URI

POST /v1/repositories

Request Parameters

Table 1 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation:

User token. It can be obtained by calling the corresponding Obtaining a User Token. The value of X-Subject-Token in the response header is the user token.

Constraints:

N/A

Range:

1–100,000 characters.

Default value

N/A

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

import_members

No

Integer

Explanation:

Whether to import project members.

Constraints:

N/A

Range:

  • 0: Do not import project members.
  • 1: Import project members.

Default value

0

name

Yes

String

Explanation:

Repository name.

Constraints:

Start with a letter, digit, or underscore (_), and use letters, digits, hyphens (-), underscores (_), and periods (.). Do not end with .git, .atom, or a period (.).

Range:

The value is a string of 1 to 256 characters.

Default value

N/A

project_uuid

Yes

String

Explanation:

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

N/A

Range:

32 digits and letters.

Default value

N/A

template_id

No

String

Explanation:

Template ID.

Constraints:

N/A

Range:

N/A

Default value

N/A

visibility_level

No

Integer

Explanation:

Repository visibility.

Constraints:

N/A

Range:

  • 0: Private

Default value

0

import_url

No

String

Explanation:

Base64 code of the HTTPS address of the template repository.

Constraints:

N/A

Range:

The value is a string of 10 to 512 characters.

Default value

N/A

description

No

String

Explanation:

Repository description.

Constraints:

N/A

Range:

The value is a string of 0 to 2,000 characters.

Default value

N/A

gitignore_id

No

String

Explanation:

.gitignore file generated based on the programming language.

Constraints:

N/A

Range:

For details about the available languages, see gitignore file template languages.

Default value

N/A

license_id

No

Integer

Explanation:

Open-source license ID.

Constraints:

N/A

Range:

  • 1: Apache_License_v2.0
  • 2: MIT_License, BSD_3Clause
  • 3: Eclipse_Public_License_v1.0
  • 4: BSD_2Clause
  • 5: GNU_General_Public_License_v2.0
  • 6: GNU_General_Public_License_v3.0
  • 7: GNU_Affero_General_Public_License_v3.0
  • 8: GNU_Lesser_General_Public_License_v2.1
  • 9: GNU_Lesser_General_Public_License_v3.0
  • 10: Mozilla_Public_License_v2.0
  • 11: The_Unlicense

Default value

N/A

enable_readme

No

Integer

Explanation:

Whether to generate a README file.

Constraints:

N/A

Range:

  • true: Create a repository.
  • false: Do not create a repository.

Default value

N/A

caller

No

String

Explanation:

API caller, that is, repository creator.

Constraints:

N/A

Range:

N/A

Default value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error code.

Range:

N/A

result

Repository object

Explanation:

Response result.

Range:

N/A

status

String

Explanation:

Response status.

Range:

  • success: The API call is successful.
  • failed: The API call failed.
Table 4 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

Max. 100 characters in the error code format.

message

String

Explanation:

Error message.

Range:

N/A

Table 5 Repository

Parameter

Type

Description

repository_uuid

String

Explanation:

Repository UUID.

Range:

32 characters.

Example Requests

POST https://{endpoint}/v1/repositories

{
	"project_uuid": "4838955a48e2492bbe44b31bc4c272f6", 
	"name": "demotest1", 
	"import_members": "0", 
	"visibility_level": "20", 
 }

Example Responses

Status code: 200

OK

{
  "result" : {
    "repository_uuid" : "d161fd00d9194816a455cb3c1d6a783e"
  },
  "status" : "success"
}

Status Code

Status Code

Description

200

OK

Error Codes

See Error Codes.