• Addon
  • Branch restrictions
  • Branching model
  • Commit statuses
  • Commits
  • Deployments
  • Downloads
  • GPG
  • Issue tracker
  • Pipelines
  • Projects
  • Pullrequests
  • Refs
  • Reports
  • Repositories
  • SSH
  • Snippets
  • Source
  • Users
  • Webhooks
  • Workspaces
  • Other operations
Cloud
Bitbucket Cloud / Reference / REST APIs

Repositories

Postman Collection
OpenAPI

A Git repository is a virtual storage of your project. It allows you to save versions of your code, which you can access when needed. The repo resource allows you to access public repos, or repos that belong to a specific workspace.

GET

List public repositories

Returns a paginated list of all public repositories.

This endpoint also supports filtering and sorting of the results. See filtering and sorting for more details.

repository

Request

Query parameters

after

string

role

string

q

string

sort

string

Responses

All public repositories.

application/json

Paginated Repositories

A paginated list of repositories.

GET/repositories
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 { "size": 142, "page": 102, "pagelen": 159, "next": "<string>", "previous": "<string>", "values": [ { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } } ] }
GET

List repositories in a workspace

Returns a paginated list of all repositories owned by the specified workspace.

The result can be narrowed down based on the authenticated user's role.

E.g. with ?role=contributor, only those repositories that the authenticated user has write access to are returned (this includes any repo the user is an admin on, as that implies write access).

This endpoint also supports filtering and sorting of the results. See filtering and sorting for more details.

Scopes
repository
read:repository:bitbucket

Request

Path parameters

workspace

string

Required

Query parameters

role

string

q

string

sort

string

Responses

The repositories owned by the specified account.

application/json

Paginated Repositories

A paginated list of repositories.

GET/repositories/{workspace}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 { "size": 142, "page": 102, "pagelen": 159, "next": "<string>", "previous": "<string>", "values": [ { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } } ] }
GET

Get a repository

Returns the object describing this repository.

Scopes
repository
read:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

The repository object.

application/json

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

GET/repositories/{workspace}/{repo_slug}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }
PUT

Update a repository

Since this endpoint can be used to both update and to create a repository, the request body depends on the intent.

Creation

See the POST documentation for the repository endpoint for an example of the request body.

Update

Note: Changing the name of the repository will cause the location to be changed. This is because the URL of the repo is derived from the name (a process called slugification). In such a scenario, it is possible for the request to fail if the newly created slug conflicts with an existing repository's slug. But if there is no conflict, the new location will be returned in the Location header of the response.

Scopes
repository:admin
admin:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Request bodyapplication/json

The repository that is to be updated.

Note that the elements "owner" and "full_name" are ignored since the URL implies them.

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

Responses

The existing repository has been updated

Headers

Location

string

application/json

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

PUT/repositories/{workspace}/{repo_slug}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "parent": { "type": "<string>" }, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }
POST

Create a repository

Creates a new repository.

Note: In order to set the project for the newly created repository, pass in either the project key or the project UUID as part of the request body as shown in the examples below:

1 2 3 4 5 6 $ curl -X POST -H "Content-Type: application/json" -d '{ "scm": "git", "project": { "key": "MARS" } }' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding

or

1 2 3 4 5 6 $ curl -X POST -H "Content-Type: application/json" -d '{ "scm": "git", "project": { "key": "{ba516952-992a-4c2d-acbd-17d502922f96}" } }' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding

The project must be assigned for all repositories. If the project is not provided, the repository is automatically assigned to the oldest project in the workspace.

Note: In the examples above, the workspace ID teamsinspace, and/or the repository name hablanding can be replaced by UUIDs.

Scopes
repository:admin
admin:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Request bodyapplication/json

The repository that is to be created. Note that most object elements are optional. Elements "owner" and "full_name" are ignored as the URL implies them.

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

Responses

The newly created repository.

application/json

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

POST/repositories/{workspace}/{repo_slug}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "parent": { "type": "<string>" }, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }
DEL

Delete a repository

Deletes the repository. This is an irreversible operation. This does not affect its forks.

Scopes
repository:delete
delete:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Query parameters

redirect_to

string

Responses

Indicates successful deletion.

DEL/repositories/{workspace}/{repo_slug}
1 2 3 curl --request DELETE \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer <access_token>'
GET

List repository forks

Returns a paginated list of all the forks of the specified repository.

Scopes
repository
read:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Query parameters

role

string

q

string

sort

string

Responses

All forks.

application/json

Paginated Repositories

A paginated list of repositories.

GET/repositories/{workspace}/{repo_slug}/forks
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/forks' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 { "size": 142, "page": 102, "pagelen": 159, "next": "<string>", "previous": "<string>", "values": [ { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } } ] }
POST

Fork a repository

Creates a new fork of the specified repository.

