# Update dashboard chart

Update the query, display and refresh configuration of the specified chart.

```text
PATCH https://moi.matrixorigin.cn/newmoi/data-dashboards/{dashboard_id}/charts/{chart_id}
```

## Preparation before calling

Prepare a personal access token and target workspace ID that has 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.

- `$DASHBOARD_ID`: `dashboard_id` to use, specifying the target resource via the request path.
- `$CHART_ID`: `chart_id` to use, specifying the target resource through the request path.

## Request body

Replace caller-specific values in the example with actual values.

::::{div} mo-api-split
:::{div} mo-api-split-main
```{raw} html
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>name</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Chart name.</dd></div>
<div class="mo-api-field"><dt><code>chart_type</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Chart type.</dd></div>
<div class="mo-api-field"><dt><code>sql_text</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Chart SQL.</dd></div>
<div class="mo-api-field"><dt><code>chart_config</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Chart configuration.</dd></div>
<div class="mo-api-field"><dt><code>layout_config</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Layout configuration.</dd></div>
<div class="mo-api-field"><dt><code>refresh_interval</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Refresh cycle.</dd></div>
<div class="mo-api-field"><dt><code>alert_enabled</code><span class="mo-api-field__type">boolean</span><span class="mo-api-field__required">Required</span></dt><dd>Whether to enable alarms.</dd></div>
<div class="mo-api-field"><dt><code>alert_config</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Alarm configuration.</dd></div>
</dl>
```
:::
:::{div} mo-api-split-aside
```{raw} html
<p class="mo-api-example-label">Request example</p>
```
```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/data-dashboards/$DASHBOARD_ID/charts/$CHART_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "每日订单数",
    "chart_type": "line",
    "sql_text": "SELECT 1",
    "chart_config": "{}",
    "layout_config": "{}",
    "refresh_interval": "manual",
    "alert_enabled": false,
    "alert_config": "{}"
  }'
```
:::
::::
## Successful response

When the update is successful, the updated chart and scheduling status are returned.

```json
{
  "code": 0,
  "data": {
    "ID": "0198ce79-2320-76aa-9d34-7f8e9d0c1b2a",
    "DashboardID": "0198ce73-3d20-7c12-9a11-1a2b3c4d5e6f",
    "Name": "每日订单数",
    "ChartType": "line",
    "SQLText": "SELECT 1",
    "DatabaseName": "analytics",
    "ChartConfig": "{}",
    "LayoutConfig": "{}",
    "RefreshInterval": "manual",
    "SchedulerTaskID": "",
    "ScheduleVersion": 2,
    "ScheduleStatus": "ready",
    "ScheduleError": "",
    "ScheduleOperationID": "operation-002",
    "AlertEnabled": false,
    "AlertConfig": "{}",
    "SnapshotEpochAt": "2026-08-21T07:10:00Z",
    "CreatedAt": "2026-08-21T07:00:00Z",
    "UpdatedAt": "2026-08-21T07:10:00Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.ID` | string | Chart ID. |
| `data.DashboardID` | string | The ID of the data dashboard. |
| `data.Name` | string | Chart name. |
| `data.ChartType` | string | Chart type. |
| `data.SQLText` | string | Chart SQL. |
| `data.DatabaseName` | string | Database name used for chart query. |
| `data.ChartConfig` | string | Chart configuration. |
| `data.LayoutConfig` | string | Layout configuration. |
| `data.RefreshInterval` | string | Refresh cycle. |
| `data.SchedulerTaskID` | string | Scheduling task ID; empty when no scheduling task is created. |
| `data.ScheduleVersion` | integer | Scheduling configuration version. |
| `data.ScheduleStatus` | string | Scheduling status. |
| `data.ScheduleError` | string | Scheduling error; empty if there is no error. |
| `data.ScheduleOperationID` | string | ID of this scheduling operation. |
| `data.AlertEnabled` | boolean | Whether to enable alarms. |
| `data.AlertConfig` | string | Alarm configuration. |
| `data.SnapshotEpochAt` | string | Result snapshot starting time. |
| `data.CreatedAt` | string | Creation time. |
| `data.UpdatedAt` | string | Update time. |

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main
```{raw} html
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">integer or string</span></dt><dd>Error code or status.</dd></div>
<div class="mo-api-field"><dt><code>message</code><span class="mo-api-field__type">string</span></dt><dd>Error message.</dd></div>
</dl>
```
:::
:::{div} mo-api-split-aside
```{raw} html
<p class="mo-api-example-label">Error response example</p>
```
```json
{
  "code": 2,
  "message": "invalid argument",
  "details": {
    "domain": "moi-core.catalog.data_dashboard",
    "reason": "DATA_DASHBOARD_INVALID_REQUEST"
  }
}
```
:::
::::
