pullrequests Resource

Overview

Manage pull requests for a Bitbucket Cloud repository. Use this resource to perform CRUD (create/read/update/delete) operations on a pull request. This resource allows you to manage the attributes of a pull request also. For example, you can list the commits or reviewers associated with a pull request. You can also accept or decline a pull request with this resource. Finally, you can use this resource to manage the comments on a pull request as well.

FieldDescription
stateThe pull request's current status. The status is either open, rejected, or fulfilled.
descriptionDescription field for the request.
linksAn map of links pointing to other representation and related data and functionality.
titleTitle of the pull request.
task_countThe number of open tasks for a specific pull request.
comment_countThe number of comments for a specific pull request.
close_source_branchA boolean flag indicating if merging the pull request closes the source branch.
destinationA structure containing the commit, branch and repository structures associated with the request destination repository.
reasonExplains why a pull request was declined. This field is only applicable to pull requests in rejected state.
idThe pull request's unique ID. Note that pull request IDs are only unique within their associated repository.
sourceA structure containing the commit , branch , and repository structures associated with the request source repository.
created_onDate the request was created.
authorThe user who created the pull request.
updated_onDate the request was last updated.
merge_commitThe merge commit object that was created when the pull request was accepted. This is only applicable to pull requests that are in fulfilled state.
closed_byThe user that closed the request.
reviewersThe list of users that were added as reviewers on this pull request when it was created. For performance reasons, the API only returns this list when an API requests a pull request by id.
participants

The list of users that are collaborating on this pull request. Collaborators are user that:

  • are added to the pull request as a reviewer (part of the reviewers list)
  • are not explicit reviewers, but have commented on the pull request
  • are not explicit reviewers, but have approved the pull request

Each user is wrapped in an object that indicates the user's role and whether they have approved the pull request. For performance reasons, the API only returns this list when an API requests a pull request by id.

GET a list of open pull requests

Get a list of of a repository's open pull requests.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.

This returns a paginated list of pull request objects. Note that the participants list is not included in the pull requests. To obtain the full list of participants, follow the pull requests's self link.

By default, only the open pull requests are returned. Use the state query parameter to access declined (state=DECLINED), open (state=OPEN) or merged (state=MERGED). The state parameter can be repeated (comma separated) to include pull requests in different states.

GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests?state=[OPEN, MERGED, DECLINED]
Click here to expand...
{
    "pagelen": 1,
    "next": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests?pagelen=1&page=2",
    "values": [{
        "description": "![img](https://cloudup.com/c7ZJtChLw9J+)\r\n\r\n## Removing:\r\n\r\n* Notifications\r\n* Email\r\n* Change password\r\n* Sessions\r\n\r\n## Renaming: \r\n\r\n* Change username\r\n* Delete account (rename to delete team)\r\n\r\n",
        "links": {
            "decline": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/decline"
            },
            "commits": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/commits"
            },
            "self": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767"
            },
            "comments": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments"
            },
            "patch": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/patch"
            },
            "merge": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/merge"
            },
            "html": {
                "href": "https://api.bitbucket.org/bitbucket/bitbucket/pull-request/3767"
            },
            "activity": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/activity"
            },
            "diff": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/diff"
            },
            "approve": {
                "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/approve"
            }
        },
        "author": {
            "username": "mfrauenholtz",
            "display_name": "Michael Frauenholtz",
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/users/mfrauenholtz"
                },
                "avatar": {
                    "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Aug/24/mfrauenholtz-avatar-1858533797-5_avatar.png"
                }
            }
        },
        "close_source_branch": true,
        "title": "BB-9500: Remove certain admin links for Team accounts",
        "destination": {
            "commit": {
                "hash": "e04099ba977c",
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/e04099ba977c"
                    }
                }
            },
            "repository": {
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket"
                    },
                    "avatar": {
                        "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Sep/27/bitbucket-logo-1832464563-7_avatar.png"
                    }
                },
                "full_name": "bitbucket/bitbucket",
                "name": "bitbucket"
            },
            "branch": {
                "name": "staging"
            }
        },
        "reason": "",
        "closed_by": null,
        "source": {
            "commit": {
                "hash": "2a81a1edc0c2",
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/2a81a1edc0c2"
                    }
                }
            },
            "repository": {
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket"
                    },
                    "avatar": {
                        "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Sep/27/bitbucket-logo-1832464563-7_avatar.png"
                    }
                },
                "full_name": "bitbucket/bitbucket",
                "name": "bitbucket"
            },
            "branch": {
                "name": "mfrauenholtz/team-removal/admin-links"
            }
        },
        "state": "OPEN",
        "created_on": "2013-11-05T23:59:26.480984+00:00",
        "updated_on": "2013-11-07T00:17:41.061613+00:00",
        "merge_commit": null,
        "id": 3767
    }],
    "page": 1,
    "size": 12
}

