> ## 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.

# Ban Member

> Ban a member from a space

Sets a member's status to `"banned"`, in this space and the child spaces where they are an active member (a pending or rejected request in a child space is left as it is), and ends their membership of those spaces' chats, so they can no longer post to or receive them (they keep read access to messages from before the ban). A request to join that is still pending can be banned too. Requires the caller to be a moderator or admin. Moderators can only ban regular members. Only the **space creator** can ban admins, and the last admin cannot be banned.

## Path Parameters

<ParamField path="spaceId" type="string" required>
  UUID of the space.
</ParamField>

<ParamField path="memberId" type="string" required>
  UUID of the membership record to ban.
</ParamField>

## Body

<ParamField body="reason" type="string">
  Optional reason for the ban, kept with who banned them in the space's ban log.
</ParamField>

## Response

<ResponseField name="message" type="string">
  Confirmation message.
</ResponseField>

<ResponseField name="membership" type="object">
  The updated membership record with `status: "banned"`.
</ResponseField>

## Error Responses

<AccordionGroup>
  <Accordion title="Membership Not Found — 404">
    ```json theme={null}
    { "error": "Membership not found.", "code": "space/membership-not-found" }
    ```
  </Accordion>

  <Accordion title="Already Banned — 409">
    The member is already banned here. The ban is still re-applied to their active memberships in child spaces, under the same rules as a first ban, so a repeated ban can instead return one of the errors below.

    ```json theme={null}
    { "error": "This member is already banned.", "code": "space/already-banned" }
    ```
  </Accordion>

  <Accordion title="Insufficient Permissions — 403">
    A moderator banning someone who is a moderator or admin in this space or in a child space the ban reaches. `spaceId` names that space.

    ```json theme={null}
    { "error": "Moderators can only ban regular members.", "code": "space/insufficient-permissions", "spaceId": "…" }
    ```
  </Accordion>

  <Accordion title="Creator Required — 403">
    Someone other than the space creator banning a member who is an admin in this space or in a child space the ban reaches. `spaceId` names that space.

    ```json theme={null}
    { "error": "Only the space creator can ban admins.", "code": "space/creator-required", "spaceId": "…" }
    ```
  </Accordion>

  <Accordion title="Last Admin — 400">
    The member is the last admin of this space or of a child space the ban reaches. `spaceId` names that space.

    ```json theme={null}
    { "error": "Cannot ban the last admin. Promote another member to admin first.", "code": "space/last-admin", "spaceId": "…" }
    ```
  </Accordion>
</AccordionGroup>

See also: [useBanMember](/v8/hooks/spaces/use-ban-member), [Unban Member](/v8/api-reference/spaces/membership/unban-member)


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