Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Repo creation using api Edited

In a project with  project key say XXX, is there an api call that can be made to create the repo named "test"? We are currently on bitbucket data center

1 answer

0 votes
Mikael Sandberg Community Leader Nov 04, 2020

You can use /rest/api/1.0/projects/{projectKey}/repos post to create a new repository. The authenticated user must have project admin permissions in the project you want to create the repository.

Thanks Mikael for the response. Would the entire command be something like this (tried couple options and didnt work yet)

 

curl -s -u username:password -k --header "Content-Type: application/json" -X PUT"Content-Type: application/json" -X PUT "https://bitbucket.xxx.xxx/rest/api/1.0/projects/CR/repos/testtest"

CR is the project key and testtest is the name of the repos

Mikael Sandberg Community Leader Nov 04, 2020

From what I can see from the documentation you also have to include scmId which should be set to git. Here is the example in the guide:

{
    "name": "My repo",
    "scmId": "git",
    "forkable": true,
    "defaultBranch": "main"
}

Default branch and workable are optional. 

Sorry to hijack this thread, but this is not working for me as I expect it to.

curl - u username:password http://bitbucket.domains/rest/api/1.0/projects/PROJECT/repos/toplevel -H 'Content-Type: application/json' -d '{"name": "newrepo", "scmID": "git"}'

 

Instead creates a repo here:

/rest/api/1.0/projects/~USERNAME/repos/newrepo

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,589 views 1 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you