POST (create) a new pull request

Creates a new pull request. The request URL you provide is the destination repository URL. For this reason, you must specify an explicit source repository in the request object if you want to pull from a different repository.

Your JSON request body can contain a standard pull request object. However, since not all elements are required or even mutable, you only need to include the elements you want to initialize. The following structure includes all the required and optional parameters for the JSON body:

 {
     "title": "REQUIRED title",
     "description": "description",
     "source": {
         "branch": {
             "name": "REQUIRED name"
         },
         "repository": {
             "full_name": "owner/repo_slug"
         }
     },
     "destination": {
         "branch": {
             "name": "name"
         },
 		"commit": {
             "hash": "name"
         }
      },
     "close_source_branch": true
 }

The response contains the newly created pull request object and its self link in the Location response header.

ParameterRequired?Description
titleYesA string representing the request title.
descriptionNoThe description of the pull request.
nameYes

A string identifying the source or destination branch (for example, develop). You must supply a source branch name. The destination branch name is optional. If you omit the destination name, the parameter defaults to the repository's main branch.

hashNoThe SHA1 of the source branch's head. You only need to specify this parameter for a Mercurial repository whose source branch has multiple heads.
full_nameNoThe full slug of the source repository (for example, evzijst/jira-fork). This parameter is optional and defaults to the current repository (the one from the URL), making it redundant for pull requests within the same repo.
hashNoThe SHA1 of the head of the destination branch. Necessary only for Mercurial repos where the destination repository has multiple heads.
close_source_branchNo

Boolean indicating whether Bitbucket should close the source branch after the pull requests gets merged successfully. Only use this parameter when the source and destination are in the same repo.

reviewersNo

A list of user objects to add as reviewers. You only need to provide the username element of the user object.

POST https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/
Click here to expand...
$ curl -X POST -H "Content-Type: application/json" -u username:password \
  https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests \
  -d '
> {
>     "title": "title",
>     "description": "Merge from upstream.",
>     "source": {
>         "branch": {
>             "name": "production"
>         },
>         "repository": {
>             "full_name": "evzijst/bitbucket2"
>         }
>     },
>     "destination": {
>         "branch": {
>             "name": "staging"
>         }
>     },
>     "reviewers": [
>         {
>             "username": "nvenegas"
>         }
>     ],
>     "close_source_branch": true
> }
> '

PUT a pull request update

Updates an existing pull request. The pull request's status must be open. With the exception of the source and destination parameters, the request body must include all the existing request parameters; Omitting a parameter causes the server to drop the existing value. For example, if the pull requests already has 3 reviewers, the request body must include these 3 reviewers to prevent Bitbucket from dropping them.

A pull request cannot exist without the source and destination parameters. For this reason Bitbucket never drops them. The URL provides the destination and Bitbucket keeps the existing source.  

A caller cannot change any elements of the source repository or the destination repository's name. A caller can change the destination branch. To do this, provide the destination's branch element in the call. 

A pull request is stale when new commits were pushed to the source branch but the request does not yet reflect these new commits. When a PUT is called on a stale request, Bitbucket always updates the source branch to the new head commit before processing the PUT.

