Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

REST API endpoints for organization members

Use the REST API to manage memberships in your organization.

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.

Fine-grained access tokens for "List organization members"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Members" organization permissions (read)

This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.

Parameters for "List organization members"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
filter string

Filter members returned in the list. 2fa_disabled means that only members without two-factor authentication enabled will be returned. 2fa_insecure means that only members with insecure 2FA methods will be returned. These options are only available for organization owners.

Default: all

Can be one of: 2fa_disabled, 2fa_insecure, all

role string

Filter members returned by their role.

Default: all

Can be one of: all, admin, member

per_page integer

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

Default: 30

page integer

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

Default: 1

HTTP response status codes for "List organization members"

Status codeDescription
200

OK

422

Validation failed, or the endpoint has been spammed.

Code samples for "List organization members"

Request example

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" \ http(s)://HOSTNAME/api/v3/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://HOSTNAME/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://HOSTNAME/users/octocat/followers", "following_url": "https://HOSTNAME/users/octocat/following{/other_user}", "gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}", "starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions", "organizations_url": "https://HOSTNAME/users/octocat/orgs", "repos_url": "https://HOSTNAME/users/octocat/repos", "events_url": "https://HOSTNAME/users/octocat/events{/privacy}", "received_events_url": "https://HOSTNAME/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.

Fine-grained access tokens for "Check organization membership for a user"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Members" organization permissions (read)

This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.

Parameters for "Check organization membership for a user"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

username string Required

The handle for the GitHub user account.

HTTP response status codes for "Check organization membership for a user"

Status codeDescription
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

Code samples for "Check organization membership for a user"

Request example

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" \ http(s)://HOSTNAME/api/v3/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.

Note

If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team.

Fine-grained access tokens for "Remove an organization member"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Members" organization permissions (write)

Parameters for "Remove an organization member"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

username string Required

The handle for the GitHub user account.

HTTP response status codes for "Remove an organization member"

Status codeDescription
204

No Content

403

Forbidden

Code samples for "Remove an organization member"

Request example

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" \ http(s)://HOSTNAME/api/v3/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.