> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.swellsystem.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Workspace API

# Workspace API

Workspace pages, blocks, templates, versions, and comments are available via the REST API.

## Authentication

Use a valid API token with `tenant` context. All endpoints require `auth:sanctum`.

## Endpoints

### Templates

**GET** `/api/v1/workspace/templates`

Returns available page templates (from config and blueprint-compatible sources).

Response:

```json
{
  "data": [
    {
      "key": "blank",
      "title": "Untitled",
      "blocks_count": 0
    },
    {
      "key": "meeting_notes",
      "title": "Meeting Notes",
      "blocks_count": 5
    }
  ]
}
```

### Pages

**GET** `/api/v1/workspace/pages`

Query parameters:

- `parent_id` – Filter by parent (omit for root)
- `flat` – If `1`, return flat list instead of tree
- `search` – Search by page title
- `archived` – If `1`, include archived pages

**POST** `/api/v1/workspace/pages`

Create a page from a template.

Body:

```json
{
  "template_key": "meeting_notes",
  "parent_id": 123
}
```

- `template_key` (required): `blank`, `meeting_notes`, `project_brief`, or custom
- `parent_id` (optional): Parent page/folder ID

**GET** `/api/v1/workspace/pages/{block}`

Get a page or folder with its blocks.

**PATCH** `/api/v1/workspace/pages/{block}`

Update a page. Body can include `content`, `icon`, `cover`, `archived`.

### Versions

**GET** `/api/v1/workspace/pages/{block}/versions`

List version history for a page.

**POST** `/api/v1/workspace/pages/{block}/versions/{versionId}`

Restore a version. Replaces current page content.

### Comments

**GET** `/api/v1/workspace/pages/{block}/comments`

List comments for a page.

**POST** `/api/v1/workspace/pages/{block}/comments`

Add a comment.

Body:

```json
{
  "content": "Your comment text"
}
```

### Table

**POST** `/api/v1/workspace/table/move-row`

Move a table row to a different group (board view).

Body:

```json
{
  "block_id": 456,
  "row_index": 1,
  "new_group_value": "Done"
}
```

- `block_id` – Table block ID
- `row_index` – 0-based row index (0 = first data row)
- `new_group_value` – Target column/group name
