Introducing a new way to review your PRs.

Read the announcement

appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎

View on GitHub

24 documents · Updated Nov 18, 2026

docs / teams-and-memberships

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:

  • list returns teams in which the current user is a member. Search and query inputs can narrow the result, and the total count can be skipped.
  • create creates a team and assigns the creator as an owner. The caller can provide initial roles for that owner membership.
  • get reads one team by ID.
  • updateName changes the team name.
  • delete removes 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:

  1. An owner creates a membership for an existing user or an invite target identified by email or phone.
  2. The membership receives the requested roles and an invitation record.
  3. A client invitation sends the target a link. The target uses the returned invitation values to accept the invitation.
  4. Acceptance marks the membership as joined and creates a session for the user.
  5. 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:

  • createMembership invites or adds a person and assigns roles.
  • listMemberships returns the team’s memberships with optional search, queries, and count control.
  • getMembership reads one membership by its membership ID.
  • updateMembership replaces the member’s role list. Only owners can use it.
  • deleteMembership removes 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.

ConcernTeam-level APIMembership-level API
Resource identityteamIdteamId and membershipId
Main purposeCreate, find, rename, list, configure, or delete a teamInvite, inspect, accept, change roles, or remove one membership
Main resultTeam or team listMembership or membership list
Access focusTeam ownership and member read accessOwner administration or member self-service
Shared stateTeam name, count, and preferencesUser, 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 createMembership and updateMembershipStatus.
  • Changes to membership privacy must stay aligned with the sensitive fields exposed by the Membership model 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 Teams export or team model types must stay aligned with the service return types used by applications.

Important failure modes

TriggerConsequenceGuard
A client uses an unregistered invitation return URLInvitation redirect is rejectedRegister the URL hostname as a project platform before creating the invitation
A caller supplies no valid invitation identityNo target user can be selected for the membershipSupply a user ID, email, or phone number
A caller accepts an invitation with the wrong user, membership, or secretMembership acceptance failsPass the values from the same invitation flow
A non-owner tries to change roles or delete the teamThe protected operation is rejectedPerform team administration with an owner membership
An update sends only part of the team preferencesExisting preferences are replaced by the partial objectRead and rebuild the full preference object before updatePrefs

Key files

FileWhy to read it
src/…/teams.tsDefines the team and membership lifecycle exposed by the SDK.
src/models.tsDefines the team, membership, and list shapes returned to callers.
src/index.tsShows the public export of the Teams service and its related SDK types.
docs/…/create-membership.mdShows the input shape for inviting or adding a member.
docs/…/update-membership-status.mdShows the input shape for accepting an invitation.
docs/…/update-prefs.mdShows the input shape for replacing shared team preferences.