Your own membership and other members’ are separate routes. Your own membership is
/spaces/:spaceId/members/me: GET to check it (useCheckMyMembership), DELETE to leave (useLeaveSpace). /spaces/:spaceId/members/:userId/… (approve, decline, role, ban, unban) is for acting on another member, addressed by their user id (user.id on a member list entry), and refuses your own id with 400 space/own-member-id.The space’s owner stays an admin. The space’s owner is its userId: the creator of a top-level space, the root space’s creator for a sub-space. They can’t step down, leave the space, or be banned — not by another admin, and not by a report on their own content.Joining and Leaving
The simplest membership operations are exposed directly fromuseSpace:
requireJoinApproval: true, joinSpace() creates a pending membership that must be approved by a moderator or admin before the user becomes active.
A private space can’t be joined, and has no join requests: joining a space the user can’t see answers 404 space/not-found, as if it didn’t exist. Its moderators and admins add its members instead (see Adding Members Directly).
Fetching Members
Use standalone hooks to fetch member lists:memberPermissions.canRead). The member list shows active members only, except to the space’s admins and moderators, who see every status (pending, active, banned, rejected) and can filter by one with status. A members-only space, or a space under one, answers 403 space/membership-required to a user who isn’t an active member of that members-only space or of a space between it and this one.
Checking Membership Status
Check the current user’s membership without loading the full space:role and joinedAt are present only for an active member, and status only when the user has a membership record; a field that doesn’t apply is left out rather than sent as null.
A user with a membership in the space gets it back whatever its status (pending, banned, rejected), so a banned user learns they are banned. A user with no membership in a space they can’t see gets 404 space/not-found. permissions is the same calculation as a fetched space’s memberPermissions.
useJoinSpace resolves with the user’s membership record and useLeaveSpace with nothing; neither carries permissions. joinSpace / leaveSpace from useSpace fetch the space again after the change, so its memberPermissions, canPost and canRead stay the server’s answer: a pending request isn’t membership, so in a "members" space it can’t post yet, and a user who leaves keeps reading only what non-members may read.
Approving and Declining Requests
Moderators and admins can process pending membership requests:userId is the requesting user’s id (user.id on an entry from useFetchSpaceMembers).
Both
useApproveMember and useDeclineMember require the caller to be a moderator or admin of the space.Adding Members Directly
A moderator or admin can add a user to a space directly withuseAddMember. The user becomes an active member at once, with no request or approval step, and gets a space-member-added notification. This is how users get into a private space, which can’t be joined.
pending or rejected membership becomes active, and an active member is left as they are. A banned user must be unbanned first (409 space/member-banned); a user banned in a parent space can’t be added either (409 space/banned-in-parent). A user can’t be added when there is a block between them and the adder, in either direction (404 space/user-not-found, the same answer as for a user who doesn’t exist), or when they are suspended (403 space/user-cannot-be-added).

