How to allow public access to a repository via the REST API in Bitbucket

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

In some cases, a Bitbucket Administrator will be required to update the public access of repositories in bulk, and updating via the UI can become tedious and time-consuming.

This task can easily be accomplished by running a cURL command on a REST endpoint.

Solution

Note for personal repositories

The <project-key> will go by the pattern ~username

Example: John Doe (username: jdoe) created a repository named MyRepository.

  • The project-key will be ~jdoe

  • The reposlug will be myrepository

Allow public access to a repository

1 2 3 curl -u <username> --location --request PUT 'https://host:port/rest/api/latest/projects/<project-key>/repos/<reposlug>' \ --header 'Content-Type: application/json' \ --data-raw '{"public": true}'

Deny public access to a repository

1 2 3 curl -u <username> --location --request PUT 'https://host:port/rest/api/latest/projects/<project-key>/repos/<reposlug>' \ --header 'Content-Type: application/json' \ --data-raw '{"public": false}'

Updated on March 18, 2025

Still need help?

The Atlassian Community is here for you.