Pontos de extremidade de API REST para membros da equipes
Use a API REST para criar e gerenciar a associação de equipes na sua organização do GitHub Enterprise Cloud.
Sobre os membros da equipe
Esses pontos de extremidade só estão disponíveis para os membros autenticados da organização da equipe. Os tokens de acesso OAuth exigem o read:org
escopo . O GitHub gera o slug
da equipe com base no name
da equipe.
Quando as permissões pull
e push
forem aceitas, elas serão mapeadas para as funções de Leitura e Gravação de um repositório da organização. Para saber mais sobre funções de repositório, confira "Funções de repositório para uma organização".
Observação: quando você tiver configurado a sincronização da equipe para uma equipe com o IdP (provedor de identidade) da sua organização, receberá uma mensagem de erro se tentar usar a API para fazer alterações na associação da equipe. Se você tiver acesso para administrar a associação do grupo em seu IdP, você pode administrar a associação da equipe do GitHub através do seu provedor de identidade, que adiciona e remove automaticamente os integrantes da equipe em uma organização. Para obter mais informações, confira "Gerenciando a sincronização da equipe para a sua organização".
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 Enterprise Cloud 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
.
Parâmetros para "List pending team invitations"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
org string ObrigatórioThe organization name. The name is not case sensitive. |
team_slug string ObrigatórioThe slug of the team name. |
Nome, Tipo, Descrição |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List pending team invitations"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List pending team invitations"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/invitations
Response
Status: 200
[
{
"id": 1,
"login": "monalisa",
"node_id": "MDQ6VXNlcjE=",
"email": "octocat@github.com",
"role": "direct_member",
"created_at": "2016-11-30T06:46:10-08:00",
"failed_at": "",
"failed_reason": "",
"inviter": {
"login": "other_user",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/other_user_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/other_user",
"html_url": "https://github.com/other_user",
"followers_url": "https://api.github.com/users/other_user/followers",
"following_url": "https://api.github.com/users/other_user/following{/other_user}",
"gists_url": "https://api.github.com/users/other_user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/other_user/subscriptions",
"organizations_url": "https://api.github.com/users/other_user/orgs",
"repos_url": "https://api.github.com/users/other_user/repos",
"events_url": "https://api.github.com/users/other_user/events{/privacy}",
"received_events_url": "https://api.github.com/users/other_user/received_events",
"type": "User",
"site_admin": false
},
"team_count": 2,
"invitation_teams_url": "https://api.github.com/organizations/2/invitations/1/teams",
"invitation_source": "member"
}
]
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.
Parâmetros para "List team members"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
org string ObrigatórioThe organization name. The name is not case sensitive. |
team_slug string ObrigatórioThe slug of the team name. |
Nome, Tipo, Descrição |
---|
role string Filters members returned by their role in the team. Padrão: Pode ser um dos: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List team members"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List team members"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/members
Response
Status: 200
[
{
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
]
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 Create a team.
Parâmetros para "Get team membership for a user"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
org string ObrigatórioThe organization name. The name is not case sensitive. |
team_slug string ObrigatórioThe slug of the team name. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Get team membership for a user"
Código de status | Descrição |
---|---|
200 | OK |
404 | if user has no team membership |
Exemplos de código para "Get team membership for a user"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/memberships/USERNAME
Response if user is a team maintainer
Status: 200
{
"url": "https://api.github.com/teams/1/memberships/octocat",
"role": "maintainer",
"state": "active"
}
Add or update team membership for a user
Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team.
Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
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 Cloud 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 Cloud."
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}
.
Parâmetros para "Add or update team membership for a user"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
org string ObrigatórioThe organization name. The name is not case sensitive. |
team_slug string ObrigatórioThe slug of the team name. |
username string ObrigatórioThe handle for the GitHub user account. |
Nome, Tipo, Descrição |
---|
role string The role that this user should have in the team. Padrão: Pode ser um dos: |
Códigos de status de resposta HTTP para "Add or update team membership for a user"
Código de status | Descrição |
---|---|
200 | OK |
403 | Forbidden if team synchronization is set up |
422 | Unprocessable Entity if you attempt to add an organization to a team |
Exemplos de código para "Add or update team membership for a user"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/memberships/USERNAME \
-d '{"role":"maintainer"}'
Response if user's membership with team is now pending
Status: 200
{
"url": "https://api.github.com/teams/1/memberships/octocat",
"role": "member",
"state": "pending"
}
Remove team membership for a user
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.
Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
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 Cloud 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 Cloud."
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}
.
Parâmetros para "Remove team membership for a user"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
org string ObrigatórioThe organization name. The name is not case sensitive. |
team_slug string ObrigatórioThe slug of the team name. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Remove team membership for a user"
Código de status | Descrição |
---|---|
204 | No Content |
403 | Forbidden if team synchronization is set up |
Exemplos de código para "Remove team membership for a user"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/memberships/USERNAME
Response
Status: 204
List pending team invitations (Legacy)
Warning
Endpoint closing down notice: This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new List pending team invitations
endpoint.
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 Enterprise Cloud member, the login
field in the return hash will be null
.
Parâmetros para "List pending team invitations (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
Nome, Tipo, Descrição |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List pending team invitations (Legacy)"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List pending team invitations (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/invitations
Response
Status: 200
[
{
"id": 1,
"login": "monalisa",
"node_id": "MDQ6VXNlcjE=",
"email": "octocat@github.com",
"role": "direct_member",
"created_at": "2016-11-30T06:46:10-08:00",
"failed_at": "",
"failed_reason": "",
"inviter": {
"login": "other_user",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/other_user_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/other_user",
"html_url": "https://github.com/other_user",
"followers_url": "https://api.github.com/users/other_user/followers",
"following_url": "https://api.github.com/users/other_user/following{/other_user}",
"gists_url": "https://api.github.com/users/other_user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/other_user/subscriptions",
"organizations_url": "https://api.github.com/users/other_user/orgs",
"repos_url": "https://api.github.com/users/other_user/repos",
"events_url": "https://api.github.com/users/other_user/events{/privacy}",
"received_events_url": "https://api.github.com/users/other_user/received_events",
"type": "User",
"site_admin": false
},
"team_count": 2,
"invitation_teams_url": "https://api.github.com/organizations/2/invitations/1/teams",
"invitation_source": "member"
}
]
List team members (Legacy)
Warning
Endpoint closing down notice: This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new List team members
endpoint.
Team members will include the members of child teams.
Parâmetros para "List team members (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
Nome, Tipo, Descrição |
---|
role string Filters members returned by their role in the team. Padrão: Pode ser um dos: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List team members (Legacy)"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Exemplos de código para "List team members (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/members
Response
Status: 200
[
{
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
]
Get team member (Legacy)
The "Get team member" endpoint (described below) is closing down.
We recommend using the Get team membership for a user endpoint instead. It allows you to get both active and pending memberships.
To list members in a team, the team must be visible to the authenticated user.
Tokens de acesso refinados para "Get team member (Legacy)"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Members" organization permissions (read)
Parâmetros para "Get team member (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Get team member (Legacy)"
Código de status | Descrição |
---|---|
204 | if user is a member |
404 | if user is not a member |
Exemplos de código para "Get team member (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/members/USERNAME
if user is a member
Status: 204
Add team member (Legacy)
The "Add team member" endpoint (described below) is closing down.
We recommend using the Add or update team membership for a user endpoint instead. It allows you to invite new organization members to your teams.
Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
To add someone to a team, the authenticated user must be an organization owner or a team maintainer in the team they're changing. The person being added to the team must be a member of the team's organization.
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 Cloud 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 Cloud."
Note that you'll need to set Content-Length
to zero when calling out to this endpoint. For more information, see "HTTP method."
Tokens de acesso refinados para "Add team member (Legacy)"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Members" organization permissions (write)
Parâmetros para "Add team member (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Add team member (Legacy)"
Código de status | Descrição |
---|---|
204 | No Content |
403 | Forbidden |
404 | Not Found if team synchronization is set up |
422 | Unprocessable Entity if you attempt to add an organization to a team or you attempt to add a user to a team when they are not a member of at least one other team in the same organization |
Exemplos de código para "Add team member (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/members/USERNAME
Response
Status: 204
Remove team member (Legacy)
The "Remove team member" endpoint (described below) is closing down.
We recommend using the Remove team membership for a user endpoint instead. It allows you to remove both active and pending memberships.
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 team member, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. Removing a team member does not delete the user, it just removes them 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 Cloud 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 Cloud."
Tokens de acesso refinados para "Remove team member (Legacy)"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Members" organization permissions (write)
Parâmetros para "Remove team member (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Remove team member (Legacy)"
Código de status | Descrição |
---|---|
204 | No Content |
404 | Not Found if team synchronization is setup |
Exemplos de código para "Remove team member (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/members/USERNAME
Response
Status: 204
Get team membership for a user (Legacy)
Warning
Endpoint closing down notice: This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new Get team membership for a user endpoint.
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:
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 Create a team.
Parâmetros para "Get team membership for a user (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Get team membership for a user (Legacy)"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Exemplos de código para "Get team membership for a user (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/memberships/USERNAME
Response if user is a team maintainer
Status: 200
{
"url": "https://api.github.com/teams/1/memberships/octocat",
"role": "maintainer",
"state": "active"
}
Add or update team membership for a user (Legacy)
Warning
Endpoint closing down notice: This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new Add or update team membership for a user endpoint.
Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
If the user is already a member of the team's organization, this endpoint will add the user to the team. To add a membership between an organization member and a team, the authenticated user must be an organization owner or a team maintainer.
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 Cloud 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 Cloud."
If the user is unaffiliated with the team's organization, this endpoint will send an invitation to the user via email. This newly-created membership will be in the "pending" state until the user 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. To add a membership between an unaffiliated user and a team, the authenticated user must be an organization owner.
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.
Parâmetros para "Add or update team membership for a user (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Nome, Tipo, Descrição |
---|
role string The role that this user should have in the team. Padrão: Pode ser um dos: |
Códigos de status de resposta HTTP para "Add or update team membership for a user (Legacy)"
Código de status | Descrição |
---|---|
200 | OK |
403 | Forbidden if team synchronization is set up |
404 | Resource not found |
422 | Unprocessable Entity if you attempt to add an organization to a team |
Exemplos de código para "Add or update team membership for a user (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/memberships/USERNAME \
-d '{"role":"member"}'
Response if user's membership with team is now pending
Status: 200
{
"url": "https://api.github.com/teams/1/memberships/octocat",
"role": "member",
"state": "pending"
}
Remove team membership for a user (Legacy)
Warning
Endpoint closing down notice: This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new Remove team membership for a user endpoint.
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 Cloud 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 Cloud."
Parâmetros para "Remove team membership for a user (Legacy)"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
team_id integer ObrigatórioThe unique identifier of the team. |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Remove team membership for a user (Legacy)"
Código de status | Descrição |
---|---|
204 | No Content |
403 | if team synchronization is set up |
Exemplos de código para "Remove team membership for a user (Legacy)"
Se você acessar o GitHub em GHE.com, substitua api.github.com
pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/teams/TEAM_ID/memberships/USERNAME
Response
Status: 204