Skip to end of metadata
Go to start of metadata

 

Overview

This resource manages the branch restrictions on a repository. This resource has the following fields:

FieldDescription
pagelenAn integer representing how many items to return per page. The default value is 10 and the maximum is 50. The caller can specify this value.
nextThe URL of the next page in the series. Only returned when there is a next page.
valuesAn array of restriction data.
pageAn integer representing the current page.
previousThe URL of the previous page in the series. Only returned when there is a previous page.
sizeThe total number of items.

 The values array takes the following:

FieldDescription
groupsAn array of groups profiles corresponding to a set of groups. This field is always empty for delete and force restrictions.
idThe URL of the next page in the series. Only returned when there is a next page.
kind

Type of restriction. This can be one of:

  • push
  • delete
  • force 
linksAn array of links for making REST calls to this resource.
patternA repository pattern to match. This is only applied when kind is push. Accepts wildcards.
users An array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions.

When creating POST or PUT calls, the easiest way to pass data is as a JSON structure: 

To pass this to a curl call, create a file called body.json and pass it with the --data flag to curl:

curl -v --request POST --user username https://bitbucket.org/api/2.0/repositories/{usersname}/{repo-slug}/branch-restrictions  --header 'Content-Type: application/json; charset=utf-8' --data @json.data

GET the branch-restrictions

Gets the information associated with a repository's branch restrictions.  This call takes the following parameters:

ParameterRequiredDescription
accountnameYesThe account owner.
repoYesThe repository name.

 

GET https://bitbucket.org/api/2.0/repositories/{username}/{repo-slug}/branch-restrictions
 Click to expand and view a response...

POST the branch-restrictions

Creates restrictions for the specified repository. You should specify a Content-Header with this call.  This call takes the following parameters:

ParameterRequiredDescription
accountname YesThe account owner.
repoYesThe repository name.
groupsNoOne or more groups. This field is always empty for delete and force restrictions.
kindYes

Type of restriction. This can be one of:

  • push
  • delete
  • force 
patternNoA repository pattern to match. This is only required when kind is [. Accepts wildcards.
users NoAn array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions.
POST https://bitbucket.org/api/2.0/repositories/{username}/{repo-slug}/branch-restrictions --header 'Content-Type: application/json; charset=utf-8' --data @json.data
Example curl comand
Example: body of call to add user branch restriction  Expand source
Response from add user branch restriction call  Expand source
Example: body of call to add group branch restriction  Expand source
Response from add group branch restriction call  Expand source

GET a specific restriction

Gets the information associated with specific restriction.  This call takes the following parameters:

ParameterRequiredDescription
accountnameYesThe account owner.
repoYesThe repository name.
idYesThe restriction's identifier.
GET https://bitbucket.org/api/2.0/repositories/{username}/{repo-slug}/branch-restrictions/{id}
 Click to expand and view a response...

PUT a branch restriction update

Updates a specific branch restriction. You cannot change the kind value with this call.  This call takes the following parameters:

ParameterRequiredDescription
accountnameYesThe account owner.
repoYesThe repository name.
groupsNoOne or more groups. This field is always empty for delete and force restrictions.
idYesThe restriction identifier.
patternNoA repository pattern to match. This is only required when kind is push. Accepts wildcards.
usersNoAn array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions.
PUT https://bitbucket.org/api/2.0/repositories/{username}/{repo-slug}/branch-restrictions/{id}
 Click to expand and view a response...

DELETE the branch restriction

Deletes the specified restriction.  This call takes the following parameters:

ParameterRequiredDescription
accountnameYesThe account owner.
repoYesThe repository name.
idYesThe restriction identifier.
DELETE https://bitbucket.org/api/2.0/repositories/{username}/{repo-slug}/branch-restrictions/{id}
  • No labels

5 Comments

  1. I think POST the branch-restrictions requires more information regarding the parameters.

    1. Also, any example for POST the branch restrictions for push?

      1. Good day,

        I'm going to look into that and hopefully will have a better answer / response tomorrow. 

        Thanks for commenting.

      2. Bogdan, just to update you. I am working on updates to the documetation for this resource.

        Thank you for putting my eyes back on it. (smile)

    2. Good day Bogdan Taranu I've updated the post portion of this API please let me know if this helps.