GitHub v3 REST API

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

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

200 application/json

Response

Protected Branch Pull Request Review

Protected Branch Pull Request Review

urlstring(uri)

Example:https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions

dismissal_restrictionsobject
Show Child Parameters
dismiss_stale_reviewsbooleanrequired

Example:true

require_code_owner_reviewsbooleanrequired

Example:true

required_approving_review_countinteger

>= 1<= 6

Example:2

get/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
 
200 application/json

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.

patch
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Body

application/json
dismissal_restrictionsobject

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.

Show Child Parameters
dismiss_stale_reviewsboolean

Set to true if you want to automatically dismiss approving reviews when someone pushes a new commit.

require_code_owner_reviewsboolean

Blocks merging pull requests until code owners have reviewed.

required_approving_review_countinteger

Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6.

Response

application/json

Response

Protected Branch Pull Request Review

Protected Branch Pull Request Review

urlstring(uri)

Example:https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions

dismissal_restrictionsobject
Show Child Parameters
dismiss_stale_reviewsbooleanrequired

Example:true

require_code_owner_reviewsbooleanrequired

Example:true

required_approving_review_countinteger

>= 1<= 6

Example:2

patch/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

Body

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

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

delete
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

Response

delete/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
 

Get commit signature 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.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of true indicates you must sign commits on this branch. For more information, see Signing commits with GPG in GitHub Help.

Note: You must enable branch protection to require signed commits.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

application/json

Response

Protected Branch Admin Enforced

Protected Branch Admin Enforced

urlstring(uri)required

Example:https://api.github.com/repos/octocat/Hello-World/branches/master/protection/enforce_admins

enabledbooleanrequired

Example:true

get/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures
 
application/json

Create commit signature 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.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits.

post
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

application/json

Response

Protected Branch Admin Enforced

Protected Branch Admin Enforced

urlstring(uri)required

Example:https://api.github.com/repos/octocat/Hello-World/branches/master/protection/enforce_admins

enabledbooleanrequired

Example:true

post/repos/{owner}/{repo}/branches/{branch}/protection/required_signatures
 
application/json