A PUT request body can contain any of the following fields (immutable or ignored fields not shown):

 {
     "title": "title",
     "description": "description",
     "destination": {
         "branch": {
             "name": "name"
         },
 		"commit": {
             "hash": "name"
         }
      },
     "reviewers": [
         {
             "username": "accountname"
         }
     ],
     "close_source_branch": true
 }

The response contains the newly created pull request object and its self link in the Location response header.

ParameterRequired?Description
titleYesA string representing the request title.
descriptionNoThe description of the pull request.
nameYes

A string identifying the destination branch (for example, develop). The destination branch name is optional. If you omit the destination name, the parameter defaults to the repository's main branch.

hashNoThe SHA1 of the source branch's head. You only need to specify this parameter for a Mercurial repository whose source branch has multiple heads.
full_nameNoThe full slug of the source repository (for example, evzijst/jira-fork). This parameter is optional and defaults to the current repository (the one from the URL), making it redundant for pull requests within the same repo.
hashNoThe SHA1 of the head of the destination branch. Necessary only for Mercurial repos where the destination repository has multiple heads.
close_source_branchNo

Boolean indicating whether Bitbucket should close the source branch after the pull requests is successfully merged. Only use this parameter when the source and destination are in the same repo.

reviewersNo

A list of user objects to add as reviewers. You only need to provide the username element of the user object.

PUT https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}
Click here to expand request body...
$ curl -X PUT -H "Content-Type: application/json" -u username:password \
  https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/28 \
  -d '
> {
>     "title": "title",
>     "description": "Merge from upstream.",
>     "destination": {
>         "branch": {
>             "name": "development"
>         }
>     },
>     "reviewers": [
>         {
>             "username": "nvenegas"
>         }
>     ],
>     "close_source_branch": true
> }
> ' 
 

GET a specific pull request

Gets an specific pull request.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
idYesThe pull request identifier.
comment_countNoThe number of comments in the pull request.
task_countNoThe number of open tasks in the pull request.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}
Click here to expand...

curl -v -u username:pw https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6 

{
    "author": {
        "display_name": "Dan Stevens [Atlassian]",
        "links": {
            "avatar": {
                "href": "https://bitbucket.org/account/dans9190/avatar/32/"
            },
            "html": {
                "href": "https://bitbucket.org/dans9190/"
            },
            "self": {
                "href": "https://api.bitbucket.org/2.0/users/dans9190"
            }
        },
        "type": "user",
        "username": "dans9190",
        "uuid": "{1cd06601-cd0e-4fce-be03-e9ac226978b7}"
    },
    "close_source_branch": false,
    "closed_by": null,
    "comment_count": 2,
    "created_on": "2015-10-15T16:38:55.491628+00:00",
    "description": "* more changes\r\n\r\n* testing prs",
    "destination": {
        "branch": {
            "name": "master"
        },
        "commit": {
            "hash": "8b236d9900e6",
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/commit/8b236d9900e6"
                }
            }
        },
        "repository": {
            "full_name": "teamsinspace/documentation-tests",
            "links": {
                "avatar": {
                    "href": "https://bitbucket.org/teamsinspace/documentation-tests/avatar/32/"
                },
                "html": {
                    "href": "https://bitbucket.org/teamsinspace/documentation-tests"
                },
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests"
                }
            },
            "name": "documentation-tests",
            "type": "repository",
            "uuid": "{b4434b4d-6a0e-4f57-8d75-e02a824abeb0}"
        }
    },
    "id": 6,
    "links": {
        "activity": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/activity"
        },
        "approve": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/approve"
        },
        "comments": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/comments"
        },
        "commits": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/commits"
        },
        "decline": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/decline"
        },
        "diff": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/diff"
        },
        "html": {
            "href": "https://bitbucket.org/teamsinspace/documentation-tests/pull-requests/6"
        },
        "merge": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6/merge"
        },
        "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/pullrequests/6"
        }
    },
    "merge_commit": null,
    "participants": [
        {
            "approved": false,
            "role": "PARTICIPANT",
            "user": {
                "display_name": "Dan Stevens [Atlassian]",
                "links": {
                    "avatar": {
                        "href": "https://bitbucket.org/account/dans9190/avatar/32/"
                    },
                    "html": {
                        "href": "https://bitbucket.org/dans9190/"
                    },
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/users/dans9190"
                    }
                },
                "type": "user",
                "username": "dans9190",
                "uuid": "{1cd06601-cd0e-4fce-be03-e9ac226978b7}"
            }
        }
    ],
    "reason": "",
    "reviewers": [],
    "source": {
        "branch": {
            "name": "changes"
        },
        "commit": {
            "hash": "235b9a74d2e8",
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests/commit/235b9a74d2e8"
                }
            }
        },
        "repository": {
            "full_name": "teamsinspace/documentation-tests",
            "links": {
                "avatar": {
                    "href": "https://bitbucket.org/teamsinspace/documentation-tests/avatar/32/"
                },
                "html": {
                    "href": "https://bitbucket.org/teamsinspace/documentation-tests"
                },
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/teamsinspace/documentation-tests"
                }
            },
            "name": "documentation-tests",
            "type": "repository",
            "uuid": "{b4434b4d-6a0e-4f57-8d75-e02a824abeb0}"
        }
    },
    "state": "OPEN",
    "task_count": 1,
    "title": "Changes",
    "type": "pullrequest",
    "updated_on": "2016-01-12T19:31:23.673329+00:00"
}

