Can I merge two branches via API call without pull request

Obviously I can go through the website and do a compare branches or tags to see the differences in branches, from there I can click the merge button to merge the two branches. Am I able to do this via the rest API?

I see this using pullrequests:

http://example.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge [POST, GET]

However we do not use pull requests for this so I am looking to just merge branches via the rest API.

Thanks for the help.

1 Like

Hey @travisw,

Quick question: are you using Bitbucket Cloud or Server?

We are using Bitbucket Server

Hey @travisw,
Merging a git branch via the REST API is indeed not possible.

But there might be a solution out there for you,
You said that you don’t use the Pullrequests so what if we do only use it via the REST API?

So we could create a pullrequest with branch A and B via the REST API, and merge this pullrequest. You need to make sure no approvers are needed or builds (this is done in the settings). Merge the pullrequest hence merging Branch A into Branch B.
And if you want to you possibly delete the pullrequest afterwards.
Here are the docs related to PR’s
Here are some docs about the PR REST api
REST Resources Provided By: Bitbucket Server - REST

1 Like

Hi! Can you solve this problem now? I have the same problem now!:sob::sob::sob: