Create data publication¶
Publish all tables or specified tables in the source database to the target workspace. Successful creation only means that the publication has been established, but does not mean that the target workspace has accepted the subscription.
POST https://moi.matrixorigin.cn/newmoi/data-share/publishes
Preparation before calling¶
Prepare a personal access token, source workspace ID, source database ID, and target workspace ID that has access to the source workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: The ID of the workspace where the data publication is to be created, passed through theX-Workspace-IDHeader.$SOURCE_DATABASE_ID: The source database ID to publish, specified in the request body.$TABLE_ID: The table ID to be published in theselectedrange, specified in the request body.$TARGET_WORKSPACE_ID: The target workspace ID to receive the publication, specified in the request body.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/data-share/publishes" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
--data-binary @- <<JSON
"name": "sales-share",
"source_database_id": "${SOURCE_DATABASE_ID}",
"table_scope": {
"mode": "selected",
"object_ids": ["${TABLE_ID}"]
},
"target_workspace_ids": ["${TARGET_WORKSPACE_ID}"],
"remark": "共享销售数据"
}
JSON
Request body¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Publication name, cannot be empty, can be up to 200 characters, and cannot contain spaces, tabs, backticks, or single or double quotes. |
|
string |
Yes |
Source database ID, must be a string in the form of a positive integer. |
|
object |
Yes |
The table range to publish. |
|
string |
Yes |
|
|
string[] |
Conditionally required |
When |
|
string[] |
Yes |
At least one unique target workspace ID; it cannot contain the current workspace ID, and each value cannot have leading or trailing spaces. |
|
string |
No |
Remarks. |
[] after a type means an array. For example, string[] is an array of strings.
Successful response¶
Returns 200 on success. data.id is the release ID.
{
"code": "OK",
"msg": "OK",
"data": {
"id": "101",
"name": "sales-share",
"source_database_id": "1001",
"mo_database_name": "sales",
"table_scope": {
"mode": "selected",
"object_ids": ["2001"]
},
"obj_display_name": "sales",
"obj_display_path": "catalog/sales",
"targets": [
{
"workspace_id": "ws-002",
"workspace_name": "分析工作区"
}
],
"permission": "read",
"remark": "共享销售数据",
"created_by": "user-001",
"created_at": "2026-08-18T10:00:00Z",
"updated_at": "2026-08-18T10:00:00Z"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Release ID. |
|
string |
Release name. |
|
string |
Source database ID. |
|
string |
Source database name in MatrixOne. |
|
object |
Published table range. |
|
string |
Table range mode. |
|
string[] |
Specifies the ID of the table; it is an empty array in all table mode. |
|
string |
The name of the source object for display. |
|
string |
Source object path for display. |
|
object[] |
List of target workspaces. |
|
string |
Target workspace ID. |
|
string |
Target workspace name; returned if there is a value. |
|
string |
Publish permission. |
|
string |
Release notes. |
|
string |
Creator ID. |
|
string |
Creation time. |
|
string |
Last updated time. |
Error response¶
{
"code": "ErrDuplicatePublish",
"msg": "发布已存在",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body, source database ID, table range, or target workspace fields are invalid. |
Check |
|
|
The source database or specified table does not exist, or the current workspace does not have permission to access it. |
Reselect the source databases and tables accessible to the current workspace. |
|
|
The current identity does not have permission to create publications. |
Request permission to create a data publication. |
|
|
The publication name or object publication relationship already exists. |
Change the name, or update an existing release. |
|
|
The creation process can be safely retried and the server has confirmed that the publication was not created. |
Try again later with the same request. |
|
|
Data publishing writing is temporarily suspended. |
Try again later with the same request. |
|
|
The server failed to create the publication. |
Try again later. |