REST API endpoints for protected branches

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

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection

Response schema (Status: 200):

Update branch protection

PUT /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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):

Delete branch protection

DELETE /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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection

Response schema (Status: 204):

Get admin branch protection

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/enforce_admins

Response schema (Status: 200):

Set admin branch protection

POST /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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/enforce_admins

Response schema (Status: 204):

Get pull request review protection

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_pull_request_reviews

Response schema (Status: 200):

Update pull request review protection

PATCH /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_pull_request_reviews

Response schema (Status: 204):

Get commit signature protection

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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.

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_signatures

Response schema (Status: 204):

Get status checks protection

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks

Response schema (Status: 200):

Update status check protection

PATCH /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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.

Remove status check 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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks

Response schema (Status: 204):

Get all status check contexts

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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

Add status check contexts

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example adding status checks to a branch protection rule

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.

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

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example updating status checks for a branch protection rule

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.

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

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example removing status checks from a branch protection rule

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 access restrictions

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions

Response schema (Status: 200):

Delete access restrictions

DELETE /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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions

Response schema (Status: 204):

Get apps with access to the protected branch

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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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:

Add app access restrictions

POST /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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.

Set app access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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.

Remove app access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams

Response schema (Status: 200):

Array of Team:

Add team access restrictions

POST /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example adding a team in a branch protection rule

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.

Set team access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example replacing a team in a branch protection rule

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.

Remove team access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example removing a team in a branch protection rule

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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:

Add user access restrictions

POST /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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example adding a user in a branch protection rule

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.

Set user access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example replacing a user in a branch protection rule

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.

Remove user access restrictions

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.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example removing a user in a branch protection rule

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.