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

# Leave Space

> Leave a space

Removes the authenticated user's membership from a space and from its child spaces, and ends their membership of those spaces' chats. A ban in a child space is kept: leaving does not clear it.

## Path Parameters

**spaceId** `string` *required*

UUID of the space to leave.

## Response

**message** `string`

Confirmation message.

## Errors

> [accordion] No Membership — 404
>
> A service key acted for a user who has no membership in the space.
>
> ```json theme={null}
> { "error": "You are not a member of this space.", "code": "space/not-member" }
> ```

> [accordion] Not a Member — 403
>
> The user is not an active member of the space (for example, banned), including when a service key acts for them.
>
> ```json theme={null}
> { "error": "Space membership required", "code": "space/membership-required" }
> ```

> [accordion] Creator Cannot Leave — 400
>
> ```json theme={null}
> { "error": "The space creator cannot leave the space. Transfer ownership or delete the space instead.", "code": "space/creator-cannot-leave" }
> ```

> [accordion] Last Admin — 400
>
> The user is the last admin of this space:
>
> ```json theme={null}
> { "error": "You are the last admin of this space. Promote another member to admin before leaving, or delete the space.", "code": "space/last-admin" }
> ```
>
> or of one of its child spaces, named by `spaceId`:
>
> ```json theme={null}
> { "error": "You are the last admin of a child space. Promote another member to admin there before leaving.", "code": "space/last-admin", "spaceId": "…" }
> ```

See also: [useLeaveSpace](https://docs.sublay.io/v7/hooks/spaces/use-leave-space.md)


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