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

# Use workspace list actions

> Low-level actions for fetching, creating, and deleting workspaces in a list

## Overview

`useWorkspaceListActions` provides the low-level fetch, create, and delete operations used internally by `useWorkspaceList`. In most cases you should use [`useWorkspaceList`](https://docs.sublay.io/v8/hooks/workspace-lists/use-workspace-list) directly, which wraps these actions with filter state, debouncing and load-more.

Use this hook only when you need direct control over fetching a list's pages.

## Usage Example

```tsx theme={null}
import { useWorkspaceListActions } from "@sublay/react-js";

function CustomWorkspaceLoader({ listId }: { listId: string }) {
  const actions = useWorkspaceListActions();

  const loadWorkspaces = async () => {
    await actions.fetchWorkspaces(listId, {
      page: 1,
      limit: 20,
      relation: "direct",
      sortDir: "asc",
    });
  };
}
```

## Methods

**fetchWorkspaces** `(listId: string, params: FetchWorkspacesOptions) =\> Promise\<Workspace[] | null\>`

Fetch one page for the given list and store it in Redux state: page 1 replaces the list, a later page is appended. `params` takes `page` and `limit` (both required) and the optional filters `relation`, `parentWorkspaceId`, `sortDir` and `include` (an array). A filter that is `null` or left out isn't sent, so the server's default applies. Throws on a failed request, after recording the error on the list.

**createWorkspace** `(listId: string, props: CreateWorkspaceOptions) =\> Promise\<Workspace | undefined\>`

Create a workspace (`name`, optional `metadata` and `parentWorkspaceId`), read it back with the optional `include` flags so it carries `reasons`, and add it to the given list where the server would list it — see [`createWorkspace`](https://docs.sublay.io/v8/hooks/workspace-lists/use-workspace-list) on `useWorkspaceList`. If the read-back fails, the workspace the create returned is added, without `reasons`. Throws if the create fails.

**deleteWorkspace** `(listId: string, props: \{ workspaceId: string \}) =\> Promise\<void\>`

Delete a workspace and remove it from the given list's state. Throws on a failed request, leaving the list as it was.

> [!TIP]
>
> Prefer `useWorkspaceList` for most use cases — it handles filter state, pagination, debouncing and load-more.


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