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

Is it possible to fork a repository with Bitbucket API?

sotayamashita November 12, 2017

I would like to fork a repository with Bitbucket API like GitHub has. https://developer.github.com/v3/repos/forks/#create-a-fork. Is it possible?

 

Thanks in advance.

 

2 answers

0 votes
Thomas Barrett October 21, 2019

API v2 for documentation:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/forks

Overview of solution is to POST to the /repo/forks/ endoint

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 12, 2017
sotayamashita November 13, 2017

I appreciate your answer but they talked about old API version in the thread and I cannot find the same one in new API version below:

https://developer.atlassian.com/bitbucket/api/2/reference/

Adam Hughes November 1, 2022

The 2.0 documentation is here but the POST body seems complicated.  Would really like some actual examples... ie what are the minimum required fields?

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-post

I was able to figure this out using chrome tools while creating a fork from the BB UI.   Here is a minimal example:

Imagine I have a repo `foo` in workspace `myspace`.  And I want to fork it into `foo-fork` in the same workspace.  The request is

POST {{BB_API}}/repositories/myspace/myspace/forks

{
  "is_private": true,
  "scm": "git",
  "name": "foo-fork",
  "workspace":{
      "slug":"myspace"
  }
}

 

Like ccenvcvb likes this
venkatesh vp August 31, 2023

Thank you!

Can you provide a full template as an example. 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events