Skip to main content

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](https://docs.github.com/[email protected]/rest/reference/orgs#get-organization-membership-for-a-user) 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, the authenticated user is limited to 50 organization invitations per 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.

PUT/orgs/{org}/memberships/{username}
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
org string
required
username string
required
Body Params
optional
application/jsonobject
role string
optional

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.

Responses

application/json Org Membership object

Response

organization Organization Simple object
required

Organization Simple

avatar_url string
required

Example: https://github.com/images/error/octocat_happy.gif

description string
requirednullable

Example: A great organization

events_url string<uri>
required

Example: https://api.github.com/orgs/github/events

hooks_url string
required

Example: https://api.github.com/orgs/github/hooks

id integer
required

Example: 1

issues_url string
required

Example: https://api.github.com/orgs/github/issues

login string
required

Example: github

members_url string
required

Example: https://api.github.com/orgs/github/members{/member}

node_id string
required

Example: MDEyOk9yZ2FuaXphdGlvbjE=

public_members_url string
required

Example: https://api.github.com/orgs/github/public_members{/member}

repos_url string<uri>
required

Example: https://api.github.com/orgs/github/repos

url string<uri>
required

Example: https://api.github.com/orgs/github

organization_url string<uri>
required

Example: https://api.github.com/orgs/octocat

permissions object
optional
can_create_repository boolean
required
role string
required

The user's membership type in the organization.

Example: admin

state string
required

The state of the member in the organization. The `pending` state indicates the user has not yet accepted an invitation.

Example: active

url string<uri>
required

Example: https://api.github.com/orgs/octocat/memberships/defunkt

user Simple User object
requirednullable

Simple User

avatar_url string<uri>
required

Example: https://github.com/images/error/octocat_happy.gif

email string
optionalnullable
events_url string
required

Example: https://api.github.com/users/octocat/events{/privacy}

followers_url string<uri>
required

Example: https://api.github.com/users/octocat/followers

following_url string
required

Example: https://api.github.com/users/octocat/following{/other_user}

gists_url string
required

Example: https://api.github.com/users/octocat/gists{/gist_id}

gravatar_id string
requirednullable

Example: 41d064eb2195891e12d0413f63227ea7

html_url string<uri>
required

Example: https://github.com/octocat

id integer
required

Example: 1

login string
required

Example: octocat

name string
optionalnullable
node_id string
required

Example: MDQ6VXNlcjE=

organizations_url string<uri>
required

Example: https://api.github.com/users/octocat/orgs

received_events_url string<uri>
required

Example: https://api.github.com/users/octocat/received_events

repos_url string<uri>
required

Example: https://api.github.com/users/octocat/repos

site_admin boolean
required
starred_at string
optional

Example: "2020-07-09T00:17:55Z"

starred_url string
required

Example: https://api.github.com/users/octocat/starred{/owner}{/repo}

subscriptions_url string<uri>
required

Example: https://api.github.com/users/octocat/subscriptions

type string
required

Example: User

url string<uri>
required

Example: https://api.github.com/users/octocat

application/json Basic Error object

Forbidden

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Validation Error object

Validation failed

documentation_url string
required
errors array[object]
optional
items object
code string
required
field string
optional
index integer
optional
message string
optional
resource string
optional
value
optional
message string
required