Add or update team membership for a user

Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.

Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team.

Note: When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "Synchronizing teams between your identity provider and GitHub."

An organization owner can add someone who is not part of the team's organization to a team. When an organization owner adds someone to a team who is not an organization member, this endpoint will send an invitation to the person via email. This newly-created membership will be in the "pending" state until the person accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team.

If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.

Note: You can also specify a team by org_id and team_id using the route PUT /organizations/{org_id}/team/{team_id}/memberships/{username}.

octokit.teams.addOrUpdateMembershipForUserInOrg({
org,
team_slug,
username,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

usernameyes
roleno

The role that this user should have in the team. Can be one of:
* member - a normal member of the team.
* maintainer - a team maintainer. Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description.

See also: GitHub Developer Guide documentation.

Add or update team project permissions

Adds an organization project to a team. To add a project to a team or update the team's permission on a project, the authenticated user must have admin permissions for the project. The project and team must be part of the same organization.

Note: You can also specify a team by org_id and team_id using the route PUT /organizations/{org_id}/team/{team_id}/projects/{project_id}.

octokit.teams.addOrUpdateProjectPermissionsInOrg({
org,
team_slug,
project_id,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

project_idyes
permissionno

The permission to grant to the team for this project. Can be one of:
* read - team members can read, but not write to or administer this project.
* write - team members can read and write, but not administer this project.
* admin - team members can read, write and administer this project.
Default: the team's permission attribute will be used to determine what permission to grant the team on this project. Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

See also: GitHub Developer Guide documentation.

Add or update team repository permissions

To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a 422 Unprocessable Entity status if you attempt to add a repository to a team that is not owned by the organization. Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

Note: You can also specify a team by org_id and team_id using the route PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}.

For more information about the permission levels, see "Repository permission levels for an organization".

octokit.teams.addOrUpdateRepoPermissionsInOrg({
org,
team_slug,
owner,
repo,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

owneryes
repoyes
permissionno

The permission to grant the team on this repository. Can be one of:
* pull - team members can pull, but not push to or administer this repository.
* push - team members can pull and push, but not administer this repository.
* admin - team members can pull, push and administer this repository.
* maintain - team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations.
* triage - team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations.

If no permission is specified, the team's permission attribute will be used to determine what permission to grant the team on this repository.

See also: GitHub Developer Guide documentation.

Check team permissions for a project

Checks whether a team has read, write, or admin permissions for an organization project. The response includes projects inherited from a parent team.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/projects/{project_id}.

octokit.teams.checkPermissionsForProjectInOrg({
org,
team_slug,
project_id,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

project_idyes

See also: GitHub Developer Guide documentation.

Check team permissions for a repository

Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. Repositories inherited through a parent team will also be checked.

You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom media type via the application/vnd.github.v3.repository+json accept header.

If a team doesn't have permission for the repository, you will receive a 404 Not Found response status.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}.

octokit.teams.checkPermissionsForRepoInOrg({
org,
team_slug,
owner,
repo,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

owneryes
repoyes

See also: GitHub Developer Guide documentation.

Create a team

To create a team, the authenticated user must be a member or owner of {org}. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "Setting team creation permissions."

When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of maintainers. For more information, see "About teams".

octokit.teams.create({
org,
name,
});

Parameters

namerequireddescription
orgyes
nameyes

The name of the team.

descriptionno

The description of the team.

maintainersno

List GitHub IDs for organization members who will become team maintainers.

repo_namesno

The full name (e.g., "organization-name/repository-name") of repositories to add the team to.

privacyno

The level of privacy this team should have. The options are:
For a non-nested team:
* secret - only visible to organization owners and members of this team.
* closed - visible to all members of this organization.
Default: secret
For a parent or child team:
* closed - visible to all members of this organization.
Default for child team: closed

permissionno

Deprecated. The permission that new repositories will be added to the team with when none is specified. Can be one of:
* pull - team members can pull, but not push to or administer newly-added repositories.
* push - team members can pull and push, but not administer newly-added repositories.
* admin - team members can pull, push and administer newly-added repositories.

parent_team_idno

The ID of a team to set as the parent team.

See also: GitHub Developer Guide documentation.

Create a discussion comment

Creates a new comment on a team discussion. OAuth access tokens require the write:discussion scope.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note: You can also specify a team by org_id and team_id using the route POST /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments.

octokit.teams.createDiscussionCommentInOrg({
org,
team_slug,
discussion_number,
body,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
bodyyes

The discussion comment's body text.

See also: GitHub Developer Guide documentation.

Create a discussion

Creates a new discussion post on a team's page. OAuth access tokens require the write:discussion scope.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Note: You can also specify a team by org_id and team_id using the route POST /organizations/{org_id}/team/{team_id}/discussions.

octokit.teams.createDiscussionInOrg({
org,
team_slug,
title,
body,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

titleyes

The discussion post's title.

bodyyes

The discussion post's body text.

privateno

Private posts are only visible to team members, organization owners, and team maintainers. Public posts are visible to all members of the organization. Set to true to create a private post.

See also: GitHub Developer Guide documentation.

Delete a discussion comment

Deletes a comment on a team discussion. OAuth access tokens require the write:discussion scope.

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}.

octokit.teams.deleteDiscussionCommentInOrg({
org,
team_slug,
discussion_number,
comment_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
comment_numberyes

See also: GitHub Developer Guide documentation.

Delete a discussion

Delete a discussion from a team's page. OAuth access tokens require the write:discussion scope.

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}.

octokit.teams.deleteDiscussionInOrg({
org,
team_slug,
discussion_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes

See also: GitHub Developer Guide documentation.

Delete a team

To delete a team, the authenticated user must be an organization owner or team maintainer.

If you are an organization owner, deleting a parent team will delete all of its child teams as well.

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}.

octokit.teams.deleteInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

See also: GitHub Developer Guide documentation.

Get a team by name

Gets a team using the team's slug. GitHub generates the slug from the team name.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}.

octokit.teams.getByName({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

See also: GitHub Developer Guide documentation.

Get a discussion comment

Get a specific comment on a team discussion. OAuth access tokens require the read:discussion scope.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}.

octokit.teams.getDiscussionCommentInOrg({
org,
team_slug,
discussion_number,
comment_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
comment_numberyes

See also: GitHub Developer Guide documentation.

Get a discussion

Get a specific discussion on a team's page. OAuth access tokens require the read:discussion scope.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}.

octokit.teams.getDiscussionInOrg({
org,
team_slug,
discussion_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes

See also: GitHub Developer Guide documentation.

Get team membership for a user

Team members will include the members of child teams.

To get a user's membership with a team, the team must be visible to the authenticated user.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/memberships/{username}.

Note: The role for organization owners returns as maintainer. For more information about maintainer roles, see Create a team.

octokit.teams.getMembershipForUserInOrg({
org,
team_slug,
username,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

usernameyes

See also: GitHub Developer Guide documentation.

List teams

Lists all teams in an organization that are visible to the authenticated user.

octokit.teams.list({
org,
});

Parameters

namerequireddescription
orgyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List child teams

Lists the child teams of the team specified by {team_slug}.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/teams.

octokit.teams.listChildInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List discussion comments

List all comments on a team discussion. OAuth access tokens require the read:discussion scope.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments.

octokit.teams.listDiscussionCommentsInOrg({
org,
team_slug,
discussion_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
directionno

One of asc (ascending) or desc (descending).

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List discussions

List all discussions on a team's page. OAuth access tokens require the read:discussion scope.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/discussions.

octokit.teams.listDiscussionsInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

directionno

One of asc (ascending) or desc (descending).

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List teams for the authenticated user

List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user, repo, or read:org scope when authenticating via OAuth.

octokit.teams.listForAuthenticatedUser();

Parameters

namerequireddescription
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List team members

Team members will include the members of child teams.

To list members in a team, the team must be visible to the authenticated user.

octokit.teams.listMembersInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

roleno

Filters members returned by their role in the team. Can be one of:
* member - normal members of the team.
* maintainer - team maintainers.
* all - all members of the team.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List pending team invitations

The return hash contains a role field which refers to the Organization Invitation role and will be one of the following values: direct_member, admin, billing_manager, hiring_manager, or reinstate. If the invitee is not a GitHub member, the login field in the return hash will be null.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/invitations.

octokit.teams.listPendingInvitationsInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List team projects

Lists the organization projects for a team.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/projects.

octokit.teams.listProjectsInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List team repositories

Lists a team's repositories visible to the authenticated user.

Note: You can also specify a team by org_id and team_id using the route GET /organizations/{org_id}/team/{team_id}/repos.

octokit.teams.listReposInOrg({
org,
team_slug,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

Remove team membership for a user

Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.

To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team.

Note: When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "Synchronizing teams between your identity provider and GitHub."

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}/memberships/{username}.

octokit.teams.removeMembershipForUserInOrg({
org,
team_slug,
username,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

usernameyes

See also: GitHub Developer Guide documentation.

Remove a project from a team

Removes an organization project from a team. An organization owner or a team maintainer can remove any project from the team. To remove a project from a team as an organization member, the authenticated user must have read access to both the team and project, or admin access to the team or project. This endpoint removes the project from the team, but does not delete the project.

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}/projects/{project_id}.

octokit.teams.removeProjectInOrg({
org,
team_slug,
project_id,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

project_idyes

See also: GitHub Developer Guide documentation.

Remove a repository from a team

If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. This does not delete the repository, it just removes it from the team.

Note: You can also specify a team by org_id and team_id using the route DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}.

octokit.teams.removeRepoInOrg({
org,
team_slug,
owner,
repo,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

owneryes
repoyes

See also: GitHub Developer Guide documentation.

Update a discussion comment

Edits the body text of a discussion comment. OAuth access tokens require the write:discussion scope.

Note: You can also specify a team by org_id and team_id using the route PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}.

octokit.teams.updateDiscussionCommentInOrg({
org,
team_slug,
discussion_number,
comment_number,
body,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
comment_numberyes
bodyyes

The discussion comment's body text.

See also: GitHub Developer Guide documentation.

Update a discussion

Edits the title and body text of a discussion post. Only the parameters you provide are updated. OAuth access tokens require the write:discussion scope.

Note: You can also specify a team by org_id and team_id using the route PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}.

octokit.teams.updateDiscussionInOrg({
org,
team_slug,
discussion_number,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

discussion_numberyes
titleno

The discussion post's title.

bodyno

The discussion post's body text.

See also: GitHub Developer Guide documentation.

Update a team

To edit a team, the authenticated user must either be an organization owner or a team maintainer.

Note: You can also specify a team by org_id and team_id using the route PATCH /organizations/{org_id}/team/{team_id}.

octokit.teams.updateInOrg({
org,
team_slug,
name,
});

Parameters

namerequireddescription
orgyes
team_slugyes

team_slug parameter

nameyes

The name of the team.

descriptionno

The description of the team.

privacyno

The level of privacy this team should have. Editing teams without specifying this parameter leaves privacy intact. When a team is nested, the privacy for parent teams cannot be secret. The options are:
For a non-nested team:
* secret - only visible to organization owners and members of this team.
* closed - visible to all members of this organization.
For a parent or child team:
* closed - visible to all members of this organization.

permissionno

Deprecated. The permission that new repositories will be added to the team with when none is specified. Can be one of:
* pull - team members can pull, but not push to or administer newly-added repositories.
* push - team members can pull and push, but not administer newly-added repositories.
* admin - team members can pull, push and administer newly-added repositories.

parent_team_idno

The ID of a team to set as the parent team.

See also: GitHub Developer Guide documentation.