Using Bitbucket REST API to get list of merged pull requests for a specific source and destination branches.
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
Applying a filter to pull request API helps us retrieve the list of merged pull requests for a specific source and destination branches.
Solution
API to be used:
curl -s -u <EMAIL>:<API_TOKEN> "https://api.bitbucket.org/2.0/repositories/<WORKSPACE_ID>/<REPO_SLUG>/pullrequests?q=destination.branch.name+%3D+%22<dst_branch>%22&source.branch.name+%3D+%22<src_branch>%22&fields=values.id,values.state"
Variables to be replaced by:
<EMAIL>: Your Atlassian account email address
<API_TOKEN>: An API token for this account that has at least the scope of read:pullrequest:bitbucket
<WORKSPACE_ID>: The ID of the workspace
<REPO_SLUG>: The slug of the repository
Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-group-pullrequests Reference: API filtering - Atlassian Documentation
Example:
Sample Query:
curl -s -u user@example.com:ATBB*********** "https://api.bitbucket.org/2.0/repositories/testwork/testrepo/pullrequests?q=destination.branch.name+%3D+%22dev%22&source.branch.name+%3D+%22master%22&fields=values.id,values.state"
Output:
{"values": [
{"id": 1, "state": "MERGED"}
]}%
Updated on September 3, 2025
Was this helpful?
Still need help?
The Atlassian Community is here for you.