Search + K

Command Palette

Search for a command to run...

Sign In

Add team access restrictions

POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
Copy endpoint
https://api.github.com

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

path Path Parameters

Name Type
owner required

The account owner of the repository. The name is not case sensitive.

string
repo required

The name of the repository without the .git extension. The name is not case sensitive.

string
branch required

The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

string

Request Body

application/json
{ teams: string[]; } | string[]

Responses

200 application/json

Response

interface Team {
id: number;
node_id: string;
name: string;
slug: string;
description: string | null;
privacy?: string;
notification_setting?: string;
permission: string;
permissions?: {
pull: boolean;
triage: boolean;
push: boolean;
maintain: boolean;
admin: boolean;
}
;
url: string;
html_url: string;
members_url: string;
repositories_url: string;
type: "enterprise" | "organization";
organization_id?: number;
enterprise_id?: number;
parent: TeamSimple

Groups of organization members that gives permissions on specified repositories.

interface TeamSimple {
id: number;
node_id: string;
url: string;
members_url: string;
name: string;
description: string | null;
permission: string;
privacy?: string;
notification_setting?: string;
html_url: string;
repositories_url: string;
slug: string;
ldap_dn?: string;
type: "enterprise" | "organization";
organization_id?: number;
enterprise_id?: number;
}
| null
;
}
[]

Client Errors

422 application/json

Validation failed, or the endpoint has been spammed.

interface ValidationError {
message: string;
documentation_url: string;
errors?: {
resource?: string;
field?: string;
message?: string;
code: string;
index?: number;
value?: string[] | string | number | null;
}
[]
;
}