Skip to main content
Quick Reference for AI Agents & Developers
// Transfer ownership (owner only)
await CometChat.transferGroupOwnership("group_guid", "new_owner_uid");

// Common pattern: Transfer then leave
await CometChat.transferGroupOwnership("group_guid", "new_owner_uid");
await CometChat.leaveGroup("group_guid");

// Note: Owner must transfer ownership before leaving the group
Transfer group ownership to another member when you need to step down as owner.
Availability: SDK, API, UI KitsOnly the current owner can transfer ownership. The owner must transfer ownership before leaving the group.

Transfer Ownership

const GUID = "group-123";
const UID = "new-owner-uid";

CometChat.transferGroupOwnership(GUID, UID).then(
  () => console.log("Ownership transferred successfully"),
  (error) => console.log("Failed to transfer:", error)
);
ParameterDescription
GUIDGroup identifier
UIDUID of the new owner (must be a group member)

When to Transfer Ownership

The owner cannot leave a group without first transferring ownership. Transfer to another admin or trusted member before leaving.
When the current owner is no longer the appropriate person to manage the group (e.g., leaving the company, changing teams).

Implementation Example

async function transferAndLeave(groupId, newOwnerId) {
  try {
    // First transfer ownership
    await CometChat.transferGroupOwnership(groupId, newOwnerId);
    console.log("Ownership transferred");
    
    // Now you can leave the group
    await CometChat.leaveGroup(groupId);
    console.log("Left group successfully");
  } catch (error) {
    console.log("Failed:", error);
  }
}

// Usage
await transferAndLeave("group-123", "user456");

Next Steps