---
title: "Add or update team membership for a user (Legacy)"
method: PUT
path: "/teams/{team_id}/memberships/{username}"
tags: ["teams"]
deprecated: true
---

# Add or update team membership for a user (Legacy)

`PUT /teams/{team_id}/memberships/{username}`

> **Deprecated.**

**Deprecation Notice:** This endpoint route is deprecated 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](https://docs.github.com/enterprise-server@3.6/rest/teams/members#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](https://docs.github.com/enterprise-server@3.6/github/getting-started-with-github/githubs-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 Server team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub Enterprise Server](https://docs.github.com/enterprise-server@3.6/articles/synchronizing-teams-between-your-identity-provider-and-github/)."

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.

## Path parameters

- `team_id` integer, required
- `username` string, required

## Request body

- object
  - `role` 'member' | 'maintainer' — The role that this user should have in the team.

## Response `200`

Response

- TeamMembership — Team Membership
  - `url` string, uri, required
  - `role` 'member' | 'maintainer', required — The role of the user in the team.
  - `state` 'active' | 'pending', required — The state of the user's membership in the team.

## Other responses

- `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

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-5.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-5/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-5/versions/50ae54440071/schema)
