Use the REST API to manage protected branches.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /repos/{owner}/{repo}/branches/{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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection
Response schema (Status: 200):
url: stringenabled: booleanrequired_status_checks: Protected Branch Required Status Check:
url: stringenforcement_level: stringcontexts: required, array of stringchecks: required, array of objects:
context: required, stringapp_id: required, integer or nullcontexts_url: stringstrict: booleanenforce_admins: Protected Branch Admin Enforced:
url: required, string, format: urienabled: required, booleanrequired_pull_request_reviews: Protected Branch Pull Request Review:
url: string, format: uridismissal_restrictions: object:
users: array of Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringteams: array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerapps: array of GitHub app:
id: required, integerslug: stringnode_id: required, stringclient_id: stringowner: required, one of:
description: string or nullhtml_url: required, string, format: uriwebsite_url: string or null, format: uriid: required, integernode_id: required, stringname: required, stringslug: required, stringcreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeavatar_url: required, string, format: uriname: required, stringdescription: required, string or nullexternal_url: required, string, format: urihtml_url: required, string, format: uricreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timepermissions: required, object, additional properties: string:
issues: stringchecks: stringmetadata: stringcontents: stringdeployments: stringevents: required, array of stringinstallations_count: integerurl: stringusers_url: stringteams_url: stringbypass_pull_request_allowances: object:
users: array of Simple User (see above)teams: array of Team (see above)apps: array of GitHub app (see above)dismiss_stale_reviews: required, booleanrequire_code_owner_reviews: required, booleanrequired_approving_review_count: integer, minimum: 0, maximum: 6require_last_push_approval: boolean, default: falserestrictions: Branch Restriction Policy:
url: required, string, format: uriusers_url: required, string, format: uriteams_url: required, string, format: uriapps_url: required, string, format: uriusers: required, array of objects:
login: stringid: integer, format: int64node_id: stringavatar_url: stringgravatar_id: stringurl: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringrepos_url: stringevents_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringteams: required, array of Team (see above)apps: required, array of objects:
id: integerslug: stringnode_id: stringowner: object:
login: stringid: integernode_id: stringurl: stringrepos_url: stringevents_url: stringhooks_url: stringissues_url: stringmembers_url: stringpublic_members_url: stringavatar_url: stringdescription: stringgravatar_id: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringname: stringclient_id: stringdescription: stringexternal_url: stringhtml_url: stringcreated_at: stringupdated_at: stringpermissions: object:
metadata: stringcontents: stringissues: stringsingle_file: stringevents: array of stringrequired_linear_history: object:
enabled: booleanallow_force_pushes: object:
enabled: booleanallow_deletions: object:
enabled: booleanblock_creations: object:
enabled: booleanrequired_conversation_resolution: object:
enabled: booleanname: stringprotection_url: stringrequired_signatures: object:
url: required, string, format: urienabled: required, booleanlock_branch: object:
enabled: boolean, default: falseallow_fork_syncing: object:
enabled: boolean, default: falsePUT /repos/{owner}/{repo}/branches/{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.
Protecting a branch requires admin or owner permissions to the repository.
Note
Passing new arrays of users and teams replaces their previous values.
Note
The list of users, apps, and teams in total is limited to 100 items.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
required_status_checks (object or null) (required)
Require status checks to pass before merging. Set to null to disable.
strict (boolean) (required)contexts (array of strings) (required)checks (array of objects)context (string) (required)app_id (integer)enforce_admins (boolean or null) (required)
Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
required_pull_request_reviews (object or null) (required)
Require at least one approving review on a pull request, before merging. Set to null to disable.
dismissal_restrictions (object)users (array of strings)teams (array of strings)apps (array of strings)dismiss_stale_reviews (boolean)require_code_owner_reviews (boolean)required_approving_review_count (integer)require_last_push_approval (boolean)falsebypass_pull_request_allowances (object)users (array of strings)teams (array of strings)apps (array of strings)restrictions (object or null) (required)
Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories. Set to null to disable.
users (array of strings) (required)teams (array of strings) (required)apps (array of strings)required_linear_history (boolean)
Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to true to enforce a linear commit history. Set to false to disable a linear commit Git history. Your repository must allow squash merging or rebase merging before you can enable a linear commit history. Default: false. For more information, see "Requiring a linear commit history" in the GitHub Help documentation.
allow_force_pushes (boolean or null)
Permits force pushes to the protected branch by anyone with write access to the repository. Set to true to allow force pushes. Set to false or null to block force pushes. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation."
allow_deletions (boolean)
Allows deletion of the protected branch by anyone with write access to the repository. Set to false to prevent deletion of the protected branch. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation.
block_creations (boolean)
If set to true, the restrictions branch protection settings which limits who can push will also block pushes which create new branches, unless the push is initiated by a user, team, or app which has the ability to push. Set to true to restrict new branch creation. Default: false.
required_conversation_resolution (boolean)
Requires all conversations on code to be resolved before a pull request can be merged into a branch that matches this rule. Set to false to disable. Default: false.
lock_branch (boolean)
Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. Default: false.
Default: false
allow_fork_syncing (boolean)
Whether users can pull changes from upstream when the branch is locked. Set to true to allow fork syncing. Set to false to prevent fork syncing. Default: false.
Default: false
200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection \
-d '{
"required_status_checks": {
"strict": true,
"contexts": [
"continuous-integration/travis-ci"
]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"dismissal_restrictions": {
"users": [
"octocat"
],
"teams": [
"justice-league"
]
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": true,
"bypass_pull_request_allowances": {
"users": [
"octocat"
],
"teams": [
"justice-league"
]
}
},
"restrictions": {
"users": [
"octocat"
],
"teams": [
"justice-league"
],
"apps": [
"super-ci"
]
},
"required_linear_history": true,
"allow_force_pushes": true,
"allow_deletions": true,
"block_creations": true,
"required_conversation_resolution": true,
"lock_branch": true,
"allow_fork_syncing": true
}'
Response schema (Status: 200):
url: required, string, format: urirequired_status_checks: Status Check Policy:
url: required, string, format: uristrict: required, booleancontexts: required, array of stringchecks: required, array of objects:
context: required, stringapp_id: required, integer or nullcontexts_url: required, string, format: urirequired_pull_request_reviews: object:
url: required, string, format: uridismiss_stale_reviews: booleanrequire_code_owner_reviews: booleanrequired_approving_review_count: integerrequire_last_push_approval: boolean, default: falsedismissal_restrictions: object:
url: required, string, format: uriusers_url: required, string, format: uriteams_url: required, string, format: uriusers: required, array of Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringteams: required, array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerapps: array of GitHub app:
id: required, integerslug: stringnode_id: required, stringclient_id: stringowner: required, one of:
description: string or nullhtml_url: required, string, format: uriwebsite_url: string or null, format: uriid: required, integernode_id: required, stringname: required, stringslug: required, stringcreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeavatar_url: required, string, format: uriname: required, stringdescription: required, string or nullexternal_url: required, string, format: urihtml_url: required, string, format: uricreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timepermissions: required, object, additional properties: string:
issues: stringchecks: stringmetadata: stringcontents: stringdeployments: stringevents: required, array of stringinstallations_count: integerbypass_pull_request_allowances: object:
users: required, array of Simple User (see above)teams: required, array of Team (see above)apps: array of GitHub app (see above)required_signatures: object:
url: required, string, format: urienabled: required, booleanenforce_admins: object:
url: required, string, format: urienabled: required, booleanrequired_linear_history: object:
enabled: required, booleanallow_force_pushes: object:
enabled: required, booleanallow_deletions: object:
enabled: required, booleanrestrictions: Branch Restriction Policy:
url: required, string, format: uriusers_url: required, string, format: uriteams_url: required, string, format: uriapps_url: required, string, format: uriusers: required, array of objects:
login: stringid: integer, format: int64node_id: stringavatar_url: stringgravatar_id: stringurl: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringrepos_url: stringevents_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringteams: required, array of Team (see above)apps: required, array of objects:
id: integerslug: stringnode_id: stringowner: object:
login: stringid: integernode_id: stringurl: stringrepos_url: stringevents_url: stringhooks_url: stringissues_url: stringmembers_url: stringpublic_members_url: stringavatar_url: stringdescription: stringgravatar_id: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringname: stringclient_id: stringdescription: stringexternal_url: stringhtml_url: stringcreated_at: stringupdated_at: stringpermissions: object:
metadata: stringcontents: stringissues: stringsingle_file: stringevents: array of stringrequired_conversation_resolution: object:
enabled: booleanblock_creations: object:
enabled: required, booleanlock_branch: object:
enabled: boolean, default: falseallow_fork_syncing: object:
enabled: boolean, default: falseDELETE /repos/{owner}/{repo}/branches/{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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
204 - No Content
403 - Forbidden
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/enforce_admins
Response schema (Status: 200):
url: required, string, format: urienabled: required, booleanPOST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/enforce_admins
Response schema (Status: 200):
Same response schema as Get admin branch protection.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
204 - No Content
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/enforce_admins
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_pull_request_reviews
Response schema (Status: 200):
url: string, format: uridismissal_restrictions: object:
users: array of Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringteams: array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerapps: array of GitHub app:
id: required, integerslug: stringnode_id: required, stringclient_id: stringowner: required, one of:
description: string or nullhtml_url: required, string, format: uriwebsite_url: string or null, format: uriid: required, integernode_id: required, stringname: required, stringslug: required, stringcreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeavatar_url: required, string, format: uriname: required, stringdescription: required, string or nullexternal_url: required, string, format: urihtml_url: required, string, format: uricreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timepermissions: required, object, additional properties: string:
issues: stringchecks: stringmetadata: stringcontents: stringdeployments: stringevents: required, array of stringinstallations_count: integerurl: stringusers_url: stringteams_url: stringbypass_pull_request_allowances: object:
users: array of Simple User (see above)teams: array of Team (see above)apps: array of GitHub app (see above)dismiss_stale_reviews: required, booleanrequire_code_owner_reviews: required, booleanrequired_approving_review_count: integer, minimum: 0, maximum: 6require_last_push_approval: boolean, default: falsePATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
dismissal_restrictions (object)
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.
users (array of strings)teams (array of strings)apps (array of strings)dismiss_stale_reviews (boolean)
Set to true if you want to automatically dismiss approving reviews when someone pushes a new commit.
require_code_owner_reviews (boolean)
Blocks merging pull requests until code owners have reviewed.
required_approving_review_count (integer)
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_approval (boolean)
Whether the most recent push must be approved by someone other than the person who pushed it. Default: false
Default: false
bypass_pull_request_allowances (object)
Allow specific users, teams, or apps to bypass pull request requirements.
users (array of strings)teams (array of strings)apps (array of strings)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PATCH \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_pull_request_reviews \
-d '{
"dismissal_restrictions": {
"users": [
"octocat"
],
"teams": [
"justice-league"
],
"apps": [
"octoapp"
]
},
"bypass_pull_request_allowances": {
"users": [
"octocat"
],
"teams": [
"justice-league"
],
"apps": [
"octoapp"
]
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": true
}'
Response schema (Status: 200):
Same response schema as Get pull request review protection.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
204 - No Content
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_pull_request_reviews
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures
Response schema (Status: 200):
Same response schema as Get admin branch protection.
POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures
Response schema (Status: 200):
Same response schema as Get admin branch protection.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures
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 disable required signed commits on a branch. You must enable branch protection to require signed commits.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
204 - No Content
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks
Response schema (Status: 200):
url: required, string, format: uristrict: required, booleancontexts: required, array of stringchecks: required, array of objects:
context: required, stringapp_id: required, integer or nullcontexts_url: required, string, format: uriPATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks
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 required status checks requires admin or owner permissions to the repository and branch protection to be enabled.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
strict (boolean)
Require branches to be up to date before merging.
contexts (array of strings)
Closing down notice: The list of status checks to require in order to merge into this branch. If any of these checks have recently been set by a particular GitHub App, they will be required to come from that app in future for the branch to merge. Use checks instead of contexts for more fine-grained control.
checks (array of objects)
The list of status checks to require in order to merge into this branch.
context (string) (required)app_id (integer)200 - OK
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PATCH \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks \
-d '{
"strict": true,
"contexts": [
"continuous-integration/travis-ci"
]
}'
Response schema (Status: 200):
Same response schema as Get status checks protection.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks/contexts
Response schema (Status: 200):
Array of string
POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
contexts (array of strings) (required)200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks/contexts \
-d '{
"contexts": [
"continuous-integration/travis-ci",
"continuous-integration/jenkins"
]
}'
Response schema (Status: 200):
Same response schema as Get all status check contexts.
PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
contexts (array of strings) (required)200 - OK
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks/contexts \
-d '{
"contexts": [
"continuous-integration/travis-ci"
]
}'
Response schema (Status: 200):
Same response schema as Get all status check contexts.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts
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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
contexts (array of strings) (required)200 - OK
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks/contexts \
-d '{
"contexts": [
"continuous-integration/jenkins"
]
}'
Response schema (Status: 200):
Same response schema as Get all status check contexts.
GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions
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.
Lists who has access to this protected branch.
Note
Users, apps, and teams restrictions are only available for organization-owned repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions
Response schema (Status: 200):
url: required, string, format: uriusers_url: required, string, format: uriteams_url: required, string, format: uriapps_url: required, string, format: uriusers: required, array of objects:
login: stringid: integer, format: int64node_id: stringavatar_url: stringgravatar_id: stringurl: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringrepos_url: stringevents_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringteams: required, array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerapps: required, array of objects:
id: integerslug: stringnode_id: stringowner: object:
login: stringid: integernode_id: stringurl: stringrepos_url: stringevents_url: stringhooks_url: stringissues_url: stringmembers_url: stringpublic_members_url: stringavatar_url: stringdescription: stringgravatar_id: stringhtml_url: stringfollowers_url: stringfollowing_url: stringgists_url: stringstarred_url: stringsubscriptions_url: stringorganizations_url: stringreceived_events_url: stringtype: stringsite_admin: booleanuser_view_type: stringname: stringclient_id: stringdescription: stringexternal_url: stringhtml_url: stringcreated_at: stringupdated_at: stringpermissions: object:
metadata: stringcontents: stringissues: stringsingle_file: stringevents: array of stringDELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions
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.
Disables the ability to restrict who can push to this branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions
Response schema (Status: 204):
GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps
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.
Lists the GitHub Apps that have push access to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/apps
Response schema (Status: 200):
Array of GitHub app:
id: required, integerslug: stringnode_id: required, stringclient_id: stringowner: required, one of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringdescription: string or nullhtml_url: required, string, format: uriwebsite_url: string or null, format: uriid: required, integernode_id: required, stringname: required, stringslug: required, stringcreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeavatar_url: required, string, format: uriname: required, stringdescription: required, string or nullexternal_url: required, string, format: urihtml_url: required, string, format: uricreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timepermissions: required, object, additional properties: string:
issues: stringchecks: stringmetadata: stringcontents: stringdeployments: stringevents: required, array of stringinstallations_count: integerPOST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps
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.
Grants the specified apps push access for this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
apps (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/apps \
-d '{
"apps": [
"octoapp"
]
}'
Response schema (Status: 200):
Same response schema as Get apps with access to the protected branch.
PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps
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.
Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
apps (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/apps \
-d '{
"apps": [
"octoapp"
]
}'
Response schema (Status: 200):
Same response schema as Get apps with access to the protected branch.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps
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.
Removes the ability of an app to push to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
apps (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/apps \
-d '{
"apps": [
"my-app"
]
}'
Response schema (Status: 200):
Same response schema as Get apps with access to the protected branch.
GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
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.
Lists the teams who have push access to this branch. The list includes child teams.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams
Response schema (Status: 200):
Array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerPOST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
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.
Grants the specified teams push access for this branch. You can also give push access to child teams.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
teams (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
-d '{
"teams": [
"justice-league"
]
}'
Response schema (Status: 200):
Same response schema as Get teams with access to the protected branch.
PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
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.
Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
teams (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
-d '{
"teams": [
"justice-league"
]
}'
Response schema (Status: 200):
Same response schema as Get teams with access to the protected branch.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
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.
Removes the ability of a team to push to this branch. You can also remove push access for child teams.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
teams (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
-d '{
"teams": [
"octocats"
]
}'
Response schema (Status: 200):
Same response schema as Get teams with access to the protected branch.
GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
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.
Lists the people who have push access to this branch.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
200 - OK
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/users
Response schema (Status: 200):
Array of Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringPOST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
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.
Grants the specified people push access for this branch.
TypeDescriptionarrayUsernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
users (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/users \
-d '{
"users": [
"octocat"
]
}'
Response schema (Status: 200):
Same response schema as Get users with access to the protected branch.
PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
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.
Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.
TypeDescriptionarrayUsernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
users (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/users \
-d '{
"users": [
"octocat"
]
}'
Response schema (Status: 200):
Same response schema as Get users with access to the protected branch.
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
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.
Removes the ability of a user to push to this branch.
TypeDescriptionarrayUsernames of the people who should no longer have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
branch (string) (required)
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
users (array of strings) (required)200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/users \
-d '{
"users": [
"octocat"
]
}'
Response schema (Status: 200):
Same response schema as Get users with access to the protected branch.