Addon
Branch restrictions
Branching model
Commit statuses
Commits
Deployments
Downloads
Issue tracker
Pipelines
Projects
Pullrequests
Refs
Reports
Repositories
Snippets
Source
Ssh
Teams
Users
Webhooks
Workspaces
Other operations

Rate this page:

Branch restrictions

Repository owners and administrators can set branch management rules on a repository that control what can be pushed by whom. Through these rules, you can enforce a project or team workflow. For example, owners or administrators can:

  • Limit push powers
  • Prevent branch deletion
  • Prevent history re-writes (Git only)

List branch restrictions

GET /2.0/repositories/{workspace}/{repo_slug}/branch-restrictions

Returns a paginated list of all branch restrictions on the repository.

OAuth scopes required
repository:admin

Request

Path parameters
repo_slug Required

string

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

Query parameters
kind

string

Branch restrictions of this type

pattern

string

Branch restrictions applied to branches of this pattern

Example

1
2
3
4
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/branch-restrictions' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

A paginated list of branch restrictions

Content typeValue
application/json

Paginated Branch Restrictions

Create a branch restriction rule

POST /2.0/repositories/{workspace}/{repo_slug}/branch-restrictions

Creates a new branch restriction rule for a repository.

kind describes what will be restricted. Allowed values include: push, force,