# Cancel execution

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

Stops SQL queries that are still running for the current identity. After the call is successful, use [query execution status](get-execution-status.md) to confirm the status of the query.

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

## 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 to cancel.</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/kill" \
  -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

A successful response indicates that the cancellation request has been completed and the query record is marked as `killed`. Use [query execution status](get-execution-status.md) to read records.


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</code><span class="mo-api-field__type">null</span></dt><dd>This operation does not return data.</dd></div>
</dl>
```

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

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

```json
{
  "code": 200,
  "data": null
}
```

:::
::::

## 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

[Query execution status](get-execution-status.md) again to confirm that execution has stopped.
