1

after reading the doc https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories .

Seems this API is for reading the info of existing repos.

Is there any API for repo creation?

daveruinseverything
  • 4,775
  • 28
  • 40
Luk Aron
  • 1,235
  • 11
  • 34

1 Answers1

0

Check out the POST of repo_slug

/2.0/repositories/{workspace}/{repo_slug}

With:

  • repo_slug string : This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.
  • workspace string : This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

Creates a new repository.

Note: In order to set the project for the newly created repository, pass in either the project key or the project UUID as part of the request body as shown in the examples below:

$ curl -X POST -H "Content-Type: application/json" -d '{
    "scm": "git",
    "project": {
        "key": "MARS"
    }
}' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding

or

$ curl -X POST -H "Content-Type: application/json" -d '{
    "scm": "git",
    "project": {
        "key": "{ba516952-992a-4c2d-acbd-17d502922f96}"
    }
}' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding

The project must be assigned for all repositories. If the project is not provided, the repository is automatically assigned to the oldest project in the workspace.

Note: In the examples above, the workspace ID teamsinspace, and/or the repository name hablanding can be replaced by UUIDs.


For BitBucket server, that would be here, as illustrated in this gist:

/rest/api/1.0/projects/{projectKey}/repos

But V1 API was deprecated in 2018.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250