Teams and memberships
Teams group users around shared work and shared settings. The team API manages the team resource, while the membership API manages each user’s place in that team, including invitations, roles, acceptance, and removal. This page is part of Identity and collaboration services. For account session behavior, see Account authentication and security. Team installations are covered with the wider installation model in Organizations and installations.
Team lifecycle
The team lifecycle starts when an authenticated user creates a team and ends when an owner deletes it. A created team gives its creator the owner role. Owners control team-wide changes and member administration, while all members can read the team and its member list.
The team-level operations are:
listreturns teams in which the current user is a member. Search and query inputs can narrow the result, and the total count can be skipped.createcreates a team and assigns the creator as an owner. The caller can provide initial roles for that owner membership.getreads one team by ID.updateNamechanges the team name.deleteremoves the team. Only an owner can perform this action.
The team model gives the shared identity of the group. It includes the team ID, name, member count, timestamps, and team preferences.
References: src/…/teams.ts• L20-468 src/models.ts• L1053-1081
Shared preferences
Team preferences store JSON-like key-value data that should be available to all members. The API reads them with getPrefs and replaces the complete stored object with updatePrefs; it does not merge the new object with the old one. A preference that belongs to one person instead of the whole team should use account preferences.
References: src/…/teams.ts• L1833-1971
Membership lifecycle
A membership is the relationship between one user and one team. It has its own ID and roles, and it records invitation and acceptance information separately from the team resource. This separation lets the team API describe the group while membership APIs change one person’s access to that group.
Membership access follows this pattern:
- An owner creates a membership for an existing user or an invite target identified by email or phone.
- The membership receives the requested roles and an invitation record.
- A client invitation sends the target a link. The target uses the returned invitation values to accept the invitation.
- Acceptance marks the membership as joined and creates a session for the user.
- An owner can change the membership roles or remove the membership. A member can remove their own membership to leave the team.
The following diagram shows the relationship between team administration and the invitation path.
flowchart TD
Owner[Team owner] --> Create[Create membership]
Create --> Pending[Invited membership]
Pending -->|Client invitation| Link[Invitation link]
Link --> Accept[Update membership status]
Accept --> Joined[Joined membership and user session]
Owner --> Roles[Update membership roles]
Roles --> Joined
Owner --> Remove[Delete membership]
Joined -->|Member leaves| Remove
References: src/models.ts• L1083-1147 src/…/teams.ts• L1017-1367 src/…/teams.ts• L1377-1831
Membership administration
Membership collection operations are nested under a team ID because membership access has meaning only within that team. listMemberships and getMembership let team members inspect memberships, subject to the project’s membership privacy setting. Owners use updateMembership to replace a member’s roles.
The membership API supports these administration actions:
createMembershipinvites or adds a person and assigns roles.listMembershipsreturns the team’s memberships with optional search, queries, and count control.getMembershipreads one membership by its membership ID.updateMembershipreplaces the member’s role list. Only owners can use it.deleteMembershipremoves a membership. An owner can remove another member, and a member can use it to leave.
Membership responses can include user contact fields, role data, invitation and join dates, confirmation state, multi-factor authentication state, and recent access time. The project’s membership privacy setting controls which sensitive user fields are visible.
References: src/…/teams.ts• L1007-1676 src/models.ts• L1086-1147
Invitation acceptance
Invitation creation and invitation acceptance are separate operations. The inviter can supply a user ID, email, or phone. If more than one is supplied, a user ID takes priority over email, and email takes priority over phone. A client-side invitation needs an allowed return URL so the recipient can come back to the application and complete acceptance.
The recipient completes acceptance through updateMembershipStatus with the team ID, membership ID, user ID, and invitation secret. A successful request confirms the membership and creates a user session. Server-side invitation calls add the new member automatically instead of waiting for this client acceptance step. src/…/teams.ts• L1154-1367
Return URLs must match a hostname registered as a project platform. This check keeps invitation redirects inside the project’s trusted application set. The account service then owns the resulting user session and authentication state; see Account authentication and security.
References: src/…/teams.ts• L1154-1367 src/…/teams.ts• L1678-1831
Team and membership API boundary
The two API levels share the same Teams service but serve different scopes. Use a team-level operation when the subject is the group as a whole. Use a membership-level operation when the subject is one user’s relationship with that group.
| Concern | Team-level API | Membership-level API |
|---|---|---|
| Resource identity | teamId | teamId and membershipId |
| Main purpose | Create, find, rename, list, configure, or delete a team | Invite, inspect, accept, change roles, or remove one membership |
| Main result | Team or team list | Membership or membership list |
| Access focus | Team ownership and member read access | Owner administration or member self-service |
| Shared state | Team name, count, and preferences | User, roles, invitation, join, and access state |
The SDK exposes Teams as a public service and returns typed Team, TeamList, Membership, and MembershipList models. The same service surface therefore supports both the group lifecycle and the user-to-group lifecycle without making those resources interchangeable.
References: src/…/teams.ts• L6-1972 src/index.ts• L1-17 src/models.ts• L107-132
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to invitation targets or acceptance fields must stay aligned between
createMembershipandupdateMembershipStatus. - Changes to membership privacy must stay aligned with the sensitive fields exposed by the
Membershipmodel and with member-list and member-read behavior. - Changes to team preference replacement semantics must stay aligned with callers that may expect a merge.
- Changes to role rules must stay aligned across team creation, membership creation, role updates, and team deletion.
- Changes to the public
Teamsexport or team model types must stay aligned with the service return types used by applications.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client uses an unregistered invitation return URL | Invitation redirect is rejected | Register the URL hostname as a project platform before creating the invitation |
| A caller supplies no valid invitation identity | No target user can be selected for the membership | Supply a user ID, email, or phone number |
| A caller accepts an invitation with the wrong user, membership, or secret | Membership acceptance fails | Pass the values from the same invitation flow |
| A non-owner tries to change roles or delete the team | The protected operation is rejected | Perform team administration with an owner membership |
| An update sends only part of the team preferences | Existing preferences are replaced by the partial object | Read and rebuild the full preference object before updatePrefs |
Key files
| File | Why to read it |
|---|---|
| src/…/teams.ts | Defines the team and membership lifecycle exposed by the SDK. |
| src/models.ts | Defines the team, membership, and list shapes returned to callers. |
| src/index.ts | Shows the public export of the Teams service and its related SDK types. |
| docs/…/create-membership.md | Shows the input shape for inviting or adding a member. |
| docs/…/update-membership-status.md | Shows the input shape for accepting an invitation. |
| docs/…/update-prefs.md | Shows the input shape for replacing shared team preferences. |