Rest api add user to document's channel

hi , Suppose user1 joined and create a document(doc1) and later user2 get joined, now how user2 can access to doc1 from rest api (and not by user1) ?

@hrs7000

In simple scenario you could create a role that contains the channel that doc1 (and other docs?) is mapped to.

Either assign the role to new users, when they are created via the ADMIn REST API, who will get access to the channel and doc1.

Or when first conneting to Sync Gateway users can create a document with a type property e.g. “type”:“joining”, which the Sync Gateway sync function processes and dynamically assigns the user the role at that point.

Andy

thanks man for your help