GET the commits for a pull request

To get the commits associated with a specific pull request, follow the pull request's commits link. This returns a paginated response.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
idYesThe request identifier.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}/commits
Click here to expand...
{
    pagelen: 1,
    next: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3764/commits?pagelen=1&page=2",
    values: [{
        hash: "ad758aeba36fa4b9d258ac1667f55cfb811e6df3",
        links: {
            self: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/ad758aeba36fa4b9d258ac1667f55cfb811e6df3"
            },
            comments: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/ad758aeba36fa4b9d258ac1667f55cfb811e6df3/comments"
            },
            patch: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/patch/ad758aeba36fa4b9d258ac1667f55cfb811e6df3"
            },
            html: {
                href: "https://bitbucket.org/bitbucket/bitbucket/commits/ad758aeba36fa4b9d258ac1667f55cfb811e6df3"
            },
            diff: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/diff/ad758aeba36fa4b9d258ac1667f55cfb811e6df3"
            },
            approve: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/ad758aeba36fa4b9d258ac1667f55cfb811e6df3/approve"
            }
        },
        repository: {
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket"
                },
                avatar: {
                    href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Sep/27/bitbucket-logo-1832464563-7_avatar.png"
                }
            },
            full_name: "bitbucket/bitbucket",
            name: "bitbucket"
        },
        author: {
            raw: "Erik van Zijst <erik.van.zijst@gmail.com>",
            user: {
                username: "erik",
                display_name: "Erik van Zijst",
                links: {
                    self: {
                        href: "https://api.bitbucket.org/2.0/users/erik"
                    },
                    avatar: {
                        href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Jul/31/erik-avatar-725122544-0_avatar.png"
                    }
                }
            }
        },
        parents: [{
            hash: "16929c2f94828ca9d8adb5b91e7db7b274aae318",
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/16929c2f94828ca9d8adb5b91e7db7b274aae318"
                }
            }
        }],
        date: "2013-11-07T00:17:05+00:00",
        message: "Reorder imports. "
    }],
    page: 1,
    size: 11
}

POST a pull request approval

Give your approval on a pull request. You can only approve a request on behalf of the authenticated account. This returns the participant object for the current user.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
idYesThe pull request identifier.
POST https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}/approve
Click here to expand...
{
    "role": "PARTICIPANT",
    "user": {
        "username": "evzijst",
        "display_name": "Erik van Zijst",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/users/evzijst"
            },
            "avatar": {
                "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
            }
        }
    },
    "approved": true
}

DELETE a pull request approval

Revoke your approval on a pull request. You can remove approvals on behalf of the authenticated account.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
idYesThe request identifier.
DELETE https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}/approve

