Help & Support

Membership Approvals

This guide explains how to use the Membership Approval Group Rule to manage Group memberships.

A Group configured with the Membership Approval Group Rule allows to create a Group where accounts requesting to join must be approved by the Group owner or an admin.

Submit Join Request

To submit a join request to a Group, follow these steps.

You MUST be authenticated as Account Manager, or Account Owner to perform this operation.

1

Requires Approval

First, inspect the group.membershipApprovalEnabled flag to figure out which groups require approval for joining.

2

Check Other Rules

Next, inspect the group.operations.canJoin field to determine whether the logged-in Account is allowed to join. Some Groups may have restrictions on who can join them.

Check Rules
switch (group.operations.canJoin.__typename) {  case "GroupOperationValidationPassed":    // Joining the group is allowed    break;
  case "GroupOperationValidationFailed":    // Joinin the group is not allowed    console.log(group.operations.canJoin.reason);    break;
  case "GroupOperationValidationUnknown":    // Validation outcome is unknown    break;}

Where:

  • GroupOperationValidationPassed: The logged-in Account can join the Group.

  • GroupOperationValidationFailed: Joining the Group is not allowed. The reason field explains why, and unsatisfiedRules lists the unmet requirements.

  • GroupOperationValidationUnknown: The Group has one or more unknown rules requiring ad-hoc verification. The extraChecksRequired field provides the addresses and configurations of these rules.

Treat the GroupOperationValidationUnknown as failed unless you intend to support the specific rules. See Group Rules for more information.

3

Request to Join

Next, if allowed, request to join the Group.

Use the requestGroupMembership action to submit a join request to a Group.

Join Request
import { evmAddress } from "@lens-protocol/client";import { requestGroupMembership } from "@lens-protocol/client/actions";
const result = await requestGroupMembership(sessionClient, {  group: evmAddress("0xe2f…"),});
if (result.isErr()) {  return console.error(result.error);}

4

Handle Result

Then, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await requestGroupMembership(sessionClient, {  group: evmAddress("0xe2f…"),}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

That's it—these accounts are now banned from joining the Group.

Cancel Join Request

You can cancel a pending join request at any time before it is approved.

You MUST be authenticated as Account Manager, or Account Owner to perform this operation.

1

Cancel the Request

Use the cancelGroupMembershipRequest action to cancel a pending join request to a Group.

Cancel Request
import { evmAddress } from "@lens-protocol/client";import { cancelGroupMembershipRequest } from "@lens-protocol/client/actions";
const result = await cancelGroupMembershipRequest(sessionClient, {  group: evmAddress("0xe2f…"),});
if (result.isErr()) {  return console.error(result.error);}

2

Handle Result

Then, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await cancelGroupMembershipRequest(sessionClient, {  group: evmAddress("0xe2f…"),}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

That's it—these accounts are now banned from joining the Group.

Manage Join Requests

A Group owner or admin can list, approve, or reject pending join requests for a Group.

You MUST be authenticated as Builder, Account Manager, or Account Owner and be the Group owner or an admin to perform this action.

List Join Requests

Use the paginated fetchGroupMembershipRequests action to list all pending join requests for a given Group.

List Requests
import { evmAddress } from "@lens-protocol/client";import { fetchGroupMembershipRequests } from "@lens-protocol/client/actions";
import { client } from "./client";
const result = await fetchGroupMembershipRequests(client, {  group: evmAddress("0x1234…"),});
if (result.isErr()) {  return console.error(result.error);}
// items: Array<GroupMembershipRequest>: [{ account: Account, requestedAt: DateTime, lastActiveAt: DateTime, …}, …]const { items, pageInfo } = result.value;

See the Pagination guide for more information on how to handle paginated results.

Approve Requests

Use the approveGroupMembershipRequests action to approve join requests for a Group.

Approve Requests
import { evmAddress } from "@lens-protocol/client";import { approveGroupMembershipRequests } from "@lens-protocol/client/actions";
const result = await approveGroupMembershipRequests(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x8765…")],});
if (result.isErr()) {  return console.error(result.error);}

And, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await approveGroupMembershipRequests(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x8765…")],}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

Reject Requests

Use the rejectGroupMembershipRequests action to reject join requests for a Group.

Approve Requests
import { evmAddress } from "@lens-protocol/client";import { rejectGroupMembershipRequests } from "@lens-protocol/client/actions";
const result = await rejectGroupMembershipRequests(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x8765…")],});
if (result.isErr()) {  return console.error(result.error);}

And, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await rejectGroupMembershipRequests(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x8765…")],}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.