GET
GET /repos/{owner}/{repo}/branches/{branch}/protection — GitHub API
GitHub token (required); https://api.github.com
GitHub APIGet branch protection
- Base URL
- https://api.github.com
- Auth
- Authorization: Bearer <GITHUB_API_KEY>
- Last verified
- 2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 227 tokens · Vary: Accept
→ 227 tokens · Vary: Accept
Critical gotchas
GitHub recommends an Accept: application/vnd.github+json header and an explicit X-GitHub-Api-Version header.
Fine-grained tokens only authorize repositories and permissions selected when the token is created.
cURL
curl -X GET 'https://api.github.com/repos/example-owner/example-repo/branches/example-branch/protection' \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -H 'Accept: application/vnd.github+json' \ -H 'X-GitHub-Api-Version: 2026-03-10'
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| owner | path | string | Yes | The account owner of the repository. The name is not case sensitive. |
| repo | path | string | Yes | The name of the repository without the `.git` extension. The name is not case sensitive. |
| branch | path | string | Yes | 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). |
Response 200 OK
{
"url": "string",
"enabled": true,
"required_status_checks": {
"url": "string",
"enforcement_level": "string",
"contexts": [
"string"
],
"checks": [
{
"context": "string",
"app_id": 0
}
],
"contexts_url": "string",
"strict": true
},
"enforce_admins": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/enforce_admins",
"enabled": true
},
"required_pull_request_reviews": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions",
"dismissal_restrictions": {
"users": [
{
"name": "string",
"email": "string",
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "41d064eb2195891e12d0413f63227ea7",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"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}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": true,
"starred_at": "\"2020-07-09T00:17:55Z\"",
"user_view_type": "public"
}
],
"teams": [
{
"id": 0,
"node_id": "string",
"name": "string",
"slug": "string",
"description": "string",
"privacy": "string",
"notification_setting": "string",
"permission": "string",
"permissions": {
"pull": "[recursive or deeply nested schema]",
"triage": "[recursive or deeply nested schema]",
"push": "[recursive or deeply nested schema]",
"maintain": "[recursive or deeply nested schema]",
"admin": "[recursive or deeply nested schema]"
},
"url": "https://example.com",
"html_url": "https://github.com/orgs/rails/teams/core",
"members_url": "string",
"repositories_url": "https://example.com",
"type": "enterprise",
"access_source": "direct",
"organization_id": 37,
"enterprise_id": 42,
"parent": {
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"members_url": "[recursive or deeply nested schema]",
"name": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"permission": "[recursive or deeply nested schema]",
"privacy": "[recursive or deeply nested schema]",
"notification_setting": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"repositories_url": "[recursive or deeply nested schema]",
"slug": "[recursive or deeply nested schema]",
"ldap_dn": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"organization_id": "[recursive or deeply nested schema]",
"enterprise_id": "[recursive or deeply nested schema]"
}
}
],
"apps": [
{
"id": 37,
"slug": "probot-owners",
"node_id": "MDExOkludGVncmF0aW9uMQ==",
"client_id": "\"Iv1.25b5d1e65ffc4022\"",
"owner": {
"name": "[recursive or deeply nested schema]",
"email": "[recursive or deeply nested schema]",
"login": "[recursive or deeply nested schema]",
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"avatar_url": "[recursive or deeply nested schema]",
"gravatar_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"followers_url": "[recursive or deeply nested schema]",
"following_url": "[recursive or deeply nested schema]",
"gists_url": "[recursive or deeply nested schema]",
"starred_url": "[recursive or deeply nested schema]",
"subscriptions_url": "[recursive or deeply nested schema]",
"organizations_url": "[recursive or deeply nested schema]",
"repos_url": "[recursive or deeply nested schema]",
"events_url": "[recursive or deeply nested schema]",
"received_events_url": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"site_admin": "[recursive or deeply nested schema]",
"starred_at": "[recursive or deeply nested schema]",
"user_view_type": "[recursive or deeply nested schema]"
},
"name": "Probot Owners",
"description": "The description of the app.",
"external_url": "https://example.com",
"html_url": "https://github.com/apps/super-ci",
"created_at": "2017-07-08T16:18:44-04:00",
"updated_at": "2017-07-08T16:18:44-04:00",
"permissions": {
"issues": "read",
"deployments": "write"
},
"events": [
"label",
"deployment"
],
"installations_count": 5
}
],
"url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions\"",
"users_url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/users\"",
"teams_url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/teams\""
},
"bypass_pull_request_allowances": {
"users": [
{
"name": "string",
"email": "string",
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "41d064eb2195891e12d0413f63227ea7",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"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}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": true,
"starred_at": "\"2020-07-09T00:17:55Z\"",
"user_view_type": "public"
}
],
"teams": [
{
"id": 0,
"node_id": "string",
"name": "string",
"slug": "string",
"description": "string",
"privacy": "string",
"notification_setting": "string",
"permission": "string",
"permissions": {
"pull": "[recursive or deeply nested schema]",
"triage": "[recursive or deeply nested schema]",
"push": "[recursive or deeply nested schema]",
"maintain": "[recursive or deeply nested schema]",
"admin": "[recursive or deeply nested schema]"
},
"url": "https://example.com",
"html_url": "https://github.com/orgs/rails/teams/core",
"members_url": "string",
"repositories_url": "https://example.com",
"type": "enterprise",
"access_source": "direct",
"organization_id": 37,
"enterprise_id": 42,
"parent": {
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"members_url": "[recursive or deeply nested schema]",
"name": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"permission": "[recursive or deeply nested schema]",
"privacy": "[recursive or deeply nested schema]",
"notification_setting": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"repositories_url": "[recursive or deeply nested schema]",
"slug": "[recursive or deeply nested schema]",
"ldap_dn": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"organization_id": "[recursive or deeply nested schema]",
"enterprise_id": "[recursive or deeply nested schema]"
}
}
],
"apps": [
{
"id": 37,
"slug": "probot-owners",
"node_id": "MDExOkludGVncmF0aW9uMQ==",
"client_id": "\"Iv1.25b5d1e65ffc4022\"",
"owner": {
"name": "[recursive or deeply nested schema]",
"email": "[recursive or deeply nested schema]",
"login": "[recursive or deeply nested schema]",
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"avatar_url": "[recursive or deeply nested schema]",
"gravatar_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"followers_url": "[recursive or deeply nested schema]",
"following_url": "[recursive or deeply nested schema]",
"gists_url": "[recursive or deeply nested schema]",
"starred_url": "[recursive or deeply nested schema]",
"subscriptions_url": "[recursive or deeply nested schema]",
"organizations_url": "[recursive or deeply nested schema]",
"repos_url": "[recursive or deeply nested schema]",
"events_url": "[recursive or deeply nested schema]",
"received_events_url": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"site_admin": "[recursive or deeply nested schema]",
"starred_at": "[recursive or deeply nested schema]",
"user_view_type": "[recursive or deeply nested schema]"
},
"name": "Probot Owners",
"description": "The description of the app.",
"external_url": "https://example.com",
"html_url": "https://github.com/apps/super-ci",
"created_at": "2017-07-08T16:18:44-04:00",
"updated_at": "2017-07-08T16:18:44-04:00",
"permissions": {
"issues": "read",
"deployments": "write"
},
"events": [
"label",
"deployment"
],
"installations_count": 5
}
]
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": true
},
"restrictions": {
"url": "https://example.com",
"users_url": "https://example.com",
"teams_url": "https://example.com",
"apps_url": "https://example.com",
"users": [
{
"login": "string",
"id": 0,
"node_id": "string",
"avatar_url": "string",
"gravatar_id": "string",
"url": "string",
"html_url": "string",
"followers_url": "string",
"following_url": "string",
"gists_url": "string",
"starred_url": "string",
"subscriptions_url": "string",
"organizations_url": "string",
"repos_url": "string",
"events_url": "string",
"received_events_url": "string",
"type": "string",
"site_admin": true,
"user_view_type": "string"
}
],
"teams": [
{
"id": 0,
"node_id": "string",
"name": "string",
"slug": "string",
"description": "string",
"privacy": "string",
"notification_setting": "string",
"permission": "string",
"permissions": {
"pull": true,
"triage": true,
"push": true,
"maintain": true,
"admin": true
},
"url": "https://example.com",
"html_url": "https://github.com/orgs/rails/teams/core",
"members_url": "string",
"repositories_url": "https://example.com",
"type": "enterprise",
"access_source": "direct",
"organization_id": 37,
"enterprise_id": 42,
"parent": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/organizations/1/team/1",
"members_url": "https://api.github.com/organizations/1/team/1/members{/member}",
"name": "Justice League",
"description": "A great team.",
"permission": "admin",
"privacy": "closed",
"notification_setting": "notifications_enabled",
"html_url": "https://github.com/orgs/rails/teams/core",
"repositories_url": "https://api.github.com/organizations/1/team/1/repos",
"slug": "justice-league",
"ldap_dn": "uid=example,ou=users,dc=github,dc=com",
"type": "enterprise",
"organization_id": 37,
"enterprise_id": 42
}
}
],
"apps": [
{
"id": 0,
"slug": "string",
"node_id": "string",
"owner": {
"login": "string",
"id": 0,
"node_id": "string",
"url": "string",
"repos_url": "string",
"events_url": "string",
"hooks_url": "string",
"issues_url": "string",
"members_url": "string",
"public_members_url": "string",
"avatar_url": "string",
"description": "string",
"gravatar_id": "\"\"",
"html_url": "\"https://github.com/testorg-ea8ec76d71c3af4b\"",
"followers_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/followers\"",
"following_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/following{/other_user}\"",
"gists_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/gists{/gist_id}\"",
"starred_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/starred{/owner}{/repo}\"",
"subscriptions_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/subscriptions\"",
"organizations_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/orgs\"",
"received_events_url": "\"https://api.github.com/users/testorg-ea8ec76d71c3af4b/received_events\"",
"type": "\"Organization\"",
"site_admin": false,
"user_view_type": "public"
},
"name": "string",
"client_id": "string",
"description": "string",
"external_url": "string",
"html_url": "string",
"created_at": "string",
"updated_at": "string",
"permissions": {
"metadata": "string",
"contents": "string",
"issues": "string",
"single_file": "string"
},
"events": [
"string"
]
}
]
},
"required_linear_history": {
"enabled": true
},
"allow_force_pushes": {
"enabled": true
},
"allow_deletions": {
"enabled": true
},
"block_creations": {
"enabled": true
},
"required_conversation_resolution": {
"enabled": true
},
"name": "\"branch/with/protection\"",
"protection_url": "\"https://api.github.com/repos/owner-79e94e2d36b3fd06a32bb213/AAA_Public_Repo/branches/branch/with/protection/protection\"",
"required_signatures": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/required_signatures",
"enabled": true
},
"lock_branch": {
"enabled": false
},
"allow_fork_syncing": {
"enabled": false
}
} Get a free GitHub API key → sponsored Affiliate link - we may earn a commission, at no extra cost to you.