Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to enable “branch deletion on merge” for Bitbucket projects via REST API


How to enable “branch deletion on merge” for Bitbucket projects via REST API?

Screen Shot 2022-08-11 at 9.15.39 PM.png

2 answers

1 accepted

0 votes
Answer accepted

I found the answer:


Bitbucket Server 7.15

Branch deletion on merge

New Java and REST API methods have been added to configure Branch deletion on merge for Project and Repository.

DeleteAfterMergeConfigurationService.deleteConfiguration(scope), DeleteAfterMergeConfigurationService.getConfiguration(scope) and DeleteAfterMergeConfigurationService.setConfiguration(DeleteAfterMergeConfigurationRequest) introduce the ability to configure Branch deletion on merge feature.

New REST endpoints:


  • GET /rest/branch-utils/latest/projects/{key}/delete-after-merge

get if the feature is enabled for a Project.

  • POST /rest/branch-utils/latest/projects/{key}/delete-after-merge

enable or disable the feature for a Project.


  • GET /rest/branch-utils/latest/projects/{key}/repos/{slug}/delete-after-merge

get if the configuration is enabled for a Repository.

  • POST /rest/branch-utils/latest/projects/{key}/repos/{slug}/delete-after-merge

enable or disable the configuration for a Repository.

  • DELETE /rest/branch-utils/latest/projects/{key}/repos/{slug}/delete-after-merge

delete the configuration for a Repository.

In order to enable “branch deletion on merge” for Bitbucket projects via REST API, you will need to make a PUT request to the following endpoint:


In the request body, you will need to specify the following JSON:

"deleteOnMerge": true

Where {projectKey} is the key of the Bitbucket project and {repositorySlug} is the slug of the repository.

If the request is successful, the response will return a 204 status code.

Thanks. It did not work. I got a 404 status code.

404 status code means the endpoint could not be found. Check the project key and repository slug to make sure they are correct.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,499 views 3 10
Read article

Atlassian Community Events