---
orphan: true
---

# Query the source database table

Paginated queries for the current identity can be used to create published source database tables.

```text
GET https://moi.matrixorigin.cn/newmoi/data-share/source-databases/{source_database_id}/tables
```

## Preparation before calling

First [query the database list](../catalog/list-databases.md) to obtain the source database ID. Prepare a personal access token with access to the target workspace, the target workspace ID, and the source database ID.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$SOURCE_DATABASE_ID`: Source database ID, which must be a canonical string of positive integers.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/data-share/source-databases/$SOURCE_DATABASE_ID/tables?page=1&page_size=20" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `source_database_id` | string | Yes | Source database ID. |

## Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer | No | Page number. |
| `page_size` | integer | No | Quantity per page. |

## Successful response

On success, `200` and the publishable table of the current page are returned.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "list": [
      {
        "id": "101",
        "name": "orders"
      }
    ],
    "total": 1,
    "page": 1,
    "page_size": 20
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.list` | array | Tables that can be published on the current page. |
| `data.list[].id` | string | Stable identification of the MatrixOne table. |
| `data.list[].name` | string | Table name. |
| `data.total` | integer | The total number of matching tables. |
| `data.page` | integer | Current page number. |
| `data.page_size` | integer | Number per page. |

In field paths, `[]` means each item in an array. For example, `data.list[].id` is the `id` field of each item in `data.list`.

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - The source database ID or paging parameter is invalid.
  - Check path and query parameters.
* - `403`
  - `ErrPermissionDenied`
  - The current identity does not have permission to read the source database or table.
  - Use credentials with read permissions.
* - `404`
  - `ErrDataShareSourceNotFound`
  - The source database or table no longer exists or cannot be matched.
  - Refresh the source database and table list and try again.
* - `500`
  - `ErrServer`
  - The server failed to query the source table.
  - Try again later.
```
