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 / identity-and-collaboration-services

Identity and collaboration services

The identity and collaboration services give an application a shared model for the signed-in account, team access, connected applications, and message delivery. Account, Teams, and Messaging work together: an account supplies the user context, teams organize shared access, and subscribers connect that account's message targets to topics.

Service boundary

The services divide identity work by the resource an application needs to manage. Account APIs establish the current user context, team APIs manage shared access and memberships, and messaging APIs attach a user-owned target to a topic.

ServiceSystem roleMain relationship
AccountCurrent account and access contextProvides the user and session state used by later calls
TeamsShared groups, memberships, and app installationsConnects users and applications to teams through roles and access state
MessagingTopic subscriber linksConnects a topic to a message target owned by a user

The SDK exposes these services with typed views for users, sessions, teams, memberships, installations, targets, and subscribers. This gives application code one identity surface while each service keeps its own resource lifecycle. src/index.ts, src/models.ts

Account identity

The Account service is the starting point for application identity. It represents the current user and creates, reads, refreshes, and ends sessions that identify that user for later account and collaboration calls.

Account access and session state

Account access changes an authentication result into a session for the current user. The service supports account creation, anonymous access, password access, browser and native provider access including Vipps OAuth, token exchange, passkeys, and other one-time access flows. Native ID-token access verifies a provider token in one request without a browser redirect. For the full sign-in view, see Account authentication and security. src/…/account.ts• L19-118, src/…/account.ts• L5480-5713

The session view carries the user identity and the state needed to decide whether later requests remain valid. Applications can inspect sessions, extend one, remove one device, or sign out other devices when account state changes. A device can also hold sessions for several accounts and select which session is active. Switching the active session changes the account used by later requests. src/…/account.ts• L796-1184, src/…/account.ts• L4477-4640, src/models.ts• L691-810

This diagram shows how an access method becomes the account context used by team and messaging calls.

sequenceDiagram
    participant App as Application
    participant Account as Account service
    participant Platform as Account system

    App->>Account: Start an access flow
    Account->>Platform: Verify access and create session
    Platform-->>App: Return session or token result
    App->>Account: Complete token flow when needed
    Account->>Platform: Create current session
    Platform-->>App: Current account context

References: src/…/account.ts• L19-118 src/…/account.ts• L796-1184 src/…/account.ts• L4477-4640 src/…/account.ts• L5480-5713 src/models.ts• L691-810

Account profile and message targets

After access is established, Account manages the current user's profile and account-owned state. It also registers the user's message targets, which are receivers such as push devices. A target belongs to the account and holds the provider-facing identifier used to deliver a message. src/…/account.ts• L688-821, src/…/account.ts• L791-1095, src/…/account.ts• L5495-5839, src/models.ts• L460-568, src/models.ts• L813-857

Push target registration links a device to the current session. The service can create or update the target when a device token changes and can remove it when the device must stop receiving messages. The Messaging service later uses the target ID to create a topic subscriber. src/…/account.ts• L6045-6389, src/…/messaging.ts• L16-137

References: src/…/account.ts• L688-821 src/…/account.ts• L791-1095 src/…/account.ts• L6045-6389 src/…/messaging.ts• L16-137 src/models.ts• L460-568 src/models.ts• L813-857

Account security and recovery

Account security protects the identity used by the other services. Verification, recovery, consent, token, and multi-factor flows change whether an account or session can be trusted; they do not replace the session model. For the full access and security view, see Account authentication and security. src/…/account.ts• L158-789, src/…/account.ts• L751-1914, src/…/account.ts• L2181-2542, src/…/account.ts• L6239-6290, src/…/account.ts• L6478-6878

The account service also lets a user review and revoke consent given to third-party applications. A consent groups the granted access, while its token families represent separate authorized devices or sessions. Removing a consent revokes all token families under it; removing one token family leaves the other consented access in place. src/…/account.ts• L250-794

Native provider sign-in has its own provider enablement and client ID checks. The application must pass the provider's ID token and the matching nonce when the provider requires one. The flow can attach to an existing account or create a user when no matching account exists. It does not provide provider refresh tokens. src/…/account.ts• L4457-4520

References: src/…/account.ts• L158-789 src/…/account.ts• L751-1914 src/…/account.ts• L2181-2542 src/…/account.ts• L250-794 src/…/account.ts• L6239-6290 src/…/account.ts• L6478-6878 src/…/account.ts• L4457-4520

Team collaboration

The Teams service turns account identity into shared access groups. A team is the shared container, while a membership links one user to that team and records the invitation state and roles used for access.

Team resources

The team resource represents the shared group. A signed-in account can list teams it can use, create a team, read or rename it, manage shared preferences, and delete it when its role allows team administration. The creator receives the owner role by default. src/…/teams.ts• L16-128, src/…/teams.ts• L131-220, src/models.ts• L1053-1081

Team ownership is an access boundary. Owners manage the team and its members, while ordinary members use the team through their membership. This keeps the group's identity separate from each person's roles and invitation state.

References: src/…/teams.ts• L16-128 src/…/teams.ts• L131-220 src/models.ts• L1053-1081

Team app installations

An app installation links an application to a team. Team members can inspect installations, while owners manage the installation and its authorization details. The installation records the access scopes granted to the app, so it acts as the team's access boundary for connected applications. src/…/teams.ts• L475-591, src/…/teams.ts• L594-710, src/…/teams.ts• L712-807

