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 the X-API-Key Header.

  • $WORKSPACE_ID: The ID of the workspace where the data publication is to be created, passed through the X-Workspace-ID Header.

  • $SOURCE_DATABASE_ID: The source database ID to publish, specified in the request body.

  • $TABLE_ID: The table ID to be published in the selected range, 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

name

string

Yes

Publication name, cannot be empty, can be up to 200 characters, and cannot contain spaces, tabs, backticks, or single or double quotes.

source_database_id

string

Yes

Source database ID, must be a string in the form of a positive integer.

table_scope

object

Yes

The table range to publish.

table_scope.mode

string

Yes

all means publishing all current tables in the source database; selected means publishing only the tables specified in object_ids.

table_scope.object_ids

string[]

Conditionally required

When mode is selected, 1 to 1000 unique positive integer form table IDs must be provided; when mode is all, an empty array must be omitted or passed.

target_workspace_ids

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.

remark

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

code

string

OK on success.

msg

string

OK on success.

data.id

string

Release ID.

data.name

string

Release name.

data.source_database_id

string

Source database ID.

data.mo_database_name

string

Source database name in MatrixOne.

data.table_scope

object

Published table range.

data.table_scope.mode

string

Table range mode.

data.table_scope.object_ids

string[]

Specifies the ID of the table; it is an empty array in all table mode.

data.obj_display_name

string

The name of the source object for display.

data.obj_display_path

string

Source object path for display.

data.targets

object[]

List of target workspaces.

data.targets[].workspace_id

string

Target workspace ID.

data.targets[].workspace_name

string

Target workspace name; returned if there is a value.

data.permission

string

Publish permission.

data.remark

string

Release notes.

data.created_by

string

Creator ID.

data.created_at

string

Creation time.

data.updated_at

string

Last updated time.

Error response

{
  "code": "ErrDuplicatePublish",
  "msg": "发布已存在",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

The request body, source database ID, table range, or target workspace fields are invalid.

Check source_database_id, table_scope and target workspace ID.

404

ErrDataShareSourceNotFound

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.

403

ErrPermissionDenied

The current identity does not have permission to create publications.

Request permission to create a data publication.

409

ErrDuplicateNameErrDuplicatePublish

The publication name or object publication relationship already exists.

Change the name, or update an existing release.

503

ErrPublicationCreateRetryable

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.

503

ErrDataShareWritesPaused

Data publishing writing is temporarily suspended.

Try again later with the same request.

500

ErrServer

The server failed to create the publication.

Try again later.

Follow-up operations

Query data release list.

Last updated on