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

> Remove your own membership on this node

Removes the caller's own membership on **this node only** (self-service, no capability). Leaving a parent while still owning a child is fine — ownership is independent of membership. Fires `workspace.member.removed`.

<Note>
  An **owner** has no member row and cannot leave via this path — an owner exits by transferring ownership or deleting the workspace. Sole-owner protection blocks a sole owner from leaving without transferring first. If the caller has **no direct member row here** (only reaches in from an ancestor), leave is a no-op / 404.
</Note>

## Path Parameters

<ParamField path="id" type="string" required>
  The workspace UUID.
</ParamField>

## Body Parameters

<ParamField body="actingUserId" type="string" required>
  Service/master keys only — the user to act as, whose membership is removed (sent in the body so the act-as-user path works on `DELETE`). **Required for a key:** leaving is inherently self-service, so there is no unbounded path — a key that names nobody is refused with `400 workspace/missing-user-id`.

  A plain user token omits it — the actor is the token's own user. The field is **not** ignored for such a token: sending your *own* user id is a harmless no-op, but sending **anyone else's** is a `403 workspace/unauthorized`. See [Acting on behalf of a user](/v8/sdk/workspaces/overview#acting-on-behalf-of-a-user).
</ParamField>

## Response

`204 No Content` on success.

## Error Responses

<AccordionGroup>
  <Accordion title="Not a Member — 404">
    ```json theme={null}
    { "error": "You are not a direct member of this workspace.", "code": "workspace/not-found" }
    ```
  </Accordion>

  <Accordion title="Sole Owner — 409">
    ```json theme={null}
    { "error": "The workspace owner cannot leave. Transfer ownership or delete the workspace first.", "code": "workspace/sole-owner" }
    ```
  </Accordion>

  <Accordion title="Missing Acting User — 400">
    ```json theme={null}
    { "error": "Missing user ID", "code": "workspace/missing-user-id" }
    ```

    A service/master key called this route without naming an `actingUserId`. Leaving removes *your own* membership row; there is none for the app itself. To remove somebody else, use [Remove Member](/v8/api-reference/workspaces/members/remove-member).
  </Accordion>

  <Accordion title="Acted as Another User — 403">
    ```json theme={null}
    { "error": "Unauthorized", "code": "workspace/unauthorized" }
    ```

    A plain user token sent an `actingUserId` naming a **different** user. Only a service/master key may act as someone else.
  </Accordion>

  <Accordion title="Invalid Path Parameter — 400">
    ```json theme={null}
    { "error": "Invalid workspace id: expected a UUID.", "code": "workspace/invalid-params" }
    ```

    Every path id on the workspaces bundle is checked for UUID shape before the route runs, so a malformed one is a plain `400` rather than a `500` from the database.
  </Accordion>
</AccordionGroup>


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