Trying to create a branch permission, What should be structure of my JSON payload
Asked by sidhant:

I'm using this API endpoint as mentioned in the documentation:  
<https://developer.atlassian.com/cloud/bitbucket/rest/api-group-branch-restrictions/#api-repositories-workspace-repo-slug-branch-restrictions-post>  

These are the permission i want to give:  

![Screenshot 2023-06-04 at 6.23.51 PM.png](/t5/image/serverpage/image-id/261177iB1397B8A75889DE1/image-size/large?v=v2&px=999 "Screenshot 2023-06-04 at 6.23.51 PM.png")![Screenshot 2023-06-04 at 6.24.05 PM.png](/t5/image/serverpage/image-id/261178i9E431DCA8BEF5715/image-size/large?v=v2&px=999 "Screenshot 2023-06-04 at 6.24.05 PM.png")


Answers:
author: Theodora Boudale
body: Hi [@sidhant](/t5/user/viewprofilepage/user-id/5233173),

I am posting below the data that is required for each branch restriction. Please keep in mind that each one of them needs to be created with a separate API call:

```
{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "push",
"users": [{"uuid": "{bt6e7413-je0e-4k93-68a2-00g19416f787}"}]
}'

where bt6e7413-je0e-4k93-68a2-00g19416f787 replace with the UUID of the user you want to add


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "force",
"value": null
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "delete",
"value": null
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_approvals_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_default_reviewer_approvals_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_no_changes_requested"
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_passing_builds_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_commits_behind",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "reset_pullrequest_changes_requested_on_change"
}
```

Please feel free to reach out if you have any questions.

Kind regards,  
Theodora

comments: author: Elena Dzhordzhilova
body: Hello,

I have a question regarding "kind": "push". I would want to know if there is a way to update the branch restriction with list of users. I am using ***uuid*** of the users with the following ***paylaod*** and ***PUT***request:

```
{
    "branch_match_kind": "glob",
    "users": [{
        "uuid": user_uuid (here I use variable and I want to add multiple users)
    }],
    "kind": "push",
    "pattern": branch-name
```

The result is that when I execute the request, only one user is being added (the last one) and all other users are being removed from the list - does not matter if they are added by hand via the interface or with script.


author: Theodora Boudale
body: Hi Elena,

You can add multiple users with the following data:

```
{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "push",
"users": [{"uuid": "{bt6e7413-je0e-4k93-68a2-00g19416f787}"}, {"uuid": "{ae5u9460-be7r-2k65-68v4-74a62825h487}"}]
}
```

Please keep in mind that if there is an existing branch restriction for the branch and userA has permission to push, if you run an API call to add userB and userC then userA is going to be removed. You will need to run an API call that includes all three users if you don't want userA to be removed.

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-development

cloud

rest-api