REST API to disable fork


Is there any REST API call to disable the fork for a repository in Bitbucket cloud ?

Thanks !

Welcome to the Atlassian developer community, @KotaSreenivasaShrava.

Yes, you can disable fork on a repository using PUT /2.0/repositories/{workspace}/{repo_slug}. You will need to send an attribute for fork_policy like:

  fork_policy: no_forks

The options come from the following enumeration:

  • allow_forks : unrestricted forking
  • no_public_forks : restrict forking to private forks (forks cannot be made public later)
  • no_forks : deny all forking
1 Like

Hi - Thanks for quick reply. I am executing this and its not working. Am I doing anything wrong?

curl --request PUT --user username:apppassword --data ā€˜{fork_policy: no_forks}ā€™

Could you share the response?

There was no response. It exits without any error or success message

I realized the example that I provided you isnā€™t valid JSON. Iā€™m not sure how I forgot the double quotes:

  "fork_policy": "no_forks"

However, I tried with both double quotes and without and I still get a response from Bitbucket. It sounds like something is blocking your network access to the Bitbucket API.