Sample - GitHub REST API
PATCH/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

Update pull request review protection

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 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.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 6 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
branchstringrequired
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql).
dismissal_restrictionsobjectoptional
Specify which users, teams, and apps 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.
dismiss_stale_reviewsbooleanoptional
Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit.
require_code_owner_reviewsbooleanoptional
Blocks merging pull requests until [code owners](https://docs.github.com/articles/about-code-owners/) have reviewed.
required_approving_review_countintegeroptional
Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers.
require_last_push_approvalbooleanoptional
Whether the most recent push must be approved by someone other than the person who pushed it. Default: `false`
Default:false
bypass_pull_request_allowancesobjectoptional
Allow specific users, teams, or apps to bypass pull request requirements.

2 status codes
200Response
urlstringoptional
dismissal_restrictionsobjectoptional
bypass_pull_request_allowancesobjectoptional
Allow specific users, teams, or apps to bypass pull request requirements.
dismiss_stale_reviewsbooleanrequired
require_code_owner_reviewsbooleanrequired
required_approving_review_countintegeroptional
require_last_push_approvalbooleanoptional
Whether the most recent push must be approved by someone other than the person who pushed it.
Default:false
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 422 is returned: Validation failed, or the endpoint has been spammed.