# Update data release

Update the table range, target workspace, or notes for data publishing.

```text
PUT https://moi.matrixorigin.cn/newmoi/data-share/publishes/{id}
```

## Preparation before calling

First [query the data release list](list-publications.md) and confirm the release to be updated. Prepare the personal access token, target workspace ID, and publication ID that have access to the target workspace.

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.
- `$PUBLICATION_ID`: The release ID to be updated, taken from the response of [query data release list](list-publications.md).
- `$TABLE_ID`: The table ID to be published in the `selected` range, specified in the request body.
- `$TARGET_WORKSPACE_ID`: The updated target workspace ID, specified in the request body.

## Request example

```bash
curl -X PUT "https://moi.matrixorigin.cn/newmoi/data-share/publishes/$PUBLICATION_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<JSON
    "table_scope": {
      "mode": "selected",
      "object_ids": ["${TABLE_ID}"]
    },
    "target_workspace_ids": ["${TARGET_WORKSPACE_ID}"],
    "remark": "更新后的备注"
  }
JSON
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | A release ID greater than `0`. |

## Request body

Submit only the fields you want to modify.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `table_scope` | object | No | The updated table range. |
| `table_scope.mode` | string | When submitting `table_scope`, | `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[] | No | The updated target workspace ID; at least one when submitting, no duplicates, cannot include the current workspace ID, and each value cannot have leading or trailing blanks. |
| `remark` | string | No | Updated remarks. |

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

Submit at least one of the fields `table_scope`, `target_workspace_ids`, or `remark`.

## Successful response

When successful, `200` is returned, and `data` is the updated publishing object.

```json
{
  "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"
      }
    ],
    "permission": "read",
    "remark": "更新后的备注",
    "created_by": "user-001",
    "created_at": "2026-08-18T10:00:00Z",
    "updated_at": "2026-08-18T11: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

```json
{
  "code": "ErrConcurrentUpdate",
  "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 publication ID, request body, table, or target workspace is invalid.
  - Check path parameters and request fields.
* - `403`
  - `ErrPermissionDenied`
  - The current identity does not have update permissions.
  - Request permission to publish updates to the data.
* - `404`
  - `ErrPublishNotFound`
  - The publication does not exist or is not visible in the current workspace.
  - Check release ID and workspace.
* - `409`
  - `ErrConcurrentUpdate`
  - The publication was modified by another request after being read.
  - Submit after re-reading the latest object.
* - `503`
  - `ErrDataShareWritesPaused`
  - Data publishing writing is temporarily suspended.
  - Try again later.
* - `500`
  - `ErrServer`
  - The server failed to update and publish.
  - Try again later.
```

## Follow-up operations

After updating, [Query data release list](list-publications.md) confirms the publication definition.
