Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Source branch not deleted after merge with API

Looking at the REST API documentation setting close_source_branch:true should delete the source branch after a Pull request has been merged.


I create a new branch with changes:

curl -sk -X POST -u 'user:pass' --url '' -F "message=testing rest $(date) [skip ci]" -F 'branch=feature/rest-test' -F 'parents=develop' -F '/documents/config-file-one.yml=@a' -F '/documents/config-file-new.yml=@a'

I validate this works on the BB GUI, next I create the PR:

curl -sk -X POST -u 'user:pass' --url '' -H 'Content-Type: application/json' --data '{"close_source_branch":true,"description":"automated process to update config files via REST","destination":{"branch":{"name":"develop"}},"source":{"branch":{"name":"feature/rest-test"}},"title":"Update config files date","type": "pullrequest"}' | jq .
"rendered": {
"description": {............

I also verify that the PR was created with the delete branch option

 curl -sk -X GET -u 'user:pass' --url '' | jq .close_source_branch

So I expect that when I merge the PR it will delete feature/rest-test

 curl -sk -X POST -u 'user:pass' --url '' | jq .
"rendered": {
"description": {

However it is not deleted :(

I am not sure what I am doing incorrectly so that it is not deleting.


2 answers

1 accepted

0 votes
Answer accepted

I have also tried adding the close_source_branch to the merge:

curl -ski -X POST -u 'user:pass' --url '' --data '{"close_source_branch":true,"type":"pullrequest"}'

and it does not help.

The above does work if you remember to include

Content-Type: application/json 

in the headers ;)

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,784 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you