Forking a repository

To create a fork, specify the workspace explicitly as part of the request body:

1 2 3 4 5 6 7 $ curl -X POST -u jdoe https://api.bitbucket.org/2.0/repositories/atlassian/bbql/forks \ -H 'Content-Type: application/json' -d '{ "name": "bbql_fork", "workspace": { "slug": "atlassian" } }'

To fork a repository into the same workspace, also specify a new name.

When you specify a value for name, it will also affect the slug. The slug is reflected in the repository URL of the new fork. It is derived from name by substituting non-ASCII characters, removes whitespace, and changes characters to lower case. For example, My repo would turn into my_repo.

You need contributor access to create new forks within a workspace.

Change the properties of a new fork

By default the fork inherits most of its properties from the parent. However, since the optional POST body document follows the normal repository JSON schema and you can override the new fork's properties.

Properties that can be overridden include:

  • description
  • fork_policy
  • language
  • mainbranch
  • is_private (note that a private repo's fork_policy might prohibit the creation of public forks, in which is_private=False would fail)
  • has_issues (to initialize or disable the new repo's issue tracker -- note that the actual contents of the parent repository's issue tracker are not copied during forking)
  • has_wiki (to initialize or disable the new repo's wiki -- note that the actual contents of the parent repository's wiki are not copied during forking)
  • project (when forking into a private project, the fork's is_private must be true)

Properties that cannot be modified include:

  • scm
  • parent
  • full_name
Scopes
repository:write
read:repository:bitbucket, write:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Request bodyapplication/json

A repository object. This can be left blank.

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

Responses

The newly created fork.

Headers

Location

string

application/json

allOf [object, Repository]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Repository

A Bitbucket repository.

POST/repositories/{workspace}/{repo_slug}/forks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/forks' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "parent": { "type": "<string>" }, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }'
201Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 { "type": "<string>", "links": { "self": { "href": "<string>", "name": "<string>" }, "html": { "href": "<string>", "name": "<string>" }, "avatar": { "href": "<string>", "name": "<string>" }, "pullrequests": { "href": "<string>", "name": "<string>" }, "commits": { "href": "<string>", "name": "<string>" }, "forks": { "href": "<string>", "name": "<string>" }, "watchers": { "href": "<string>", "name": "<string>" }, "downloads": { "href": "<string>", "name": "<string>" }, "clone": [ { "href": "<string>", "name": "<string>" } ], "hooks": { "href": "<string>", "name": "<string>" } }, "uuid": "<string>", "full_name": "<string>", "is_private": true, "scm": "git", "owner": { "type": "<string>" }, "name": "<string>", "description": "<string>", "created_on": "<string>", "updated_on": "<string>", "size": 2154, "language": "<string>", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "<string>" }, "mainbranch": { "type": "<string>" } }
GET

List webhooks for a repository

Returns a paginated list of webhooks installed on this repository.

webhook

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

The paginated list of installed webhooks.

application/json

Paginated Webhook Subscriptions

A paginated list of webhook subscriptions

GET/repositories/{workspace}/{repo_slug}/hooks
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 { "size": 142, "page": 102, "pagelen": 159, "next": "<string>", "previous": "<string>", "values": [ { "type": "<string>", "uuid": "<string>", "url": "<string>", "description": "<string>", "subject_type": "repository", "active": true, "created_at": "<string>", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "<string>" } ] }
POST

Create a webhook for a repository

Creates a new webhook on the specified repository.

Example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ curl -X POST -u credentials -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo-slug/hooks -d ' { "description": "Webhook Description", "url": "https://example.com/", "active": true, "secret": "this is a really bad secret", "events": [ "repo:push", "issue:created", "issue:updated" ] }'

When the secret is provided it will be used as the key to generate a HMAC digest value sent in the X-Hub-Signature header at delivery time. Passing a null or empty secret or not passing a secret will leave the webhook's secret unset. Bitbucket only generates the X-Hub-Signature when the webhook's secret is set.

Note that this call requires the webhook scope, as well as any scope that applies to the events that the webhook subscribes to. In the example above that means: webhook, repository and issue.

Also note that the url must properly resolve and cannot be an internal, non-routed address.

webhook

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

If the webhook was registered successfully.

Headers

Location

string

application/json

allOf [object, Webhook Subscription]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Webhook Subscription

A Webhook subscription.

POST/repositories/{workspace}/{repo_slug}/hooks
1 2 3 4 curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
201Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "type": "<string>", "uuid": "<string>", "url": "<string>", "description": "<string>", "subject_type": "repository", "active": true, "created_at": "<string>", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "<string>" }
GET

Get a webhook for a repository

Returns the webhook with the specified id installed on the specified repository.

webhook

Request

Path parameters

repo_slug

string

Required
uid

string

Required
workspace

string

Required

Responses