Changing or removing an installation revokes its earlier installation access tokens. Applications must therefore treat an installation change as a change to the connected app's access state. For the complete installation view, see Organizations and installations. src/…/teams.ts• L809-1001

The installation relationship connects a team, an application, and the access granted to that connection.

flowchart LR
    Team[Team] --> Installation[App installation]
    App[Application] --> Installation
    Owner[Team owner] --> Manage[Manage installation]
    Manage --> Installation
    Installation --> Scopes[Granted scopes]
    Installation --> Tokens[Installation access tokens]
    Installation --> Revoked[Revoked access after change]

References: src/…/teams.ts• L475-591 src/…/teams.ts• L594-710 src/…/teams.ts• L712-807 src/…/teams.ts• L809-1001

Membership lifecycle

Membership is the collaboration link between a user and a team. The service lists and reads memberships, invites a person by account or contact detail, assigns roles, changes roles, removes access, and accepts an invitation after the invited user returns to the application. src/…/teams.ts• L1003-1148, src/…/teams.ts• L1150-1363, src/…/teams.ts• L1365-1663

An invitation has a short client flow:

  1. An owner creates a membership with a role set and an account, email, or phone target.
  2. The platform sends the invitation and returns the user to an approved application URL.
  3. The application submits the team ID, membership ID, user ID, and invitation secret.
  4. The platform confirms the membership and creates a session for the invited user.

The membership state distinguishes an invitation from joined access. Applications must use that state with the member's roles when they decide whether to show team features. For the complete membership view, see Teams and memberships. src/…/teams.ts• L1665-1815, src/models.ts• L1083-1147

This diagram shows how a team invitation becomes a confirmed membership and an account session.

flowchart LR
    Owner[Team owner] --> Invite[Invitation with roles]
    Invite --> Pending[Pending membership]
    Pending --> Accept[Invitation acceptance]
    Accept --> Membership[Confirmed membership]
    Accept --> Session[Invited user's session]

References: src/…/teams.ts• L1003-1148 src/…/teams.ts• L1150-1363 src/…/teams.ts• L1468-1587 src/…/teams.ts• L1590-1663 src/…/teams.ts• L1665-1815 src/models.ts• L1083-1147

Message subscribers

The Messaging service links a topic to a message target. A subscriber is the topic-specific link, not the target itself. This separation lets one account target receive messages for the topics to which it is subscribed.

Subscriber lifecycle

The application first registers a target for the current account. It then creates a subscriber with the topic ID, subscriber ID, and target ID. Topic delivery uses that link and the target's provider type. The application removes the link when the user no longer wants the topic. src/…/account.ts• L6045-6389, src/…/messaging.ts• L16-137, src/…/messaging.ts• L139-214

The delivery relationship is therefore:

flowchart LR
    Account[Current account] --> Target[User-owned message target]
    Topic[Messaging topic] --> Subscriber[Topic subscriber link]
    Target --> Subscriber
    Subscriber --> Delivery[Message delivery]
    Account --> Remove[Remove subscription]
    Remove --> Subscriber

For the full topic subscription view, see Messaging subscribers.

References: src/…/account.ts• L6045-6389 src/…/messaging.ts• L16-137 src/…/messaging.ts• L139-214 src/models.ts• L1437-1477

Change checklist

When these files or sections are changed, remember to consider these:

  • When session, device switching, or native provider access changes, check the handoff from authentication results to the current account context. Check provider enablement, client IDs, nonce rules, and the active device session together.
  • When consent or token-family behavior changes, check which third-party access is revoked by each account action.
  • When target behavior changes, check the subscriber contract because subscribers store target IDs rather than delivery details.
  • When team roles or membership state changes, check owner-only actions and the distinction between invited and joined members.
  • When invitation fields or redirect rules change, check both membership creation and invitation acceptance. Keep the user ID and invitation secret paired.
  • When installation scopes or authorization details change, check the access tokens issued for existing installations. Installation updates and removal revoke those tokens.
  • When service or model names change, check the public exports and the related child-page links.

Important failure modes

TriggerConsequenceGuard
A subscriber is created before a valid account target existsThe topic has no usable message receiverRegister the target first and pass its target ID
A pending membership is treated as joined accessThe user can see team features before accepting the invitationCheck invitation, join, confirmation, and role state
An invitation uses a URL outside the configured platform domainsThe platform rejects or cannot safely complete the return flowUse an approved application URL
A native ID token has the wrong provider, audience, or required nonceSign-in fails and no session is createdEnable native sign-in and match the provider client ID and nonce
A consent is deleted without accounting for its token familiesEvery token family under that consent stops workingTreat consent deletion as a full third-party access revocation
An installation changes while an old installation token is in useCalls made with that token stop workingRefresh authorization and obtain a new token
A session expires or is removed while the app uses its account contextAccount, team, or subscriber calls failRe-establish the session and rebuild account state

Key files

FileWhy to read it
src/index.tsShows the public service and model exports for the identity surface.
src/…/account.tsDefines account access, sessions, account switching, consent state, security state, and user-owned message targets.
src/…/teams.tsDefines teams, installations, memberships, roles, invitations, and shared preferences.
src/…/messaging.tsDefines topic subscriber creation and removal.
src/models.tsDefines the user, session, team, membership, installation, target, and subscriber views.