# Preview dashboard chart SQL

Execute a chart SQL preview, returning query results without saving the chart.

```text
POST $CLOUDSIGMA_API_BASE/data-dashboards/{dashboard_id}/preview
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

Set the operation-specific values used in the request:

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

## Request body

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

::::{div} mo-api-split
:::{div} mo-api-split-main
<dl class="mo-api-fields">
<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>The SQL to preview.</dd></div>
</dl>
:::
:::{div} mo-api-split-aside
<p class="mo-api-example-label">Request example</p>
```bash
curl -X POST "$CLOUDSIGMA_API_BASE/data-dashboards/$DASHBOARD_ID/preview" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "sql_text": "SELECT 1 AS value"
  }'
```
:::
::::
## Successful response

When the request is successful, the data of this operation is returned. Just because the write or run request has been accepted does not mean that the subsequent processing has been completed; please confirm the result based on the return status or subsequent query.

```json
{
  "code": 200,
  "data": {"query_id": "query-001", "statement_id": "stmt-001", "status": "completed", "total": 1}
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.query_id` | string | Query ID. |
| `data.statement_id` | string | Statement ID. |
| `data.status` | string | Query status. |
| `data.columns` | array | Result column. |
| `data.result` | array | Result data. |

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main
<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
<p class="mo-api-example-label">Error response example</p>
```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```
:::
::::
