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

Still need help?

The Atlassian Community is here for you.

Ask the community

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.

Environment

Bitbucket Server or Data Center

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

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

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}'

Reference

Further information on https://docs.atlassian.com/bitbucket-server/rest/<bitbucket-server-version>/bitbucket-rest.html


Last modified on Sep 26, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.