The webhook subscription object.

application/json

allOf [object, Webhook Subscription]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Webhook Subscription

A Webhook subscription.

GET/repositories/{workspace}/{repo_slug}/hooks/{uid}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks/{uid}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "type": "<string>", "uuid": "<string>", "url": "<string>", "description": "<string>", "subject_type": "repository", "active": true, "created_at": "<string>", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "<string>" }
PUT

Update a webhook for a repository

Updates the specified webhook subscription.

The following properties can be mutated:

  • description
  • url
  • secret
  • active
  • events

The hook's secret is used as a key to generate the HMAC hex digest sent in the X-Hub-Signature header at delivery time. This signature is only generated when the hook has a secret.

Set the hook's secret by passing the new value in the secret field. Passing a null value in the secret field will remove the secret from the hook. The hook's secret can be left unchanged by not passing the secret field in the request.

webhook

Request

Path parameters

repo_slug

string

Required
uid

string

Required
workspace

string

Required

Responses

The webhook subscription object.

application/json

allOf [object, Webhook Subscription]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Webhook Subscription

A Webhook subscription.

PUT/repositories/{workspace}/{repo_slug}/hooks/{uid}
1 2 3 4 curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks/{uid}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "type": "<string>", "uuid": "<string>", "url": "<string>", "description": "<string>", "subject_type": "repository", "active": true, "created_at": "<string>", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "<string>" }
DEL

Delete a webhook for a repository

Deletes the specified webhook subscription from the given repository.

webhook

Request

Path parameters

repo_slug

string

Required
uid

string

Required
workspace

string

Required

Responses

When the webhook was deleted successfully

DEL/repositories/{workspace}/{repo_slug}/hooks/{uid}
1 2 3 curl --request DELETE \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks/{uid}' \ --header 'Authorization: Bearer <access_token>'
GET

Retrieve the inheritance state for repository settings

Scopes
repository:admin
admin:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

The repository setting inheritance state

application/json

Repository Inheritance State

A json object representing the repository's inheritance state values

GET/repositories/{workspace}/{repo_slug}/override-settings
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/override-settings' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 { "type": "<string>", "override_settings": {} }
PUT

Set the inheritance state for repository settings

Scopes
repository:admin
admin:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

The repository setting inheritance state was set and no content returned

PUT/repositories/{workspace}/{repo_slug}/override-settings
1 2 3 curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/override-settings' \ --header 'Authorization: Bearer <access_token>'
GET

List explicit group permissions for a repository

Returns a paginated list of explicit group permissions for the given repository. This endpoint does not support BBQL features.

Scopes
repository:admin
read:repository:bitbucket, read:user:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

Paginated of explicit group permissions on the repository.

application/json

Paginated Repository Group Permissions

A paginated list of repository group permissions.

GET/repositories/{workspace}/{repo_slug}/permissions-config/groups
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 { "pagelen": 10, "values": [ { "type": "repository_group_permission", "group": { "type": "group", "name": "Administrators", "slug": "administrators" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/groups/administrators" } } }, { "type": "repository_group_permission", "group": { "type": "group", "name": "Developers", "slug": "developers" }, "permission": "read", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/groups/developers" } } } ], "page": 1, "size": 2 }
GET

Get an explicit group permission for a repository

Returns the group permission for a given group slug and repository

Only users with admin permission for the repository may access this resource.

Permissions can be:

  • admin
  • write
  • read
  • none
Scopes
repository:admin
read:repository:bitbucket, read:user:bitbucket

Request

Path parameters

group_slug

string

Required
repo_slug

string

Required
workspace

string

Required

Responses

Group permission for group slug and repository

application/json

Repository Group Permission

A group's permission for a given repository.

GET/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 { "type": "repository_group_permission", "group": { "type": "group", "name": "Developers", "slug": "developers", "full_slug": "atlassian_tutorial:developers" }, "permission": "read", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/groups/developers" } } }
PUT

Update an explicit group permission for a repository

Updates the group permission, or grants a new permission if one does not already exist.

Only users with admin permission for the repository may access this resource.

The only authentication method supported for this endpoint is via app passwords.

Permissions can be:

  • admin
  • write
  • read
repository:admin

Request

Path parameters

group_slug

string

Required
repo_slug

string

Required
workspace

string

Required

Request bodyapplication/json

The permission to grant

permission

string

Required

Responses

Group permission updated

application/json

Repository Group Permission

A group's permission for a given repository.

PUT/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}
1 2 3 4 5 6 7 8 curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "permission": "read" }'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 { "type": "repository_group_permission", "group": { "type": "group", "name": "Developers", "slug": "developers", "full_slug": "atlassian_tutorial:developers" }, "permission": "write", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/groups/developers" } } }
DEL

Delete an explicit group permission for a repository

