GitHub v3 REST API

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 response contains the state of the membership and the member’s role.

The role for organization owners is set to maintainer. For more information about maintainer roles, see see Create a team.

get
{protocol}://{hostname}/api/v3/orgs/{org}/teams/{team_slug}/memberships/{username}

Path Parameters

orgstringrequired
team_slugstringrequired

team_slug parameter

usernamestringrequired

Response

application/json

Response

Team Membership

Team Membership

urlstring(uri)required
rolestringrequired

The role of the user in the team.

Allowed values:membermaintainer

Default:member

Example:member

statestringrequired

The state of the user’s membership in the team.

Allowed values:activepending

get/orgs/{org}/teams/{team_slug}/memberships/{username}
 
application/json

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 Enterprise Server 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 Enterprise Server.”

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

put
{protocol}://{hostname}/api/v3/orgs/{org}/teams/{team_slug}/memberships/{username}

Path Parameters

orgstringrequired
team_slugstringrequired

team_slug parameter

usernamestringrequired

Body

application/json
rolestring

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.

Allowed values:membermaintainer

Default:member

Response

application/json

Response

Team Membership

Team Membership

urlstring(uri)required
rolestringrequired

The role of the user in the team.

Allowed values:membermaintainer

Default:member

Example:member

statestringrequired

The state of the user’s membership in the team.

Allowed values:activepending

put/orgs/{org}/teams/{team_slug}/memberships/{username}

Body

{}
 
application/json

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 Enterprise Server 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 Enterprise Server.”

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

delete
{protocol}://{hostname}/api/v3/orgs/{org}/teams/{team_slug}/memberships/{username}

Path Parameters

orgstringrequired
team_slugstringrequired

team_slug parameter

usernamestringrequired

Response

Response

delete/orgs/{org}/teams/{team_slug}/memberships/{username}
 

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.

get
{protocol}://{hostname}/api/v3/orgs/{org}/teams/{team_slug}/projects

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

orgstringrequired
team_slugstringrequired

team_slug parameter

Response

200 application/json

Response

A team’s access to a project.

owner_urlstringrequired
urlstringrequired
html_urlstringrequired
columns_urlstringrequired
idintegerrequired
node_idstringrequired
namestringrequired
bodystring | nullrequired
numberintegerrequired
statestringrequired
creatorobjectrequired

Simple User

Show Child Parameters
created_atstringrequired
updated_atstringrequired
organization_permissionstring

The organization permission for this project. Only present when owner is an organization.

privateboolean

Whether the project is private or not. Only present when owner is an organization.

permissionsobjectrequired
Show Child Parameters
get/orgs/{org}/teams/{team_slug}/projects
 
200 application/json

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

get
{protocol}://{hostname}/api/v3/orgs/{org}/teams/{team_slug}/projects/{project_id}

Path Parameters

orgstringrequired
team_slugstringrequired

team_slug parameter

project_idintegerrequired

Response

application/json

Response

Team Project

A team’s access to a project.

owner_urlstringrequired
urlstringrequired
html_urlstringrequired
columns_urlstringrequired
idintegerrequired
node_idstringrequired
namestringrequired
bodystring | nullrequired
numberintegerrequired
statestringrequired
creatorobjectrequired

Simple User

Show Child Parameters
created_atstringrequired
updated_atstringrequired
organization_permissionstring

The organization permission for this project. Only present when owner is an organization.

privateboolean

Whether the project is private or not. Only present when owner is an organization.

permissionsobjectrequired
Show Child Parameters
get/orgs/{org}/teams/{team_slug}/projects/{project_id}
 
application/json