Pullrequests

Create a pull request

Changed on

Creates a new pull request where the destination repository is this repository and the author is the authenticated user.

The minimum required fields to create a pull request are title and source, specified by a branch name.

curl https://api.bitbucket.org/2.0/repositories/my-workspace/my-repository/pullrequests \
    -u my-username:my-password \
    --request POST \
    --header 'Content-Type: application/json' \
    --data '{
        "title": "My Title",
        "source": {
            "branch": {
                "name": "staging"
            }
        }
    }'

If the pull request's destination is not specified, it will default to the repository.mainbranch. To open a pull request to a different branch, say from a feature branch to a staging branch, specify a destination (same format as the source):

{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "my-feature-branch"
        }
    },
    "destination": {
        "branch": {
            "name": "staging"
        }
    }
}

Reviewers can be specified by adding an array of user objects as the reviewers property.

{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "my-feature-branch"
        }
    },
    "reviewers": [
        {
            "uuid": "{504c3b62-8120-4f0c-a7bc-87800b9d6f70}"
        }
    ]
}

Other fields:

  • description - a string
  • close_source_branch - boolean that specifies if the source branch should be closed upon merging
  • draft - boolean that specifies whether the pull request is a draft
post/repositories/{workspace}/{repo_slug}/pullrequests

Request

  • Base URL
    https://api.bitbucket.org/2.0
  • URL
    https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests
  • Auth
    • OAuth 2
      Authorization code: https://bitbucket.org/site/oauth2/authorize
      Token URL: https://bitbucket.org/site/oauth2/access_token scopes: pullrequest:write
    • or HTTP basic
    • or API key in header Authorization

Request body

typestring required
idinteger

The pull request's unique ID. Note that pull request IDs are only unique within their associated repository.

titlestring

Title of the pull request.

state'OPEN' | 'MERGED' | 'DECLINED' | 'SUPERSEDED'

The pull request's current status.

comment_countinteger

The number of comments for a specific pull request.

task_countinteger

The number of open tasks for a specific pull request.

close_source_branchboolean

A boolean flag indicating if merging the pull request closes the source branch.

reasonstring

Explains why a pull request was declined. This field is only applicable to pull requests in rejected state.

created_onstring date-time

The ISO8601 timestamp the request was created.

updated_onstring date-time

The ISO8601 timestamp the request was last updated.

draftboolean

A boolean flag indicating whether the pull request is a draft.

queuedboolean

A boolean flag indicating whether the pull request is queued

Response

The newly created pull request.

typestring required
idinteger

The pull request's unique ID. Note that pull request IDs are only unique within their associated repository.

titlestring

Title of the pull request.

state'OPEN' | 'MERGED' | 'DECLINED' | 'SUPERSEDED'

The pull request's current status.

comment_countinteger

The number of comments for a specific pull request.

task_countinteger

The number of open tasks for a specific pull request.

close_source_branchboolean

A boolean flag indicating if merging the pull request closes the source branch.

reasonstring

Explains why a pull request was declined. This field is only applicable to pull requests in rejected state.

created_onstring date-time

The ISO8601 timestamp the request was created.

updated_onstring date-time

The ISO8601 timestamp the request was last updated.

draftboolean

A boolean flag indicating whether the pull request is a draft.

queuedboolean

A boolean flag indicating whether the pull request is queued

Changes

    • info

      added the new optional request property //

    • info

      added the optional property // to the response with the status

    • warning

      removed the request property ///

    • warning

      removed the request property ///

    • warning

      removed the request property ////////////////

    • warning

      removed the request property /////////////

    • warning

      removed the request property //////

    • warning

      removed the request property ////////////

    • warning

      removed the request property //////

    • warning

      removed the request property ////

    • warning

      removed the request property ////////////////

    • warning

      removed the request property /////////////

    • warning

      removed the request property //////

    • warning

      removed the request property ////////////

    • warning

      removed the optional property /// from the response with the status

    • warning

      removed the optional property /// from the response with the status

    • warning

      removed the optional property //////////////// from the response with the status

    • warning

      removed the optional property ///////////// from the response with the status

    • warning

      removed the optional property ////// from the response with the status

    • warning

      removed the optional property //////////// from the response with the status

    • warning

      removed the optional property ////// from the response with the status

    • warning

      removed the optional property //// from the response with the status

    • warning

      removed the optional property //////////////// from the response with the status

    • warning

      removed the optional property ///////////// from the response with the status

    • warning

      removed the optional property ////// from the response with the status

    • warning

      removed the optional property //////////// from the response with the status

    • warning

      added the new rebase_fast_forward enum value to the //// response property for the response status

    • warning

      added the new rebase_fast_forward enum value to the /////// response property for the response status

    • warning

      added the new rebase_fast_forward enum value to the //// response property for the response status

    • warning

      added the new rebase_fast_forward enum value to the /////// response property for the response status

    • warning

      added the new rebase_merge enum value to the //// response property for the response status

    • warning

      added the new rebase_merge enum value to the /////// response property for the response status

    • warning

      added the new rebase_merge enum value to the //// response property for the response status

    • warning

      added the new rebase_merge enum value to the /////// response property for the response status

    • warning

      added the new squash_fast_forward enum value to the //// response property for the response status

    • warning

      added the new squash_fast_forward enum value to the /////// response property for the response status

    • warning

      added the new squash_fast_forward enum value to the //// response property for the response status

    • warning

      added the new squash_fast_forward enum value to the /////// response property for the response status

    • info

      added the new optional request property ////////////

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property ////////////

    • info

      added the new rebase_fast_forward enum value to the request property ////

    • info

      added the new rebase_fast_forward enum value to the request property ///////

    • info

      added the new rebase_fast_forward enum value to the request property ////

    • info

      added the new rebase_fast_forward enum value to the request property ///////

    • info

      added the new rebase_merge enum value to the request property ////

    • info

      added the new rebase_merge enum value to the request property ///////

    • info

      added the new rebase_merge enum value to the request property ////

    • info

      added the new rebase_merge enum value to the request property ///////

    • info

      added the new squash_fast_forward enum value to the request property ////

    • info

      added the new squash_fast_forward enum value to the request property ///////

    • info

      added the new squash_fast_forward enum value to the request property ////

    • info

      added the new squash_fast_forward enum value to the request property ///////

    • info

      added the optional property //////////// to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property //////////// to the response with the status