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 / messaging-subscribers

Messaging subscribers

Messaging subscribers connect a delivery target to an Appwrite topic. The Messaging service creates that connection and removes it when the recipient no longer wants messages. A subscriber gives a topic a stable delivery identity without making the topic depend on a device token or other provider detail.

Subscriber model

Topic membership

A subscriber is a membership record between one topic and one target. The record has its own ID and keeps the topic ID, target ID, user identity, and provider type together. Later delivery can use this record to resolve both the audience and the channel.

The subscriber ID identifies the membership record. It is separate from the target ID and the topic ID. This separation lets one target join more than one topic while each topic keeps its own subscriber relationship.

References: src/models.ts• L1437-1476

Delivery identity

The target is the endpoint that can receive a message. It carries the provider type and provider-specific identifier. In the account flow, the current user registers a target with a chosen or generated target ID. Messaging then uses that target as the recipient endpoint.

The subscriber does not replace account identity. Its userId and userName fields describe the user related to the subscription, while targetId selects the delivery endpoint. This distinction matters when one user has several devices or other delivery targets.

For the account and session context around targets, see Account authentication and security.

References: src/models.ts• L1454-1476 src/models.ts• L1480-1518 src/…/account.ts• L2069-2138

Subscriber lifecycle

Subscription creation

Creating a subscriber attaches a target to a topic and returns the resulting subscriber record. The caller supplies the topic to join, the subscriber ID for the relationship, and the target ID for delivery.

The creation flow turns an existing delivery target into topic membership:

flowchart LR
    A[Topic ID] --> D[Create subscriber]
    B[Subscriber ID] --> D
    C[Target ID] --> D
    D --> E[Subscriber record]
    E --> F[Topic can address the target]

The Messaging service requires topicId, subscriberId, and targetId before it sends the request. The topic ID cannot be empty. The subscriber ID and target ID must be present so the returned subscriber record can represent a usable relationship. A working target should exist before this step so the topic has a valid delivery endpoint.

A client should use the object form shown in docs/…/create-subscriber.md. The service also accepts a positional form for older callers, but that form is deprecated.

References: src/…/messaging.ts• L11-137 docs/…/create-subscriber.md• L1-17

Subscription deletion

Deleting a subscriber removes one topic-to-target relationship. The caller must identify both the topic and the subscriber because the subscriber belongs to a topic in the Messaging API path.

Deletion does not remove the target itself. It only stops that target from receiving messages through the deleted topic. The same target can remain available for another topic or for other account messaging use.

The client can use the object form shown in docs/…/delete-subscriber.md. The operation returns an empty result when the request succeeds.

References: src/…/messaging.ts• L139-214 docs/…/delete-subscriber.md• L1-16

Messaging delivery workflow

Topic-to-target resolution

Appwrite messaging delivery uses the subscriber as the link between a topic and a recipient endpoint. A topic identifies the message audience. The subscriber selects the target that represents a user's delivery address. The target then supplies the provider information needed to attempt delivery.

This workflow separates audience management from endpoint management. Applications can change or remove a target through the account APIs while topic membership remains a separate concern. Applications can also remove a subscriber without deleting the user's account or all of the user's targets.

The relationship can be viewed as a short chain:

sequenceDiagram
    participant App as Application
    participant Msg as Messaging
    participant Topic as Topic
    participant Target as Delivery target
    participant Provider as Message provider

    App->>Msg: Create subscriber(topicId, subscriberId, targetId)
    Msg->>Topic: Record topic membership
    Topic->>Target: Resolve subscribed target
    Target->>Provider: Supply provider type and identifier
    Provider-->>Target: Attempt message delivery
    App->>Msg: Delete subscriber(topicId, subscriberId)
    Msg-->>Topic: Remove topic membership

For the wider identity and collaboration model, see Identity and collaboration services. For account context around delivery targets, see Account authentication and security.

References: src/…/messaging.ts• L11-214 src/models.ts• L1454-1518 src/…/account.ts• L2069-2245

Change checklist

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

  • Keep the Subscriber model fields aligned with the identifiers returned by subscriber creation and consumed by deletion.
  • Preserve the distinction between a topic membership ID and the target ID used for delivery.
  • If target creation or deletion changes, confirm that subscriber workflows still refer to valid target identities.
  • If the Messaging endpoint contract changes, update both the object-form examples and the lifecycle description. Keep the object form as the current client shape while treating the positional form as deprecated.
  • Keep links from the identity parent page and the account child page aligned with the document slugs.

Important failure modes

TriggerConsequenceGuard
topicId is missing or empty when a subscriber is createdThe SDK rejects the request before it reaches AppwriteSupply a non-empty topic identity for the subscription
subscriberId or targetId is missing during creationNo topic membership is createdTreat all three creation inputs as required
Deletion uses the wrong topic ID or subscriber IDThe intended membership is not addressedStore the pair returned or used at creation time
A subscriber points to a target that no longer exists or cannot deliverTopic delivery cannot reach that recipient endpointManage target lifetime with subscriber lifetime

Key files

FileWhy to read it
src/…/messaging.tsDefines the subscriber creation and deletion contract and the topic-scoped identity used by each request.
src/models.tsDefines the Subscriber and Target records that explain the relationship between topic membership and delivery endpoints.
src/…/account.tsShows how a user registers, updates, and removes the target that Messaging uses for delivery.
docs/…/create-subscriber.mdShows the supported client shape for joining a topic.
docs/…/delete-subscriber.mdShows the supported client shape for leaving a topic.