# Update pull request review protection

From **GitHub v3 REST API**.

`PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews`

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.

Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

**Note**: Passing new arrays of `users` and `teams` replaces their previous values.

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

### `branch`

- Location: path
- Required: true
- Type: `string`

The name of the branch.

## Request body

- Required: false
### `application/json`

- Type: `object`

```json
{
  "bypass_pull_request_allowances": {
    "teams": [
      "justice-league"
    ],
    "users": [
      "octocat"
    ]
  },
  "dismiss_stale_reviews": true,
  "dismissal_restrictions": {
    "teams": [
      "justice-league"
    ],
    "users": [
      "octocat"
    ]
  },
  "require_code_owner_reviews": true,
  "required_approving_review_count": 2
}
```

```json
{"properties":{"dismiss_stale_reviews":{"description":"Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit.","type":"boolean"},"dismissal_restrictions":{"description":"Specify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories.","properties":{"teams":{"description":"The list of team `slug`s with dismissal access","items":{"type":"string"},"type":"array"},"users":{"description":"The list of user `login`s with dismissal access","items":{"type":"string"},"type":"array"}},"type":"object"},"require_code_owner_reviews":{"description":"Blocks merging pull requests until [code owners](https://docs.github.com/articles/about-code-owners/) have reviewed.","type":"boolean"},"required_approving_review_count":{"description":"Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6.","type":"integer"}},"type":"object"}
```

## Responses

### `200`

Response

### `application/json`

- Type: `object`

Protected Branch Pull Request Review

```json
{
  "dismiss_stale_reviews": true,
  "dismissal_restrictions": {
    "teams": [
      {
        "description": "A great team.",
        "html_url": "https://github.com/orgs/github/teams/justice-league",
        "id": 1,
        "members_url": "https://api.github.com/teams/1/members{/member}",
        "name": "Justice League",
        "node_id": "MDQ6VGVhbTE=",
        "parent": null,
        "permission": "admin",
        "privacy": "closed",
        "repositories_url": "https://api.github.com/teams/1/repos",
        "slug": "justice-league",
        "url": "https://api.github.com/teams/1"
      }
    ],
    "teams_url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions/teams",
    "url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions",
    "users": [
      {
        "avatar_url": "https://github.com/images/error/octocat_happy.gif",
        "events_url": "https://api.github.com/users/octocat/events{/privacy}",
        "followers_url": "https://api.github.com/users/octocat/followers",
        "following_url": "https://api.github.com/users/octocat/following{/other_user}",
        "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
        "gravatar_id": "",
        "html_url": "https://github.com/octocat",
        "id": 1,
        "login": "octocat",
        "node_id": "MDQ6VXNlcjE=",
        "organizations_url": "https://api.github.com/users/octocat/orgs",
        "received_events_url": "https://api.github.com/users/octocat/received_events",
        "repos_url": "https://api.github.com/users/octocat/repos",
        "site_admin": false,
        "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
        "type": "User",
        "url": "https://api.github.com/users/octocat"
      }
    ],
    "users_url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions/users"
  },
  "require_code_owner_reviews": true,
  "required_approving_review_count": 2,
  "url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/required_pull_request_reviews"
}
```

```json
{"description":"Protected Branch Pull Request Review","properties":{"dismiss_stale_reviews":{"example":true,"type":"boolean"},"dismissal_restrictions":{"properties":{"teams":{"description":"The list of teams with review dismissal access.","items":{"$ref":"#/components/schemas/team"},"type":"array"},"teams_url":{"example":"\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/teams\"","type":"string"},"url":{"example":"\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions\"","type":"string"},"users":{"description":"The list of users with review dismissal access.","items":{"$ref":"#/components/schemas/simple-user"},"type":"array"},"users_url":{"example":"\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/users\"","type":"string"}},"type":"object"},"require_code_owner_reviews":{"example":true,"type":"boolean"},"required_approving_review_count":{"example":2,"maximum":6,"minimum":1,"type":"integer"},"url":{"example":"https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions","format":"uri","type":"string"}},"required":["dismiss_stale_reviews","require_code_owner_reviews"],"title":"Protected Branch Pull Request Review","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request PATCH \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews \
  --header 'content-type: application/json' \
  --data '{
  "bypass_pull_request_allowances": {
    "teams": [
      "justice-league"
    ],
    "users": [
      "octocat"
    ]
  },
  "dismiss_stale_reviews": true,
  "dismissal_restrictions": {
    "teams": [
      "justice-league"
    ],
    "users": [
      "octocat"
    ]
  },
  "require_code_owner_reviews": true,
  "required_approving_review_count": 2
}'
```
