GitHub v3 REST API

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

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

Response

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

Get admin branch 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/enforce_admins

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

200 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/enforce_admins
 
200 application/json

Set admin branch 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.

Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

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

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

200 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/enforce_admins
 
200 application/json

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

Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

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

Path Parameters

ownerstringrequired
repostringrequired
branchstringrequired

The name of the branch.

Response

Response

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

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