GET / DELETE /spaces/:spaceId/members/me); the functions that take a userId (updateMemberRole, approveMembership, declineMembership, banMember, unbanMember) act on another member, and passing your own id is refused with 400 space/own-member-id. The space’s owner (its userId: the creator of a top-level space, the root space’s creator for a sub-space) stays an admin for good: they can’t step down, leave the space, or be banned.
joinSpace
Joins a space as the logged-in user, or requests to join if the space requires approval. A private space can’t be joined: joining a space the user can’t see answers404 space/not-found. Its moderators and admins add members with addMember.
Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember). status is "pending" when the space requires approval. A user who is already an active member, or already asked to join, gets their existing membership back unchanged, so a repeat join is safe: it resolves with the same record a fresh join would. The response carries no permissions: fetch the space again to read its memberPermissions after joining.
leaveSpace
Leaves a space as the logged-in user (DELETE /spaces/:spaceId/members/me). The space’s owner can’t leave (409 space/owner-cannot-leave).
Promise<void>. It resolves with no value once the user has left. Fetch the space again to read its memberPermissions, what the user may still do in it as a non-member.
checkMyMembership
Checks the logged-in user’s membership status in a space (GET /spaces/:spaceId/members/me). A user with a membership gets it back whatever its status (a banned user learns they’re banned); a user with no membership in a space they can’t see gets 404 space/not-found.
Promise<CheckMyMembershipResponse>: { isMember, role?, status?, joinedAt?, permissions }. role and joinedAt are present only when isMember is true, and status only when a membership record exists; a field that doesn’t apply is left out, never null. Its permissions come from the same calculation as a fetched space’s memberPermissions.
fetchSpaceMembers
Fetches a paginated list of a space’s members, filterable by role and status.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.
The number of members to return per page: a whole number from
1 to 100. Defaults to 20. A larger value is rejected with 400 space/invalid-query, never lowered to 100.Filter by membership status:
"pending", "active", "banned", or "rejected" (declined join requests). Honoured only when the logged-in user is an admin or moderator of the space. Admins and moderators who leave status out get members of every status. Anyone else always gets active members only, whatever status they send.Promise<SpaceMembersResponse>
fetchSpaceTeam
Fetches the team (admins and moderators) of a space.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.
Returns — Promise<SpaceTeamResponse>
updateMemberRole
Updates another member’s role within a space. Only the space’s owner can promote or demote admins, and nobody can demote the owner.The user id of the member to update. Your own id is refused (
400 space/own-member-id).Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember).
addMember
Adds a user to a space directly: they become an active member at once, with no request or approval step. The logged-in user must be an active moderator or admin of the space. This is how users get into a private space, which can’t be joined. A user with apending or rejected membership becomes active; one who is already an active member is left as they are. A banned user can’t be added until unbanned (409 space/member-banned), nor can a user banned in a parent space (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). The added user gets a space-member-added notification. See Add Member for every case and error.
Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember), with status: "active". role is member for a user just added; one who was already an active member keeps their role. It resolves with the same record whether the user was just added or already was an active member, so a repeat is safe.
approveMembership
Approves a pending membership request.Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember), with status: "active".
declineMembership
Declines a pending membership request.Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember), with status: "rejected".
banMember
Bans another member from a space. A moderator can ban only regular members; only the space’s owner can ban an admin, and the owner can’t be banned.Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember), with status: "banned".
unbanMember
Unbans a previously banned member.Promise<SpaceMember>: the membership record, { id, spaceId, userId, role, status, joinedAt, createdAt } (see SpaceMember), with status: "active".
