Sample - GitHub REST API
PUT/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

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

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.

TypeDescription
arrayUsernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 1 body field
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
branchstringrequired
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql).
usersarray<string>required
The username for users

2 status codes
200Response
namestringoptional
emailstringoptional
loginstringrequired
idintegerrequired
node_idstringrequired
avatar_urlstringrequired
gravatar_idstringrequired
urlstringrequired
html_urlstringrequired
followers_urlstringrequired
following_urlstringrequired
gists_urlstringrequired
starred_urlstringrequired
subscriptions_urlstringrequired
organizations_urlstringrequired
repos_urlstringrequired
events_urlstringrequired
received_events_urlstringrequired
typestringrequired
site_adminbooleanrequired
starred_atstringoptional
user_view_typestringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 422 is returned: Validation failed, or the endpoint has been spammed.