CreateRepository - Create a repository
Creates a repository through OpenAPI.
Applicable editions | Central edition, Region edition |
Endpoints and authorization information
- Get the endpoint to replace {domain} in the request syntax.
- Get a personal access token.
- Get the organization ID. This parameter is required only for the Central edition. Go to the Basic Information page in the Organization Management console to obtain the organization ID.
Product | Resource | Required permission |
Codeup | Code repository | Read/Write |
Request syntax
Central edition
POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories
Region edition
POST https://{domain}/oapi/v1/codeup/repositories
Request headers
Parameter | Type | Required | Description | Example value |
x-yunxiao-token | string | Yes | Personal access token. | pt-0fh3****0fbG_35af****0484 |
Request parameters
Parameter | Type | Location | Required | Description | Example value |
organizationId | string | path |
| The organization ID. | 60d54f3daccf2bbd6659f3ad |
createParentPath | boolean | query | No | Specifies whether to automatically create the parent path. | true |
| - | object | body | No | ||
| avatarUrl | string | body | No | The repository avatar URL. | https://example/example/w/100/h/100 |
| description | string | body | No | The repository description. A maximum of 65,535 characters. | Description content |
| name | string | body | Yes | The repository name. | demo-repo |
| namespaceId | integer | body | No | The ID of the repository parent path. If it is empty, the repository is created under the organization path. | 2813489 |
| path | string | body | Yes | The repository path. | demo-repo |
| readMeType | string | body | No | The type of README to create automatically: EMPTY - empty, USER_GUIDE - guide README file. | USER_GUIDE |
| repositoryTags | array[string] | body | No | The list of repository tag names. | ["Tag 1", "Tag 2"] |
| templateProject | object | body | No | ||
| syncAllBranches | boolean | body | No | Specifies whether to import all branches of the template repository. | true |
| templateProjectId | integer | body | No | The template repository ID. | 1 |
| templateType | integer | body | No | The template type. 1 - custom template, 2 - system preset template. | 1 |
| visibility | string | body | No | The visibility of the repository: private (private), internal (public within the organization). Valid values: [private internal]. | private |
Request examples
Central edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories?createParentPath=true' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"avatarUrl": "https://example/example/w/100/h/100",
"description": "Description content",
"name": "demo-repo",
"namespaceId": 2813489,
"path": "demo-repo",
"readMeType": "USER_GUIDE",
"repositoryTags": ["Tag 1", "Tag 2"],
"templateProject": {
"syncAllBranches": true,
"templateProjectId": 1,
"templateType": 1
},
"visibility": "private"
}'
Region edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/repositories?createParentPath=true' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"avatarUrl": "https://example/example/w/100/h/100",
"description": "Description content",
"name": "demo-repo",
"namespaceId": 2813489,
"path": "demo-repo",
"readMeType": "USER_GUIDE",
"repositoryTags": ["Tag 1", "Tag 2"],
"templateProject": {
"syncAllBranches": true,
"templateProjectId": 1,
"templateType": 1
},
"visibility": "private"
}'
Response parameters
Parameter | Type | Description | Example value |
| - | object | ||
| accessLevel | integer | The permission type of the current user on this repository. Valid values: [20 30 40]. | 40 |
| archived | boolean | Whether the repository is archived. | false |
| avatarUrl | string | The avatar URL. | https://example/example/w/100/h/100 |
| createdAt | string | The creation time. | 2024-10-05T15:30:45Z |
| creatorId | integer | The repository creator. | 1 |
| creatorUid | string | The repository creator (Yunxiao user ID). | 5f8b3b3b3b3b3b3b3b3b3b3b |
| demoProject | boolean | Whether it is a demo repository. | false |
| description | string | The repository description. | demo repo |
| encrypted | boolean | Whether it is encrypted. | false |
| id | integer | The repository ID. | 2813489 |
| lastActivityAt | string | The last activity time. | 2024-10-05T15:30:45Z |
| name | string | The repository name. | demo-repo |
| nameWithNamespace | string | The full name of the repository (including the full group name). | 60de7a6852743a5162b5f957 / DemoRepo |
| namespaceId | integer | The ID of the parent path. | 2813489 |
| path | string | The repository path. | demo-repo |
| pathWithNamespace | string | The full path of the repository (including the full group path). | 60de7a6852743a5162b5f957/DemoRepo |
| repositorySize | string | The repository size (MB). | 1 |
| repositoryTags | array | The list of repository tags. | |
| - | object | The repository tag. | |
| tagColor | string | The tag color. | #C4C6CF |
| tagName | string | The tag name. | Tag 1 |
| starCount | integer | The number of stars. | 1 |
| starred | boolean | Whether it is starred by the current user. | false |
| updatedAt | string | The last update time. | 2024-10-05T15:30:45Z |
| visibility | string | The visibility: private (private), internal (public within the organization). Valid values: [private internal]. | private |
| webUrl | string | The URL for page access. | http://example.com/org-demo/example-repo |
Response example
{
"accessLevel": 40,
"archived": false,
"avatarUrl": "https://example/example/w/100/h/100",
"createdAt": "2024-10-05T15:30:45Z",
"creatorId": 1,
"creatorUid": "5f8b3b3b3b3b3b3b3b3b3b3b",
"demoProject": false,
"description": "demo repo",
"encrypted": false,
"id": 2813489,
"lastActivityAt": "2024-10-05T15:30:45Z",
"name": "demo-repo",
"nameWithNamespace": "60de7a6852743a5162b5f957 / DemoRepo",
"namespaceId": 2813489,
"path": "demo-repo",
"pathWithNamespace": "60de7a6852743a5162b5f957/DemoRepo",
"repositorySize": "1",
"repositoryTags": [
{
"tagColor": "#C4C6CF",
"tagName": "Tag 1"
}
],
"starCount": 1,
"starred": false,
"updatedAt": "2024-10-05T15:30:45Z",
"visibility": "private",
"webUrl": "http://example.com/org-demo/example-repo"
}
Error codes
For more information about API error codes, see the Error Code Center.