On success, this method returns: HTTP/1.1 204 NO CONTENT 

GET the diff for a pull request

Gets the diff or patch for a pull request. This returns a 302 redirect response with the Location header set to the URL that will perform a temporary merge and return the diff of it. The result is identical to diff in the UI.

The diff is returned as raw text (Content-Type: text/plain). For Mercurial, git-style diffs are returned.

By default, 3 lines of context are included. This can be changed using the context=num_lines query parameter. 

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
idYesThe request identifier.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/diff
Click here to expand...
diff --git a/apps/account/forms.py b/apps/account/forms.py
index c2f3d2d..2c27220 100644
--- a/apps/account/forms.py
+++ b/apps/account/forms.py
@@ -553,6 +553,8 @@ class UsernameChangeForm(forms.Form):
             raise TypeError("Keyword argument 'request' must be supplied")
         super(UsernameChangeForm, self).__init__(*args, **kwargs)
         self.request = request
+        if request.target_user.get_profile().is_team:
+            self.fields['username'].label = _('Team id')
         if request.user == request.target_user:
             self.fields['username'].help_text = _('You will need to log in '
                                                   'again after making this '

GET the log of all of a repository's pull request activity

Returns all the pull request activity for a repository. This call returns a historical log of all the pull request activity within a repository.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
pull_request_idYesThe request identifier.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/activity
Click here to expand...
 {
  "pagelen": 10,
  "next": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/activity?page=2",
  "values": [
    {
      "update": {
        "description": "editme.html edited online with Bitbucket",
        "title": "editme.html edited online with Bitbucket",
        "destination": {
          "commit": {
            "hash": "160c67046cbd",
            "links": {
              "self": {
                "href": "https://bitbucket.org/!api/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/160c67046cbd"
              }
            }
          },
          "repository": {
            "links": {
              "self": {
                "href": "https://bitbucket.org/!api/2.0/repositories/tutorials/tutorials.bitbucket.org"
              },
              "avatar": {
                "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
              }
            },
            "full_name": "tutorials/tutorials.bitbucket.org",
            "name": "tutorials.bitbucket.org"
          },
          "branch": {
            "name": "default"
          }
        },
        "reason": "",
        "source": {
          "commit": {
            "hash": "e38157163256",
            "links": {
              "self": {
                "href": "https://bitbucket.org/!api/2.0/repositories/yogaswara/tutorials.bitbucket.org/commit/e38157163256"
              }
            }
          },
          "repository": {
            "links": {
              "self": {
                "href": "https://bitbucket.org/!api/2.0/repositories/yogaswara/tutorials.bitbucket.org"
              },
              "avatar": {
                "href": "https://d3oaxc4q5k2d6q.cloudfront.net/m/2d3c993b256a/img/language-avatars/html5_16.png"
              }
            },
            "full_name": "yogaswara/tutorials.bitbucket.org",
            "name": "tutorials.bitbucket.org"
          },
          "branch": {
            "name": "yogaswara/editmehtml-edited-online-with-bitbucket-1397734940485"
          }
        },
        "state": "OPEN",
        "author": {
          "username": "yogaswara",
          "display_name": "Gistha Yogaswara",
          "links": {
            "self": {
              "href": "https://bitbucket.org/!api/2.0/users/yogaswara"
            },
            "avatar": {
              "href": "https://secure.gravatar.com/avatar/13926efbdd4c1aa474bd5bf6309c8c22?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F2d3c993b256a%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
            }
          }
        },
        "date": "2014-04-17T11:43:06.043720+00:00"
      },
       "pull_request": {
        "id": 3662,
        "links": {
          "self": {
            "href": "https://bitbucket.org/!api/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/3662"
          }
        },
        "title": "adding a quote by Bill Hicks"
      }
    },
    {
      "comment": {
        "links": {
          "self": {
            "href": "https://bitbucket.org/!api/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/3662/comments/1675471"
          }
        },
        "content": {
          "raw": "I think you accidentally pasted an existing quote instead of the Bill Hicks quote. I'd like to see the Bill Hicks quote so feel free to resubmit. :) ",
          "markup": "markdown",
          "html": "<p>I think you accidentally pasted an existing quote instead of the Bill Hicks quote. I'd like to see the Bill Hicks quote so feel free to resubmit. :) </p>"
        },
        "created_on": "2014-04-16T16:31:21.158922+00:00",
        "user": {
          "username": "dans9190",
          "display_name": "Daniel  Stevens",
          "links": {
            "self": {
              "href": "https://bitbucket.org/!api/2.0/users/dans9190"
            },
            "avatar": {
              "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2014/Jan/29/dans9190-avatar-2647033047-1_avatar.png"
            }
          }
        },
        "updated_on": "2014-04-16T16:31:21.169121+00:00",
        "id": 1675471
      },
      "pull_request": {
        "id": 3662,
        "links": {
          "self": {
            "href": "https://bitbucket.org/!api/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/3662"
          }
        },
        "title": "adding a quote by Bill Hicks"
      }
    }
  ],
  "page": 1,
  "size": 10965

GET the activity for a pull request

Gets a log of the activity for a specific pull request.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
pull_request_idYesThe request identifier.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/activity
Click here to expand...
{
    pagelen: 2,
    next: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/activity?pagelen=2&page=2",
    values: [{
        comment: {
            parent: {
                id: 25334,
                links: {
                    self: {
                        href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments/25334"
                    }
                }
            },
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments/25337"
                }
            },
            content: {
                raw: "If we are leaving the email attached to the team account, Gravatar should still work fine. The problem would be they can't change the Gravatar associated account then.",
                markup: "markdown",
                html: "<p>If we are leaving the email attached to the team account, Gravatar should still work fine. The problem would be they can't change the Gravatar associated account then.</p>"
            },
            created_on: "2013-11-07T17:11:20.986517+00:00",
            user: {
                username: "mfrauenholtz",
                display_name: "Michael Frauenholtz",
                links: {
                    self: {
                        href: "https://api.bitbucket.org/2.0/users/mfrauenholtz"
                    },
                    avatar: {
                        href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Aug/24/mfrauenholtz-avatar-1858533797-5_avatar.png"
                    }
                }
            },
            updated_on: "2013-11-07T17:11:20.989028+00:00",
            id: 25337
        },
        pull_request: {
            id: 3767,
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767"
                }
            },
            title: "BB-9500: Remove certain admin links for Team accounts"
        }
    }, {
        update: {
            status: "open",
            description: "![img](https://cloudup.com/ccaeaiiEz1S+) ## Removing: * Notifications * Email * Change password * Sessions ## Renaming: * Change username * Delete account (rename to delete team) ",
            title: "BB-9500: Remove certain admin links for Team accounts",
            destination: {
                commit: {
                    hash: "e04099ba977c",
                    links: {
                        self: {
                            href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/e04099ba977c"
                        }
                    }
                },
                repository: {
                    links: {
                        self: {
                            href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket"
                        },
                        avatar: {
                            href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Sep/27/bitbucket-logo-1832464563-7_avatar.png"
                        }
                    },
                    full_name: "bitbucket/bitbucket",
                    name: "bitbucket"
                },
                branch: {
                    name: "staging"
                }
            },
            source: {
                commit: {
                    hash: "cfda27cb506e",
                    links: {
                        self: {
                            href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/commit/cfda27cb506e"
                        }
                    }
                },
                repository: {
                    links: {
                        self: {
                            href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket"
                        },
                        avatar: {
                            href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Sep/27/bitbucket-logo-1832464563-7_avatar.png"
                        }
                    },
                    full_name: "bitbucket/bitbucket",
                    name: "bitbucket"
                },
                branch: {
                    name: "mfrauenholtz/team-removal/admin-links"
                }
            },
            reason: "",
            user: {
                username: "mfrauenholtz",
                display_name: "Michael Frauenholtz",
                links: {
                    self: {
                        href: "https://api.bitbucket.org/2.0/users/mfrauenholtz"
                    },
                    avatar: {
                        href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Aug/24/mfrauenholtz-avatar-1858533797-5_avatar.png"
                    }
                }
            },
            date: "2013-11-07T16:56:48.699418+00:00"
        },
        pull_request: {
            id: 3767,
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767"
                }
            },
            title: "BB-9500: Remove certain admin links for Team accounts"
        }
    }],
    page: 1,
    size: 10
}

