Accept data subscription

Accepts a data subscription and specifies the subscription database name in the target workspace.

POST https://moi.matrixorigin.cn/newmoi/data-share/subscriptions/{id}/subscribe

Preparation before calling

First query the data subscription list to confirm the subscription to be accepted. Prepare a personal access token with access to the target workspace, target workspace ID, subscription ID, and local subscription name.

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.

  • $SUBSCRIPTION_ID: The subscription ID to be accepted, taken from the response of query data subscription list.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/data-share/subscriptions/$SUBSCRIPTION_ID/subscribe" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "sub_name": "sales_subscription"
  }'

Path parameters

Parameters

Type

Description

id

integer

A subscription ID greater than 0.

Request body

Field

Type

Required

Description

sub_name

string

Yes

Local subscription name.

Successful response

Returns 200 and the updated subscription record on success. Record the target database ID; it represents the subscription database created in the target workspace.

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": "201",
    "pub_name": "sales-share",
    "source_database_id": "101",
    "mo_database_name": "sales",
    "table_scope": {
      "mode": "selected",
      "object_ids": ["1001"]
    },
    "target_database_id": "301",
    "obj_display_name": "sales",
    "obj_display_path": "catalog/sales",
    "source_workspace_id": "ws-001",
    "source_workspace_name": "数据工作区",
    "publisher": "user-001",
    "published_at": "2026-08-18T10:00:00Z",
    "status": "subscribed",
    "sub_name": "sales_subscription",
    "subscribed_by": "user-002",
    "created_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

Subscription ID.

data.pub_name

string

Source publication name.

data.source_database_id

string

Source database ID.

data.mo_database_name

string

Source database name.

data.table_scope

object

Publish shared table range.

data.table_scope.mode

string

Range mode: all or selected.

data.table_scope.object_ids

string[]

List of table IDs when the range mode is selected.

data.target_database_id

string

ID of the subscription database in the target workspace; returned after successful acceptance.

data.obj_display_name

string

The display name of the source database.

data.obj_display_path

string

The display path of the source database.

data.source_workspace_id

string

Source workspace ID.

data.source_workspace_name

string

Source workspace name; returned if there is a value.

data.publisher

string

Publisher.

data.published_at

string

Release time.

data.status

string

Current subscription status.

data.sub_name

string

The name of the subscription database in the target workspace.

data.subscribed_by

string

The identity to accept the subscription.

data.created_at

string

Time to accept subscription.

[] after a type means an array. For example, string[] is an array of strings.

Error response

{
  "code": "ErrAlreadySubscribed",
  "msg": "数据已订阅",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

Invalid subscription ID or sub_name.

Check the path and request body fields.

403

ErrPermissionDenied

The current identity does not have permission to create subscriptions.

Request permission to create data subscriptions.

404

ErrSubscriptionNotFound

The subscription does not exist or does not belong to the current workspace.

Verify subscription ID and workspace.

409

ErrAlreadySubscribed

The subscription has been accepted.

Query the subscription list to avoid repeated submissions.

409

ErrNameConflict

The target workspace already has a subscription database with the same name.

Replace sub_name and try again.

503

ErrServiceUnavailable

Dependent services are temporarily unavailable.

Try again later.

500

ErrServer

The server failed to accept the subscription.

Try again later.

Follow-up operations

Use data.target_database_id to record the target subscription database; then Query data subscription list to confirm the subscription status and name.

Last updated on