Rate this page:
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 /2.0/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
string
Filter the results to include only repositories created on or
after this ISO-8601
timestamp. Example: YYYY-MM-DDTHH:mm:ss.sssZ
string
Filters the result based on the authenticated user's role on each repository.
Valid values: admin
, contributor
, member
, owner
string
Query string to narrow down the response as per filtering and sorting.
role
parameter must also be specified.
string
Field by which the results should be sorted as per filtering and sorting.
1 2 3 4
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json'
All public repositories.
Content type | Value |
---|---|
application/json |
GET /2.0/repositories/{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.
repository
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
string
Filters the result based on the authenticated user's role on each repository.
Valid values: admin
, contributor
, member
, owner
string
Query string to narrow down the response as per filtering and sorting.
string
Field by which the results should be sorted as per filtering and sorting.
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'
The repositories owned by the specified account.
Content type | Value |
---|---|
application/json |
GET /2.0/repositories/{workspace}/{repo_slug}
Returns the object describing this repository.
repository
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
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'
The repository object.
Content type | Value |
---|---|
application/json | allOf [object, Repository] |
PUT /2.0/repositories/{workspace}/{repo_slug}
Since this endpoint can be used to both update and to create a repository, the request body depends on the intent.
See the POST documentation for the repository endpoint for an example of the request body.
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.
repository:admin
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
Content type | Value |
---|---|
application/json | allOf [object, Repository] |
1 2 3 4
curl --request PUT \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json'
The existing repository has been updated
Content type | Value |
---|---|
application/json | allOf [object, Repository] |
string
The location of the repository. This header is only provided when the repository's name is changed.
POST /2.0/repositories/{workspace}/{repo_slug}
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$ 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$ 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.
repository:admin
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
Content type | Value |
---|---|
application/json | allOf [object, Repository] |
1 2 3 4
curl --request POST \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json'
The newly created repository.
Content type | Value |
---|---|
application/json | allOf [object, Repository] |
DELETE /2.0/repositories/{workspace}/{repo_slug}
Deletes the repository. This is an irreversible operation. This does not affect its forks.
repository:delete
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
string
If a repository has been moved to a new location, use this parameter to show users a friendly message in the Bitbucket UI that the repository has moved to a new location. However, a GET to this endpoint will still return a 404.
1 2 3
curl --request DELETE \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \
--header 'Authorization: Bearer <access_token>'
Indicates successful deletion.
GET /2.0/repositories/{workspace}/{repo_slug}/forks
Returns a paginated list of all the forks of the specified repository.
repository
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
string
Filters the result based on the authenticated user's role on each repository.
Valid values: admin
, contributor
, member
, owner
string
Query string to narrow down the response as per filtering and sorting.
string
Field by which the results should be sorted as per filtering and sorting.
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'
All forks.
Content type | Value |
---|---|
application/json |
POST /2.0/repositories/{workspace}/{repo_slug}/forks
Creates a new fork of the specified repository.
To create a fork, specify the workspace explicitly as part of the request body:
1 2$ 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