Accept and merge a pull request

Accept a pull request and merges into the destination branch. This requires write access on the destination repository.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
pull_request_idYesThe pullrequest identifier.
messageNo

The message that will be used for the merge commit.

close_source_branchNoOverride the value of close_source_branch that was used at the time of pull request creation.
POST https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/merge
Click here to expand...
{
  "description": "test",
  "links": {
    "decline": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/decline"
    },
    "commits": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/commits"
    },
    "self": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819"
    },
    "comments": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/comments"
    },
    "merge": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/merge"
    },
    "html": {
      "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org/pull-request/2819"
    },
    "activity": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/activity"
    },
    "diff": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/diff"
    },
    "approve": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2819/approve"
    }
  },
  "title": "testing",
  "close_source_branch": false,
  "reviewers": [],
  "destination": {
    "commit": {
      "hash": "382c3b9528dc",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/382c3b9528dc"
        }
      }
    },
    "repository": {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        }
      },
      "full_name": "tutorials/tutorials.bitbucket.org",
      "name": "tutorials.bitbucket.org"
    },
    "branch": {
      "name": "default"
    }
  },
  "reason": "",
  "closed_by": {
    "username": "tutorials",
    "display_name": "first name last",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/users/tutorials"
      },
      "avatar": {
        "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
      }
    }
  },
  "source": {
    "commit": {
      "hash": "d3d92dca839c",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/d3d92dca839c"
        }
      }
    },
    "repository": {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        }
      },
      "full_name": "tutorials/tutorials.bitbucket.org",
      "name": "tutorials.bitbucket.org"
    },
    "branch": {
      "name": "againwithatest"
    }
  },
  "state": "MERGED",
  "author": {
    "username": "tutorials",
    "display_name": "first name last",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/users/tutorials"
      },
      "avatar": {
        "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
      }
    }
  },
  "created_on": "2013-11-19T20:53:29.288706+00:00",
  "participants": [],
  "updated_on": "2013-11-19T20:54:32.387720+00:00",
  "merge_commit": {
    "hash": "cd2506b7e620",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/cd2506b7e620"
      }
    }
  },
  "id": 2819
}

