Skip to main content
Ahora la API de REST tiene control de versiones. Para obtener más información, consulta "Acerca del control de versiones de la API".

Puntos de conexión de API REST para los miembros de la organización

Usa la API de REST para administrar las pertenencias en tu organización.

Note

Si usa Enterprise Managed Users, agregue miembros directamente a las organizaciones, en lugar de enviar invitaciones. Las operaciones para administrar invitaciones de la organización no funcionarán en su empresa. Sin embargo, las operaciones para ver o administrar la pertenencia directamente funcionarán según lo previsto.

List failed organization invitations

The return hash contains failed_at and failed_reason fields which represent the time at which the invitation failed and the reason for the failure.

This endpoint is not available for Enterprise Managed User (EMU) organizations.

Tokens de acceso específicos para "List failed organization invitations"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Parámetros para "List failed organization invitations"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros de consulta
Nombre, Tipo, Descripción
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List failed organization invitations"

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código para "List failed organization invitations"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/failed_invitations
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/failed_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 pending organization 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, or hiring_manager. If the invitee is not a GitHub Enterprise Cloud member, the login field in the return hash will be null.

This endpoint is not available for Enterprise Managed User (EMU) organizations.

Tokens de acceso específicos para "List pending organization invitations"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Parámetros para "List pending organization invitations"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros de consulta
Nombre, Tipo, Descripción
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

role string

Filter invitations by their member role.

Valor predeterminado: all

Puede ser uno de los siguientes: all, admin, direct_member, billing_manager, hiring_manager

invitation_source string

Filter invitations by their invitation source.

Valor predeterminado: all

Puede ser uno de los siguientes: all, member, scim

Códigos de estado de respuesta HTTP para "List pending organization invitations"

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código para "List pending organization invitations"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/invitations
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/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" } ]

Create an organization invitation

Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner.

This endpoint is not available for Enterprise Managed User (EMU) organizations.

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

Tokens de acceso específicos para "Create an organization invitation"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Create an organization invitation"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros del cuerpo
Nombre, Tipo, Descripción
invitee_id integer

Required unless you provide email. GitHub user ID for the person you are inviting.

email string

Required unless you provide invitee_id. Email address of the person you are inviting, which can be an existing GitHub user.

role string

The role for the new member.

  • admin - Organization owners with full administrative rights to the organization and complete access to all repositories and teams.
  • direct_member - Non-owner organization members with ability to see other members and join teams by invitation.
  • billing_manager - Non-owner organization members with ability to manage the billing settings of your organization.
  • reinstate - The previous role assigned to the invitee before they were removed from your organization. Can be one of the roles listed above. Only works if the invitee was previously part of your organization.

Valor predeterminado: direct_member

Puede ser uno de los siguientes: admin, direct_member, billing_manager, reinstate

team_ids array of integers

Specify IDs for the teams you want to invite new members to.

Códigos de estado de respuesta HTTP para "Create an organization invitation"

status codeDescripción
201

Created

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "Create an organization invitation"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

post/orgs/{org}/invitations
curl -L \ -X POST \ -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/invitations \ -d '{"email":"octocat@github.com","role":"direct_member","team_ids":[12,26]}'

Response

Status: 201
{ "id": 1, "login": "monalisa", "node_id": "MDQ6VXNlcjE=", "email": "octocat@github.com", "role": "direct_member", "created_at": "2016-11-30T06:46:10-08:00", "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" }

Cancel an organization invitation

Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner.

This endpoint is not available for Enterprise Managed User (EMU) organizations.

This endpoint triggers notifications.

Tokens de acceso específicos para "Cancel an organization invitation"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Cancel an organization invitation"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

invitation_id integer Requerido

The unique identifier of the invitation.

Códigos de estado de respuesta HTTP para "Cancel an organization invitation"

status codeDescripción
204

No Content

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "Cancel an organization invitation"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/orgs/{org}/invitations/{invitation_id}
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/invitations/INVITATION_ID

Response

Status: 204

List organization invitation teams

List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner.

This endpoint is not available for Enterprise Managed User (EMU) organizations.

