跳到主要内容

Share Groups

Share group access with other users, transfer ownership, and manage sharing requests.

备注

userInstance and group — see Manage Groups. Sharing uses ESPGroupSharingRequest for accept/decline.

What This Module Does ?

Grant other users access to one or many groups, transfer ownership, or revoke access—at user level (shareGroups, transferGroups) or single-group level (group.share, group.transfer).

Use user-level APIs to share multiple groups in one request. Use group-level APIs when the UI is focused on one group.

Expected outcome: Sharing requests are created; recipients accept to gain access; owners can revoke or transfer.

Common Workflows

Share multiple groups

const requestId = await userInstance.shareGroups({
username: "family@example.com",
groupIds: ["group_id_1", "group_id_2"],
});

Transfer multiple groups

await userInstance.transferGroups({
toUserName: "new_owner@example.com",
groupIds: ["group_id_1"],
selfToSecondary: false,
});

Share one group

await group.share({
username: "guest@example.com",
makePrimary: false,
});

Revoke access

await group.removeSharingFor("former_user@example.com");

View sharing info

const sharingInfo = await group.getSharingInfo({
groupId: group.id,
subGroups: true,
parentGroups: true,
metadata: true,
});

Accept a received request

const { sharedRequests } = await userInstance.getReceivedGroupSharingRequests();
const request = sharedRequests.find((r) => r.id === requestId);
await request.accept();

Decline or cancel

await request.decline();

const { sharedRequests } = await userInstance.getIssuedGroupSharingRequests();
await sharedRequests[0].remove();

End-to-end flow

// Owner sends
await userInstance.shareGroups({
username: "guest@example.com",
groupIds: [group.id],
});

// Guest accepts
const { sharedRequests } = await userInstance.getReceivedGroupSharingRequests();
const pending = sharedRequests.find((r) => r.groupIds.includes(group.id));
await pending.accept();

Error Handling

try {
await userInstance.shareGroups({ username, groupIds });
} catch (error) {
console.error("Group sharing failed:", error);
}

Advanced Concepts

Request lifecycle

User-level vs group-level

APIScope
shareGroups / transferGroupsMultiple groups
group.share / group.transferCurrent group only

Best Practices

  1. Show pending sent and received requests in settings UI
  2. Confirm before transfer — ownership change is significant
  3. Use batch shareGroups when inviting a user to several rooms at once
  4. Call getSharingInfo before showing who has access

On this page