Create dashboard chart¶
Create a chart in the specified data dashboard.
POST https://moi.matrixorigin.cn/newmoi/data-dashboards/{dashboard_id}/charts
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 theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$DASHBOARD_ID:dashboard_idto use, specifying the target resource via the request path.
Request body¶
Replace caller-specific values in the example with actual values.
namestringRequired- Chart name.
chart_typestringRequired- Chart type.
sql_textstringRequired- Chart SQL.
chart_configstringRequired- Chart configuration.
layout_configstringRequired- Layout configuration.
refresh_intervalstringRequired- Refresh cycle.
alert_enabledbooleanRequired- Whether to enable alarms.
alert_configstringRequired- Alarm configuration.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/data-dashboards/$DASHBOARD_ID/charts" \
-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 creation is successful, the HTTP status code is 201, and the code in the response body is 0.
{
"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": 1,
"ScheduleStatus": "ready",
"ScheduleError": "",
"ScheduleOperationID": "operation-001",
"AlertEnabled": false,
"AlertConfig": "{}",
"SnapshotEpochAt": "2026-08-21T07:00:00Z",
"CreatedAt": "2026-08-21T07:00:00Z",
"UpdatedAt": "2026-08-21T07:00:00Z"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
Chart ID. |
|
string |
The ID of the data dashboard. |
|
string |
Chart name. |
|
string |
Chart type. |
|
string |
Chart SQL. |
|
string |
Database name used for chart query. |
|
string |
Chart configuration. |
|
string |
Layout configuration. |
|
string |
Refresh cycle. |
|
string |
Scheduling task ID; empty when no scheduling task is created. |
|
integer |
Scheduling configuration version. |
|
string |
Scheduling status. |
|
string |
Scheduling error; empty if there is no error. |
|
string |
ID of this scheduling operation. |
|
boolean |
Whether to enable alarms. |
|
string |
Alarm configuration. |
|
string |
Result snapshot starting time. |
|
string |
Creation time. |
|
string |
Update time. |
Error response¶
codeinteger or string- Error code or status.
messagestring- Error message.
Error response example
{
"code": 2,
"message": "invalid argument",
"details": {
"domain": "moi-core.catalog.data_dashboard",
"reason": "DATA_DASHBOARD_INVALID_REQUEST"
}
}