Decline or reject a pull request

Rejects a pull request. This requires write access on the destination repository.

ParameterRequired?Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
pull_request_idYesThe pull request identifier.
messageNo

An optional reason explaining why the pull request is being rejected.

POST https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/decline
Click here to expand...
{
  "description": "",
  "links": {
    "decline": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/decline"
    },
    "commits": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/commits"
    },
    "self": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820"
    },
    "comments": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/comments"
    },
    "merge": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/merge"
    },
    "html": {
      "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org/pull-request/2820"
    },
    "activity": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/activity"
    },
    "diff": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/diff"
    },
    "approve": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2820/approve"
    }
  },
  "title": "test",
  "close_source_branch": false,
  "reviewers": [],
  "destination": {
    "commit": {
      "hash": "cd2506b7e620",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/cd2506b7e620"
        }
      }
    },
    "repository": {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        }
      },
      "full_name": "tutorials/tutorials.bitbucket.org",
      "name": "tutorials.bitbucket.org"
    },
    "branch": {
      "name": "default"
    }
  },
  "reason": "",
  "closed_by": {
    "username": "tutorials",
    "display_name": "first name last",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/users/tutorials"
      },
      "avatar": {
        "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
      }
    }
  },
  "source": {
    "commit": {
      "hash": "067c283803a7",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commit/067c283803a7"
        }
      }
    },
    "repository": {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        }
      },
      "full_name": "tutorials/tutorials.bitbucket.org",
      "name": "tutorials.bitbucket.org"
    },
    "branch": {
      "name": "againwithatest"
    }
  },
  "state": "DECLINED",
  "author": {
    "username": "tutorials",
    "display_name": "first name last",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/users/tutorials"
      },
      "avatar": {
        "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
      }
    }
  },
  "created_on": "2013-11-19T21:13:26.746009+00:00",
  "participants": [],
  "updated_on": "2013-11-19T21:14:04.620150+00:00",
  "merge_commit": null,
  "id": 2820
}