Deletes the repository group permission between the requested repository and group, if one exists. Only users with admin permission for the repository may access this resource. The only authentication method supported for this endpoint is via app passwords.

repository:admin

Request

Path parameters

group_slug

string

Required
repo_slug

string

Required
workspace

string

Required

Responses

Group permission deleted

DEL/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}
1 2 3 curl --request DELETE \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}' \ --header 'Authorization: Bearer <access_token>'
GET

List explicit user permissions for a repository

Returns a paginated list of explicit user permissions for the given repository. This endpoint does not support BBQL features.

Scopes
repository:admin
read:repository:bitbucket, read:user:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

Paginated of explicit user permissions on the repository.

application/json

Paginated Repository User Permissions

A paginated list of repository user permissions.

GET/repositories/{workspace}/{repo_slug}/permissions-config/users
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 { "pagelen": 10, "values": [ { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } }, { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Sean Conaty", "uuid": "{504c3b62-8120-4f0c-a7bc-87800b9d6f70}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324c" }, "permission": "write", "links": { "self": { "href": "https://api.bitbucket.org/2.0//repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324c" } } } ], "page": 1, "size": 2 }
GET

Get an explicit user permission for a repository

Returns the explicit user permission for a given user and repository.

Only users with admin permission for the repository may access this resource.

Permissions can be:

  • admin
  • write
  • read
  • none
Scopes
repository:admin
read:repository:bitbucket, read:user:bitbucket

Request

Path parameters

repo_slug

string

Required
selected_user_id

string

Required
workspace

string

Required

Responses

Explicit user permission for user and repository

application/json

Repository User Permission

A user's direct permission for a given repository.

GET/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a", "nickname": "Colin Cameron" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } }
PUT

Update an explicit user permission for a repository

Updates the explicit user permission for a given user and repository. The selected user must be a member of the workspace, and cannot be the workspace owner. Only users with admin permission for the repository may access this resource.

The only authentication method for this endpoint is via app passwords.

Permissions can be:

  • admin
  • write
  • read
repository:admin

Request

Path parameters

repo_slug

string

Required
selected_user_id

string

Required
workspace

string

Required

Request bodyapplication/json

The permission to grant

permission

string

Required

Responses

Explicit user permission updated

application/json

Repository User Permission

A user's direct permission for a given repository.

PUT/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}
1 2 3 4 5 6 7 8 curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "permission": "read" }'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a", "nickname": "Colin Cameron" }, "permission": "write", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } }
DEL

Delete an explicit user permission for a repository

Deletes the repository user permission between the requested repository and user, if one exists. Only users with admin permission for the repository may access this resource. The only authentication method for this endpoint is via app passwords.

repository:admin

Request

Path parameters

repo_slug

string

Required
selected_user_id

string

Required
workspace

string

Required

Responses

The repository user permission was deleted and no content returned.

DEL/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}
1 2 3 curl --request DELETE \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}' \ --header 'Authorization: Bearer <access_token>'
GET

List repositories watchers

Returns a paginated list of all the watchers on the specified repository.

Scopes
repository
read:repository:bitbucket

Request

Path parameters

repo_slug

string

Required
workspace

string

Required

Responses

A paginated list of all the watchers on the specified repository.

application/json

Paginated Accounts

A paginated list of accounts.

GET/repositories/{workspace}/{repo_slug}/watchers
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/watchers' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "size": 142, "page": 102, "pagelen": 159, "next": "<string>", "previous": "<string>", "values": [ { "type": "<string>", "links": {}, "created_on": "<string>", "display_name": "<string>", "uuid": "<string>" } ] }
GET

List repository permissions for a user

Returns an object for each repository the caller has explicit access to and their effective permission — the highest level of permission the caller has. This does not return public repositories that the user was not granted any specific permission in, and does not distinguish between explicit and implicit privileges.

Permissions can be:

  • admin
  • write
  • read

Results may be further filtered or sorted by repository or permission by adding the following query string parameters:

  • q=repository.name="geordi" or q=permission>"read"
  • sort=repository.name

Note that the query parameter values need to be URL escaped so that = would become %3D.

account
,
repository

Request

Query parameters

q

string

sort

string

Responses

Repository permissions for the repositories a caller has explicit access to.

application/json

Paginated Repository Permissions

A paginated list of repository permissions.

GET/user/permissions/repositories
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/user/permissions/repositories' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 { "pagelen": 10, "values": [ { "type": "repository_permission", "user": { "type": "user", "nickname": "evzijst", "display_name": "Erik van Zijst", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}" }, "repository": { "type": "repository", "name": "geordi", "full_name": "bitbucket/geordi", "uuid": "{85d08b4e-571d-44e9-a507-fa476535aa98}" }, "permission": "admin" } ], "page": 1, "size": 1 }

Rate this page: