Updated on 2025-03-28 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 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.

Constraints:

None

Range:

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

Default value:

0

name

Yes

String

Explanation:

Repository name.

Constraints:

Mandatory

Range:

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

Default value:

None

project_uuid

Yes

String

Explanation:

Project ID.

Constraints:

Mandatory

Range:

32 characters.

Default value:

None

template_id

No

String

Explanation:

Template ID.

Constraints:

None

Range:

Character string

Default value:

None

visibility_level

No

Integer

Explanation:

Repository visibility.

Constraints:

None

Range:

  • 0: Private
  • 20: Public

Default value:

0

import_url

No

String

Explanation:

Base64-encoded HTTPS address of the template repository.

Constraints:

None

Range:

10–512 characters.

Default value:

None

description

No

String

Explanation:

Repository description.

Constraints:

None

Range:

[0-2000]

Default value:

None

gitignore_id

No

String

Explanation:

.gitignore file generated based on the programming language.

Constraints:

None

Range:

Actionscript,Ada,Agda,Android,Ansible,AppceleratorTitanium,AppEngine,ArchLinuxPackages,Autotools,C#,C++,C,CakePHP,CFWheels,ChefCookbook,Clojure,CMake,CodeIgniter,CommonLisp,Composer,Concrete5,Coq,CraftCMS,CUDA,D,Dart,Delphi,DM,Dreamweaver,Dropbox,Drupal,Eagle,Eclipse,Elisp,Elixir,Elm,Emacs,EPiServer,Erlang,ExpressionEngine,ExtJs,Fancy,Finale,ForceDotCom,Fortran,FuelPHP,Gcov,GitBook,Go,Godot,GPG,Gradle,Grails,GWT,Haskell,Idris,IGORPro,Java,JavaScript,Jboss,Jekyll,JetBrains,Joomla,Julia,KiCad,Kohana,Kotlin,LabVIEW,Laravel,Leiningen,LemonStand,Lilypond,Lithium,Lua,Magento,Maven,Mercury,MetaProgrammingSystem,Nanoc,NetBeans,Nim,Node,NotepadPP,Objective-C,OCaml,Opa,OpenCart,OracleForms,Packer,Perl,Phalcon,PlayFramework,Plone,Prestashop,Processing,PureScript,Python,Qooxdoo,Qt,R,Rails,RhodesRhomobile,ROS,Ruby,Rust,Sass,Scala,Scheme,SCons,Scrivener,Sdcc,SeamGen,SketchUp,Smalltalk,Stella,SublimeText,SugarCRM,SVN,Swift,Symfony,SymphonyCMS,Terraform,TeX,Textpattern,TortoiseGit,TurboGears2,Typo3,Umbraco,Unity,UnrealEngine,VisualStudio,VisualStudioCode,VVVV,Waf,WordPress,Xojo,Yeoman,Yii,ZendFramework,Zephir

Default value:

None

license_id

No

Integer

Explanation:

Open-source license ID.

Constraints:

None

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:

None

enable_readme

No

Integer

Explanation:

Whether to generate a README file.

Constraints:

None

Range:

  • true: Yes
  • false: No

Default value:

None

caller

No

String

Explanation:

Caller.

Constraints:

None

Range:

Character string

Default value:

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error.

result

Repository object

Explanation:

Response result.

status

String

Explanation:

Response status.

Range:

  • success
  • fail
Table 4 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

See Error Codes.

message

String

Explanation:

Error message.

Range:

Character string

Table 5 Repository

Parameter

Type

Description

repository_uuid

String

Explanation:

Project ID.

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 Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.