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

Set team access restrictions

Replaces the teams that have push access to a protected branch. Provide the complete replacement list in teams; teams previously granted access are removed, and child teams are included in the restriction. The response lists the teams with access after replacement.

  • 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 repository name without the `.git` extension; the name is not case sensitive.
branchstringrequired
The branch name. Must not contain wildcard characters.

Complete team access restriction data, supplied either as an array of team slugs or as an object containing a teams array.

teamsarray<string>required
The slug values for teams

2 status codes
200Returns an array of team objects representing the teams with push access to the protected branch, including identifiers, names, slugs, permissions, and repository URLs.
idintegerrequired
node_idstringrequired
namestringrequired
slugstringrequired
descriptionstringrequired
privacystringoptional
notification_settingstringoptional
permissionstringrequired
permissionsobjectoptional
urlstringrequired
html_urlstringrequired
members_urlstringrequired
repositories_urlstringrequired
typestringrequired
The ownership type of the team
Allowed:enterpriseorganization
access_sourcestringoptional
How the team's access to the repository was granted. This property is only present when the team is returned in a repository context, such as `GET /repos/{owner}/{repo}/teams`.
Allowed:directorganizationenterprise
organization_idintegeroptional
Unique identifier of the organization to which this team belongs
enterprise_idintegeroptional
Unique identifier of the enterprise to which this team belongs
parentobjectrequired
Groups of organization members that gives permissions on specified repositories.
422Returned when the request fails validation or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 422 is returned when the request fails validation or the endpoint has been spammed. Supply the replacement team slugs through teams as either an array or an object containing a teams array. branch must not contain wildcard characters.