# View SQL workbook list

Lists the SQL save records that can be read by the current access credentials. The `workbook_id` in each item can be used to view the version, modify the name, or delete the record.

```text
POST https://moi.matrixorigin.cn/newmoi/workbook/list
```

## Preparation before calling

Prepare a personal access token and workspace ID that has access to the workspace. `$AI_STUDIO_API_KEY` is the personal access token used as the value of the `X-API-Key` request header; `$WORKSPACE_ID` is the target workspace ID used as the value of the `X-Workspace-ID` request header.

At most `100` records are returned each time; `20` records are returned when `page_size` is not specified. When the `next_page_token` in the response is not empty, fill the value into the `page_token` of the next request as it is; when it is empty, it means that the last page has been reached.

## Request body

Replace caller-specific values in the example with actual values.

::::{div} mo-api-split
:::{div} mo-api-split-main
```{raw} html
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>search</code><span class="mo-api-field__type">string</span></dt><dd>Search by name.</dd></div>
<div class="mo-api-field"><dt><code>page_size</code><span class="mo-api-field__type">integer</span></dt><dd>Number per page, ranging from `1` to `100`; if not passed, it is `20`.</dd></div>
<div class="mo-api-field"><dt><code>page_token</code><span class="mo-api-field__type">string</span></dt><dd>Next page token.</dd></div>
</dl>
```
:::
:::{div} mo-api-split-aside
```{raw} html
<p class="mo-api-example-label">Request example</p>
```
```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workbook/list" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "page_size": 20
  }'
```
:::
::::
## Successful response

`data.result` is the record list of saved SQL, and `data.total` is the total number of matches. The `workbook_id` in each item can be used to later view the version, modify the name, or delete the record.

```json
{
  "code": 200,
  "data": {
    "total": 1,
    "result": [
      {
        "workbook_id": "workbook-123",
        "name": "销售分析"
      }
    ],
    "next_page_token": ""
  }
}
```

The response fields are as follows.


| Field | Type | Description |
| --- | --- | --- |
| `data.total` | integer | The total number of records matched by the current query. |
| `data.result` | array | Record list of saved SQL. |
| `data.result[].workbook_id` | string | ID of SQL saved record. |
| `data.result[].name` | string | The name of the saved record. |
| `data.next_page_token` | string | Next page mark; if empty, there will be no next page. |

In field paths, `[]` denotes each item in an array. For example, `items[].name` is the `name` field of each item in the `items` array.


## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main
```{raw} html
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">integer or string</span></dt><dd>Error code or status.</dd></div>
<div class="mo-api-field"><dt><code>message</code><span class="mo-api-field__type">string</span></dt><dd>Error message.</dd></div>
</dl>
```
:::
:::{div} mo-api-split-aside
```{raw} html
<p class="mo-api-example-label">Error response example</p>
```
```json
{
  "code": 400,
  "message": "请求参数无效"
}
```
:::
::::
## Follow-up operations

Save the identifier of the target item, and then [View the saved SQL version content](get-workbook.md).
