Skip to main content

Get 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](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.

GET/repos/{owner}/{repo}/branches/{branch}/protection
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
owner string
required
repo string
required
branch string
required

The name of the branch.

Responses

application/json Branch Protection object

Response

allow_deletions object
optional
enabled boolean
optional
allow_force_pushes object
optional
enabled boolean
optional
enabled boolean
optional
enforce_admins Protected Branch Admin Enforced object
optional

Protected Branch Admin Enforced

enabled boolean
required

Example: true

url string<uri>
required

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

name string
optional

Example: "branch/with/protection"

protection_url string
optional
Example:
"https://api.github.com/repos/owner-79e94e2d36b3fd06a32bb213/AAA_Public_Repo/branches/branch/with/protection/protection"
required_conversation_resolution object
optional
enabled boolean
optional
required_linear_history object
optional
enabled boolean
optional
required_pull_request_reviews Protected Branch Pull Request Review object
optional

Protected Branch Pull Request Review

dismiss_stale_reviews boolean
required

Example: true

dismissal_restrictions object
optional
teams array[Team object]
optional

The list of teams with review dismissal access.

teams_url string
optional
Example:
"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/teams"
url string
optional
Example:
"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions"
users array[Simple User object]
optional

The list of users with review dismissal access.

users_url string
optional
Example:
"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/users"
require_code_owner_reviews boolean
required

Example: true

required_approving_review_count integer
optional

Example: 2

url string<uri>
optional
Example:
https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions
required_signatures object
optional
enabled boolean
required

Example: true

url string<uri>
required

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

required_status_checks Protected Branch Required Status Check object
optional

Protected Branch Required Status Check

contexts array[string]
required
contexts_url string
optional
enforcement_level string
optional
strict boolean
optional
url string
optional
restrictions Branch Restriction Policy object
optional

Branch Restriction Policy

apps array[object]
required
items object
created_at string
optional
description string
optional
events array
optional
external_url string
optional
html_url string
optional
id integer
optional
name string
optional
node_id string
optional
owner object
optional
permissions object
optional
slug string
optional
updated_at string
optional
apps_url string<uri>
required
teams array[object]
required
items object
description string
optionalnullable
html_url string
optional
id integer
optional
members_url string
optional
name string
optional
node_id string
optional
parent string
optionalnullable
permission string
optional
privacy string
optional
repositories_url string
optional
slug string
optional
url string
optional
teams_url string<uri>
required
url string<uri>
required
users array[object]
required
items object
avatar_url string
optional
events_url string
optional
followers_url string
optional
following_url string
optional
gists_url string
optional
gravatar_id string
optional
html_url string
optional
id integer
optional
login string
optional
node_id string
optional
organizations_url string
optional
received_events_url string
optional
repos_url string
optional
site_admin boolean
optional
starred_url string
optional
subscriptions_url string
optional
type string
optional
url string
optional
users_url string<uri>
required
url string
optional
application/json Basic Error object

Resource not found

documentation_url string
optional
message string
optional
status string
optional
url string
optional