Tokens de acceso específicos para "List organization invitation teams"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Parámetros para "List organization invitation teams"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

invitation_id integer Requerido

The unique identifier of the invitation.

Parámetros de consulta
Nombre, Tipo, Descripción
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List organization invitation teams"

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código para "List organization invitation teams"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/invitations/{invitation_id}/teams
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/invitations/INVITATION_ID/teams

Response

Status: 200
[ { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null } ]

List organization members

List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned.

Tokens de acceso específicos para "List organization members"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "List organization members"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros de consulta
Nombre, Tipo, Descripción
filter string

Filter members returned in the list. 2fa_disabled means that only members without two-factor authentication enabled will be returned. This options is only available for organization owners.

Valor predeterminado: all

Puede ser uno de los siguientes: 2fa_disabled, all

role string

Filter members returned by their role.

Valor predeterminado: all

Puede ser uno de los siguientes: all, admin, member

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List organization members"

status codeDescripción
200

OK

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "List organization members"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/members
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/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 } ]

Check organization membership for a user

Check if a user is, publicly or privately, a member of the organization.

Tokens de acceso específicos para "Check organization membership for a user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "Check organization membership for a user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Check organization membership for a user"

status codeDescripción
204

Response if requester is an organization member and user is a member

302

Response if requester is not an organization member

404

Not Found if requester is an organization member and user is not a member

Ejemplos de código para "Check organization membership for a user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/members/{username}
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/members/USERNAME

Response if requester is an organization member and user is a member

Status: 204

Remove an organization member

Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories.

Tokens de acceso específicos para "Remove an organization member"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Remove an organization member"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Remove an organization member"

status codeDescripción
204

No Content

403

Forbidden

Ejemplos de código para "Remove an organization member"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/orgs/{org}/members/{username}
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/members/USERNAME

Response

Status: 204

Get organization membership for a user

In order to get a user's membership with an organization, the authenticated user must be an organization member. The state parameter in the response can be used to identify the user's membership status.

Tokens de acceso específicos para "Get organization membership for a user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Parámetros para "Get organization membership for a user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Get organization membership for a user"

status codeDescripción
200

OK

403

Forbidden

404

Resource not found

Ejemplos de código para "Get organization membership for a user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/memberships/{username}
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/memberships/USERNAME

Response if user has an active admin membership with organization

Status: 200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 } }

Set organization membership for a user

Only authenticated organization owners can add a member to the organization or update the member's role.

  • If the authenticated user is adding a member to the organization, the invited user will receive an email inviting them to the organization. The user's membership status will be pending until they accept the invitation.

  • Authenticated users can update a user's membership by passing the role parameter. If the authenticated user changes a member's role to admin, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to member, no email will be sent.

Rate limits

To prevent abuse, organization owners are limited to creating 50 organization invitations for an organization within a 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period.

Tokens de acceso específicos para "Set organization membership for a user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Set organization membership for a user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Parámetros del cuerpo
Nombre, Tipo, Descripción
role string

The role to give the user in the organization. Can be one of:

  • admin - The user will become an owner of the organization.
  • member - The user will become a non-owner member of the organization.

Valor predeterminado: member

Puede ser uno de los siguientes: admin, member

Códigos de estado de respuesta HTTP para "Set organization membership for a user"

status codeDescripción
200

OK

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "Set organization membership for a user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

put/orgs/{org}/memberships/{username}
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/memberships/USERNAME \ -d '{"role":"member"}'

Response if user has an active admin membership with organization

Status: 200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 } }

Remove organization membership for a user

In order to remove a user's membership with an organization, the authenticated user must be an organization owner.

If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases.

Tokens de acceso específicos para "Remove organization membership for a user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Remove organization membership for a user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Remove organization membership for a user"

status codeDescripción
204

No Content

403

Forbidden

404

Resource not found

Ejemplos de código para "Remove organization membership for a user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/orgs/{org}/memberships/{username}
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/memberships/USERNAME

Response

Status: 204

List public organization members

Members of an organization can choose to have their membership publicized or not.

Tokens de acceso específicos para "List public organization members"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "List public organization members"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros de consulta
Nombre, Tipo, Descripción
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List public organization members"

