Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to watch a Bitbucket repo (Pushes, All branches) using Bitbucket Data Center Rest API

Daniel Villeneuve May 8, 2025

Hi all.  My team has tens of developers managing hundreds of repos with lots of branches, and we expect to receive email notifications on pushes for all branches.

Manually selecting a repo, clicking on watch and configuring it is inefficient when considering lots of repos.

There seems to be an API for that: (https://developer.atlassian.com/server/bitbucket/rest/v906/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-watch-post).

However, using this service does not turn the repo icon "watch" into "watching" (as it would do when using the web interface), the documentation does not tell how to specify which set of branches to watch, and the repo does not show up in the user profile under "watched repositories".

The body for this POST request does not seem aligned with what needs to be provided in the web page.

Is it actually possible to programmatically set "watch/pushes/all branches" for a repo?

With this, we would script a loop over relevant collections of repos and be efficient at configuring Bitbucket.

Regards
Daniel Villeneuve

1 answer

0 votes
Daniel Villeneuve May 9, 2025

Finally, I've found the following HTTP service: PUT /rest/notification/latest/watch/projects/$project/repos/$repo with the following JSON body:

{ "pushNotificationScope": "ALL", "pullRequestNotificationScope": "ALL" }


where other possible values are "NONE", and "DEFAULT_BRANCH" for push and "STATE_CHANGES" for pull.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events