# View execution status

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Read the status and result ID of the SQL executed by the current identity (`statement_id`). Results can only be read or downloaded using this result ID if the status is `success`.

```text
POST https://moi.matrixorigin.cn/newmoi/query/describe
```

## Preparation before calling

Prepare the personal access token, workspace ID, and query ID from the [Execute SQL](execute-sql.md) response.


## Request body

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>query_id</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>The query ID returned by [Execute SQL](execute-sql.md).</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Request example</p>
```

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/query/describe" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"query_id\":\"$QUERY_ID\"}"
```

:::
::::

## Successful response

`statement_id` is used to read or download results and cannot be replaced by `query_id`. When the status is `success`, the Statement ID can be used to obtain the result.


The response fields are as follows.

::::{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</span></dt><dd>200 on success.</dd></div>
  <div class="mo-api-field"><dt><code>data.query_id</code><span class="mo-api-field__type">string</span></dt><dd>Query ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.created_at</code><span class="mo-api-field__type">string</span></dt><dd>The creation time of the execution record.</dd></div>
  <div class="mo-api-field"><dt><code>data.statement_id</code><span class="mo-api-field__type">string</span></dt><dd>Result ID; used when reading or downloading the results of this SQL.</dd></div>
  <div class="mo-api-field"><dt><code>data.db_name</code><span class="mo-api-field__type">string</span></dt><dd>The database specified during execution.</dd></div>
  <div class="mo-api-field"><dt><code>data.status</code><span class="mo-api-field__type">string</span></dt><dd>Execution status.</dd></div>
  <div class="mo-api-field"><dt><code>data.err_msg</code><span class="mo-api-field__type">string</span></dt><dd>Execution error message; only returned if there is an error message.</dd></div>
  <div class="mo-api-field"><dt><code>data.rows_affected</code><span class="mo-api-field__type">integer</span></dt><dd>Number of affected rows.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Successful response example</p>
```

```json
{
  "code": 200,
  "data": {
    "query_id": "query_01",
    "created_at": "2026-08-18T10:00:00Z",
    "statement_id": "statement_01",
    "db_name": "sales",
    "status": "success",
    "rows_affected": 1
  }
}
```

:::
::::

## 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">string</span></dt><dd>Error code.</dd></div>
  <div class="mo-api-field"><dt><code>msg</code><span class="mo-api-field__type">string</span></dt><dd>Readable error message.</dd></div>
  <div class="mo-api-field"><dt><code>data</code><span class="mo-api-field__type">null</span></dt><dd>`null` in an error response.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Error response example</p>
```

```json
{"code": 404, "message": "SQL 查询不存在"}
```

:::
::::

## Follow-up operations

When the status indicates success, use the returned result to identify [query execution result](get-execution-result.md) or [download execution result](download-execution-result.md). [Cancel execution](cancel-execution.md) while still executing and needs to be aborted.
