Create 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 stringclose_source_branch
- boolean that specifies if the source branch should be closed upon merging.
External Documentation
To learn more, visit the Bitbucket documentation.
Parameters
Parameter | Description |
---|---|
Destination Branch | - |
Repo Slug | This can either be the repository slug or the UUID of the repository,surrounded by curly-braces, for example: {repository UUID} . |
Source Branch | - |
State | The pull request's current status. |
Title | Title of the pull request. |
Workspace Slug | This can either be the workspace ID (slug) or the workspace UUIDsurrounded by curly-braces, for example: {workspace UUID} . |
Example Output
{
"author": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"close_source_branch": false,
"closed_by": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"comment_count": 0,
"created_on": "The ISO8601 timestamp the request was created.",
"destination": {
"branch": {
"default_merge_strategy": "The default merge strategy, when this endpoint is the destination of the pull request.",
"merge_strategies": [
"string"
],
"name": "string"
},
"commit": {
"hash": "[0-9a-f]{7,}?"
},
"repository": {
"created_on": "date-time",
"description": "string",
"fork_policy": "\nControls the rules for forking this repository.\n\n* **allow_forks**: unrestricted forking\n* **no_public_forks**: restrict forking to private forks (forks cannot\n be made public later)\n* **no_forks**: deny all forking\n",
"full_name": "The concatenation of the repository owner's username and the slugified name, e.g. \"evzijst/interruptingcow\". This is the same string used in Bitbucket URLs.",
"has_issues": false,
"has_wiki": false,
"is_private": false,
"language": "string",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"clone": [
{
"href": "uri",
"name": "string"
}
],
"commits": {
"href": "uri",
"name": "string"
},
"downloads": {
"href": "uri",
"name": "string"
},
"forks": {
"href": "uri",
"name": "string"
},
"hooks": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"pullrequests": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
},
"watchers": {
"href": "uri",
"name": "string"
}
},
"mainbranch": {
"default_merge_strategy": "The default merge strategy for pull requests targeting this branch.",
"links": {
"commits": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"merge_strategies": [
"string"
],
"name": "The name of the ref.",
"target": {
"author": {
"raw": "The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.",
"type": "string",
"user": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
},
"date": "date-time",
"hash": "[0-9a-f]{7,}?",
"message": "string",
"parents": [
null
],
"participants": [
{
"approved": false,
"participated_on": "The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.",
"role": "string",
"state": "string",
"type": "string",
"user": {
"account_id": "The user's Atlassian account ID.",
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"is_staff": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
}
],
"summary": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"type": "string"
},
"type": "string"
},
"name": "string",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"project": {
"created_on": "date-time",
"description": "string",
"has_publicly_visible_repos": false,
"is_private": false,
"key": "The project's key.",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
}
},
"name": "The name of the project.",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"type": "string",
"updated_on": "date-time",
"uuid": "The project's immutable id."
},
"scm": "string",
"size": 0,
"type": "string",
"updated_on": "date-time",
"uuid": "The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user."
}
},
"id": 0,
"links": {
"activity": {
"href": "uri",
"name": "string"
},
"approve": {
"href": "uri",
"name": "string"
},
"comments": {
"href": "uri",
"name": "string"
},
"commits": {
"href": "uri",
"name": "string"
},
"decline": {
"href": "uri",
"name": "string"
},
"diff": {
"href": "uri",
"name": "string"
},
"diffstat": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"merge": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"merge_commit": {
"hash": "[0-9a-f]{7,}?"
},
"participants": [
{
"approved": false,
"participated_on": "The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.",
"role": "string",
"state": "string",
"type": "string",
"user": {
"account_id": "The user's Atlassian account ID.",
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"is_staff": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
}
],
"reason": "Explains why a pull request was declined. This field is only applicable to pull requests in rejected state.",
"rendered": {
"description": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"reason": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"title": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
}
},
"reviewers": [
{
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
],
"source": {
"branch": {
"default_merge_strategy": "The default merge strategy, when this endpoint is the destination of the pull request.",
"merge_strategies": [
"string"
],
"name": "string"
},
"commit": {
"hash": "[0-9a-f]{7,}?"
},
"repository": {
"created_on": "date-time",
"description": "string",
"fork_policy": "\nControls the rules for forking this repository.\n\n* **allow_forks**: unrestricted forking\n* **no_public_forks**: restrict forking to private forks (forks cannot\n be made public later)\n* **no_forks**: deny all forking\n",
"full_name": "The concatenation of the repository owner's username and the slugified name, e.g. \"evzijst/interruptingcow\". This is the same string used in Bitbucket URLs.",
"has_issues": false,
"has_wiki": false,
"is_private": false,
"language": "string",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"clone": [
{
"href": "uri",
"name": "string"
}
],
"commits": {
"href": "uri",
"name": "string"
},
"downloads": {
"href": "uri",
"name": "string"
},
"forks": {
"href": "uri",
"name": "string"
},
"hooks": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"pullrequests": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
},
"watchers": {
"href": "uri",
"name": "string"
}
},
"mainbranch": {
"default_merge_strategy": "The default merge strategy for pull requests targeting this branch.",
"links": {
"commits": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"merge_strategies": [
"string"
],
"name": "The name of the ref.",
"target": {
"author": {
"raw": "The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.",
"type": "string",
"user": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
},
"date": "date-time",
"hash": "[0-9a-f]{7,}?",
"message": "string",
"parents": [
null
],
"participants": [
{
"approved": false,
"participated_on": "The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.",
"role": "string",
"state": "string",
"type": "string",
"user": {
"account_id": "The user's Atlassian account ID.",
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"is_staff": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
}
],
"summary": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"type": "string"
},
"type": "string"
},
"name": "string",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"project": {
"created_on": "date-time",
"description": "string",
"has_publicly_visible_repos": false,
"is_private": false,
"key": "The project's key.",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
}
},
"name": "The name of the project.",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"type": "string",
"updated_on": "date-time",
"uuid": "The project's immutable id."
},
"scm": "string",
"size": 0,
"type": "string",
"updated_on": "date-time",
"uuid": "The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user."
}
},
"state": "The pull request's current status.",
"summary": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"task_count": 0,
"title": "Title of the pull request.",
"type": "string",
"updated_on": "The ISO8601 timestamp the request was last updated."
}
Workflow Library Example
Create Pull Request with Bitbucket and Send Results Via Email
Preview this Workflow on desktop