status codeDescripción
200

OK

Ejemplos de código para "List public organization members"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/public_members
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/public_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 } ]

Check public organization membership for a user

Check if the provided user is a public member of the organization.

Tokens de acceso específicos para "Check public organization membership for a user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "Check public organization membership for a user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Check public organization membership for a user"

status codeDescripción
204

Response if user is a public member

404

Not Found if user is not a public member

Ejemplos de código para "Check public organization membership for a user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/orgs/{org}/public_members/{username}
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/public_members/USERNAME

Response if user is a public member

Status: 204

Set public organization membership for the authenticated user

The user can publicize their own membership. (A user cannot publicize the membership for another user.)

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 acceso específicos para "Set public organization membership for the authenticated user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Set public organization membership for the authenticated user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Set public organization membership for the authenticated user"

status codeDescripción
204

No Content

403

Forbidden

Ejemplos de código para "Set public organization membership for the authenticated user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

put/orgs/{org}/public_members/{username}
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/public_members/USERNAME

Response

Status: 204

Remove public organization membership for the authenticated user

Removes the public membership for the authenticated user from the specified organization, unless public visibility is enforced by default.

Tokens de acceso específicos para "Remove public organization membership for the authenticated user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Remove public organization membership for the authenticated user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

username string Requerido

The handle for the GitHub user account.

Códigos de estado de respuesta HTTP para "Remove public organization membership for the authenticated user"

status codeDescripción
204

No Content

Ejemplos de código para "Remove public organization membership for the authenticated user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/orgs/{org}/public_members/{username}
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/public_members/USERNAME

Response

Status: 204

List organization memberships for the authenticated user

Lists all of the authenticated user's organization memberships.

Tokens de acceso específicos para "List organization memberships for the authenticated user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado no requiere ningún permiso.

Parámetros para "List organization memberships for the authenticated user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de consulta
Nombre, Tipo, Descripción
state string

Indicates the state of the memberships to return. If not specified, the API returns both active and pending memberships.

Puede ser uno de los siguientes: active, pending

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List organization memberships for the authenticated user"

status codeDescripción
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "List organization memberships for the authenticated user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/user/memberships/orgs
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/user/memberships/orgs

Response

Status: 200
[ { "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 } }, { "url": "https://api.github.com/orgs/invitocat/memberships/defunkt", "state": "pending", "role": "admin", "organization_url": "https://api.github.com/orgs/invitocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 an organization membership for the authenticated user

If the authenticated user is an active or pending member of the organization, this endpoint will return the user's membership. If the authenticated user is not affiliated with the organization, a 404 is returned. This endpoint will return a 403 if the request is made by a GitHub App that is blocked by the organization.

Tokens de acceso específicos para "Get an organization membership for the authenticated user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (read)

Parámetros para "Get an organization membership for the authenticated user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Códigos de estado de respuesta HTTP para "Get an organization membership for the authenticated user"

status codeDescripción
200

OK

403

Forbidden

404

Resource not found

Ejemplos de código para "Get an organization membership for the authenticated user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/user/memberships/orgs/{org}
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/user/memberships/orgs/ORG

Response

Status: 200
{ "url": "https://api.github.com/orgs/invitocat/memberships/defunkt", "state": "pending", "role": "admin", "organization_url": "https://api.github.com/orgs/invitocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 } }

Update an organization membership for the authenticated user

Converts the authenticated user to an active member of the organization, if that user has a pending invitation from the organization.

Tokens de acceso específicos para "Update an organization membership for the authenticated user"

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Members" organization permissions (write)

Parámetros para "Update an organization membership for the authenticated user"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros del cuerpo
Nombre, Tipo, Descripción
state string Requerido

The state that the membership should be in. Only "active" will be accepted.

Valor: active

Códigos de estado de respuesta HTTP para "Update an organization membership for the authenticated user"

status codeDescripción
200

OK

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código para "Update an organization membership for the authenticated user"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

patch/user/memberships/orgs/{org}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/memberships/orgs/ORG \ -d '{"state":"active"}'

Response

Status: 200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "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 } }