> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Space Members

> Manage space membership — joining, leaving, approvals, role assignments, and bans

export const SpaceReputationParams = ({variant = "context", field = "path"}) => {
  const isUser = variant === "user";
  return <>
      <ParamField {...{
    [field]: "spaceReputation",
    type: "object"
  }}>
        Opt-in. Adds a <code>spaceReputation</code> number to each returned user,
        scoped to a single space. Requires the <code>reputation</code> bundle.
        The <code>reputation</code> total is always present regardless;{" "}
        <code>spaceReputation</code> is purely additive and only appears when you
        pass this object. <strong>This object is the primary form</strong> — it
        replaces the deprecated flat props below. See the{" "}
        <a href="/v8/data-models/reputation">Reputation data model</a> for the
        full contract.

        <Expandable title="spaceReputation">
          {isUser ? <ParamField name="spaceId" type="string | &quot;none&quot;" required>
              Which bucket to read. A space <strong><code>&lt;uuid&gt;</code></strong> reads that
              space's bucket; <strong><code>"none"</code></strong> reads the
              project-general (space-less) bucket.{" "}
              <strong><code>"context"</code> is rejected (400)</strong> on this
              endpoint — there is no space context to derive. The empty string
              and the legacy <code>general</code> / <code>null</code> aliases are
              also rejected. Missing buckets read as <code>0</code>.
            </ParamField> : <ParamField name="spaceId" type="string | &quot;none&quot; | &quot;context&quot;" required>
              Which bucket to read. One of: a space <strong><code>&lt;uuid&gt;</code></strong>{" "}
              (that space's bucket), <strong><code>"none"</code></strong> (the
              project-general, space-less bucket), or{" "}
              <strong><code>"context"</code></strong> (the space derived from the
              request context — resolved per-row on lists, or the single space on
              member/team/conversation surfaces). The empty string and the legacy{" "}
              <code>general</code> / <code>null</code> aliases are rejected (400).
              Missing buckets read as <code>0</code>.
            </ParamField>}
          <ParamField name="includeDescendants" type="boolean">
            Only honored when <code>spaceId</code> is an explicit space <code>&lt;uuid&gt;</code>.
            When <code>true</code>, <code>spaceReputation</code> is the{" "}
            <strong>subtree sum</strong> — the named space plus all of its
            descendant spaces (the root space's own bucket included). Ignored for{" "}
            <code>"none"</code>; not allowed with <code>"context"</code>.
          </ParamField>
        </Expandable>
      </ParamField>

      {isUser ? <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code> or <code>"none"</code> only —{" "}
          <code>"context"</code> is rejected (400) on this endpoint.
        </ParamField> : <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code>, <code>"none"</code>, or{" "}
          <code>"context"</code>.
        </ParamField>}

      <ParamField {...{
    [field]: "spaceReputationDescendants",
    type: "boolean",
    deprecated: true
  }}>
        <strong>Deprecated</strong> — use{" "}
        <code>spaceReputation.includeDescendants</code> instead. The flat form,
        only honored alongside an explicit <code>spaceReputationId</code> <code>&lt;uuid&gt;</code>.
      </ParamField>
    </>;
};

The `spaces` module includes a full set of membership management functions. Use these to build admin tools, automate onboarding flows, or enforce membership policies server-side.

***

### joinSpace

Adds a user to a space. If the space requires approval (`requireJoinApproval: true`), the membership is created in a pending state.

```typescript theme={null}
const result = await sublay.spaces.joinSpace({
  spaceId: "spc_abc123",
  userId: "usr_abc123",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="userId" type="string" required>
  The Sublay user ID to add.
</ParamField>

**Returns** — `Promise<JoinSpaceResponse>`

***

### leaveSpace

Removes a user from a space.

```typescript theme={null}
const result = await sublay.spaces.leaveSpace({
  spaceId: "spc_abc123",
  userId: "usr_abc123",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="userId" type="string" required>
  The Sublay user ID to remove.
</ParamField>

**Returns** — `Promise<LeaveSpaceResponse>`

***

### checkMyMembership

Returns the membership status of a user in a space.

```typescript theme={null}
const result = await sublay.spaces.checkMyMembership({
  spaceId: "spc_abc123",
  userId: "usr_abc123",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="userId" type="string" required>
  The Sublay user ID to check.
</ParamField>

**Returns** — `Promise<CheckMyMembershipResponse>`

***

### fetchSpaceMembers

Returns a paginated list of approved members in a space.

```typescript theme={null}
const result = await sublay.spaces.fetchSpaceMembers({
  spaceId: "spc_abc123",
  page: 1,
  limit: 20,
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="page" type="number">
  Page number (1-indexed). Defaults to `1`.
</ParamField>

<ParamField body="limit" type="number">
  Results per page. Defaults to `20`.
</ParamField>

<ParamField body="role" type="string">
  Filter by role: `"admin"`, `"moderator"`, or `"member"`.
</ParamField>

<ParamField body="status" type="string">
  Filter by membership status: `"pending"`, `"active"`, `"banned"`, or `"rejected"`.
</ParamField>

<SpaceReputationParams variant="context" field="body" />

**Returns** — `Promise<SpaceMembersResponse>`

***

### fetchSpaceTeam

Returns the admin and moderator members of a space (the "team").

```typescript theme={null}
const result = await sublay.spaces.fetchSpaceTeam({ spaceId: "spc_abc123" });
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<SpaceReputationParams variant="context" field="body" />

**Returns** — `Promise<SpaceTeamResponse>`

***

### updateMemberRole

Updates a member's role within a space.

```typescript theme={null}
const result = await sublay.spaces.updateMemberRole({
  spaceId: "spc_abc123",
  memberId: "mem_xyz789",
  role: "moderator",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="memberId" type="string" required>
  The Sublay space member ID (not the user ID).
</ParamField>

<ParamField body="role" type="string" required>
  The new role to assign: `"admin"`, `"moderator"`, or `"member"`.
</ParamField>

**Returns** — `Promise<UpdateMemberRoleResponse>`

***

### approveMembership

Approves a pending membership request. Only relevant when the space has `requireJoinApproval: true`.

```typescript theme={null}
const result = await sublay.spaces.approveMembership({
  spaceId: "spc_abc123",
  memberId: "mem_xyz789",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="memberId" type="string" required>
  The Sublay space member ID of the pending member.
</ParamField>

**Returns** — `Promise<ApproveMemberResponse>`

***

### declineMembership

Declines and removes a pending membership request.

```typescript theme={null}
const result = await sublay.spaces.declineMembership({
  spaceId: "spc_abc123",
  memberId: "mem_xyz789",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="memberId" type="string" required>
  The Sublay space member ID of the pending member.
</ParamField>

**Returns** — `Promise<DeclineMemberResponse>`

***

### banMember

Bans a member from a space, preventing them from rejoining.

```typescript theme={null}
const result = await sublay.spaces.banMember({
  spaceId: "spc_abc123",
  memberId: "mem_xyz789",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="memberId" type="string" required>
  The Sublay space member ID to ban.
</ParamField>

<ParamField body="reason" type="string">
  Why the member is banned; kept in the space's ban log.
</ParamField>

**Returns** — `Promise<BanMemberResponse>`

***

### unbanMember

Removes a ban, allowing the user to rejoin the space.

```typescript theme={null}
const result = await sublay.spaces.unbanMember({
  spaceId: "spc_abc123",
  memberId: "mem_xyz789",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="memberId" type="string" required>
  The Sublay space member ID to unban.
</ParamField>

**Returns** — `Promise<UnbanMemberResponse>`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.