GET a list of a pull request comments

Gets the array of comments on the specified pull request. A pull request comment has the following fields:

FieldDescription
linksLinks to the comment's self location, as well as other representations and related resource.
idAn integer representing an id for the comment.
parentThe parent comment. This is is applicable only to replies and not present in top-level comments.
updated_onThe timestamp of the most recent change to the comment.
filenameThe filename the new comment concerns.
content

The content of the comment.

  • raw: the raw text as the user typed it
  • markup: the markup language used
  • html: the rendered HTML version of the markup
userThe user that added the comment.
inline

Presence of this element indicates that the comment is an inline code comment. It contains the following nested elements:

  • to: the line number of the new version in the diff that the comment was made on (the "green" line). null if the line does not exist in the new version
  • from: the line number of the old version in the diff that the comment was made on (the "red" line). null if the line did not exist in the old version
  • path: the name of the file the comment was made on

Inline comments also have an additional link in the links section (rel: "code") that points to the raw file diff.

created_onDate and time when the comment was created.

For private repositories, the caller must authenticate as a user with read access to the destination repository.

GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/comments
Click here to expand...
{
    pagelen: 1,
    next: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments?pagelen=1&page=2",
    values: [{
        parent: {
            id: 25334,
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments/25334"
                }
            }
        },
        links: {
            self: {
                href: "https://api.bitbucket.org/2.0/repositories/bitbucket/bitbucket/pullrequests/3767/comments/25337"
            },
            html: {
                href: "https://bitbucket.org/bitbucket/bitbucket/pull-request/3767/_/diff#comment-25337"
            }
        },
        content: {
            raw: "If we are leaving the email attached to the team account, Gravatar should still work fine. The problem would be they can't change the Gravatar associated account then.",
            markup: "markdown",
            html: "<p>If we are leaving the email attached to the team account, Gravatar should still work fine. The problem would be they can't change the Gravatar associated account then.</p>"
        },
        created_on: "2013-11-07T17:11:20.986517+00:00",
        user: {
            username: "mfrauenholtz",
            display_name: "Michael Frauenholtz",
            links: {
                self: {
                    href: "https://api.bitbucket.org/2.0/users/mfrauenholtz"
                },
                avatar: {
                    href: "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Aug/24/mfrauenholtz-avatar-1858533797-5_avatar.png"
                }
            }
        },
        updated_on: "2013-11-07T17:11:20.989028+00:00",
        id: 25337
    }],
    page: 1,
    size: 4
}

GET an individual pull request comment 

Gets an individual comment on an request. Private repositories require authorization with an account that has appropriate access.

Parameter
Required?
Description
ownerYesThe account owning the repo.
repo_slugYesThe repo identifier.
pull_request_idYesThe pull request identifier.
comment_idYes

The comment identifier.

GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/comments/{comment_id}
Click here to expand...
{
  "links": {
    "self": {
      "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/2821/comments/839163"
    },
    "html": {
      "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org/pull-request/2821/_/diff#comment-839163"
    }
  },
  "content": {
    "raw": "this is my first comment",
    "markup": "markdown",
    "html": "<p>this is my first comment</p>"
  },
  "created_on": "2013-11-19T21:19:24.138375+00:00",
  "user": {
    "username": "tutorials",
    "display_name": "first name last",
    "links": {
      "self": {
        "href": "https://api.bitbucket.org/2.0/users/tutorials"
      },
      "avatar": {
        "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
      }
    }
  },
  "updated_on": "2013-11-19T21:19:24.141013+00:00",
  "id": 839163
}
Last modified on Mar 2, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.