Bitbucket Cloud - Check if a pull request has conflicts
Asked by Paolo.Ascari:

Hello, using the Bitbucket ++**CLOUD**++ API:

* Is there a way to check if a pull request has any conflicting files - and if so, obtain a list thereof?

Thanks in advance for any pointers!


Answers:
author: Theodora Boudale
body: Hi Paolo and welcome to the community!

You can use the following API endpoint with the branches of the PR and ++without the **topic** query parameter++

* <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get>

Example:

```
https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/diffstat/feature..main
```

For the conflicted files, you will see in the output the field **"status": "merge conflict"**.

<br />

The **topic** query parameter was introduced last year when we made changes in the diff algorithm we use:

* <https://bitbucket.org/blog/improving-performance-on-complex-diffs>

The status **"merge conflict"** was ++not added++ as a status when the **topic** query is used, because ++we will eventually remove this status++. When we do, we will provide a public conflict API endpoint for customers who use this status for that purpose, to ensure continuity.

Any changes in the API are announced here:

* <https://developer.atlassian.com/cloud/bitbucket/>

Kind regards,  
Theodora

comments: author: Paolo.Ascari
body: Hello Theodora, and thank you for your prompt reply.

This!... Exactly what I was looking for!

But please let me ask you: is there a more comprehensive documentation detailing payloads and responses, including for example the 'status' field that you have mentioned and its possible values?

I have found the API documentation to be fairly basic, to be honest, sometimes with broken links or poorly formatted examples. I guess many things can be discovered through trial-and-error attempts, but it would be nice to have a richer/better documentation to peruse -- and avoid me asking you silly questions... ;)

Cheers, Paolo


author: Theodora Boudale
body: Hi Paolo,

That is the official documentation for our APIs. I just realized I provided the link to the diff endpoint instead of the diffstat, I edited my previous post to correct the URL.

While viewing info for this endpoint, scroll down to the section **Responses** (right below **Example** ) \> select **Paginated Diff Stat**, and a new window will open with details on the fields that are returned from this endpoint:

![Screenshot 2023-05-22 at 10.36.08.png](https://community.atlassian.com/t5/image/serverpage/image-id/258618i59E892C39A83CE89/image-size/large?v=v2&px=999 "Screenshot 2023-05-22 at 10.36.08.png")

<br />

If you scroll down this window, select **Diff Stat** (right below the field **values** ) and you will see more fields documented (including the field **status**).

Please keep in mind that the status "merge conflict" is not documented there, because, as I mentioned, we will eventually remove it (it is also not available when using the **topic** query parameter).

Kind regards,  
Theodora


author: Paolo.Ascari
body: Thank you Theodora

Yes, I was looking for "merge conflict" as a possible value for the **status** field, but now I understand why it's not listed -- hopefully the new public conflict API endpoint will be available soon :)

Cheers,

Paolo


author: Theodora Boudale
body: You are welcome Paolo, please feel free to reach out if you ever need anything else!

Kind regards,  
Theodora


author: Ulrich Kuhnhardt _IzymesCo_
body: Hi [@Paolo.Ascari](/t5/user/viewprofilepage/user-id/5176130) ,

me again :)

There is a Bitbucket cloud API endpoint that **merges** a PR \[1\]. I am not sure if you could swap the POST method with a GET and see if you get the mergeability status?

Would be interesting, I haven't tried this yet.

Best, Ulrich

\[1\] <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-merge-post>


Tags: api

bitbucket-cloud

cloud

conflict

pull-request