v2

latestOpenAPI 3.0.02026-08-013312111.4 MB
Pullrequests

Create a pull request

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 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