# Delete task

Delete an export task.

```text
POST https://moi.matrixorigin.cn/newmoi/export/task/delete
```

## Preparation before calling

First [Query task details](get-export-task.md) to confirm the export task to be deleted. Prepare a personal access token with access to the target workspace, the target workspace ID, and the export task ID.

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.
- `$TASK_ID`: ID of the export task to be deleted, fill in the `id` field of the request body.

Deletion of the currently created page is disabled while the task is running. Deleting a task does not roll back data that has been exported to the target system.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/export/task/delete" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "'$TASK_ID'"
  }'
```

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The ID of the export task to be deleted. |

## Successful response

Returns `200` on success. `data` is `null`, indicating that the deletion request has been completed; the data that has been exported to the target system will not be rolled back.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` means the interface call is successful. |
| `msg` | string | Success message with value `OK`. |
| `data` | null | Deleting the interface does not return the task object. |

## Error response

Business failure may be returned with HTTP `200` and `code` other than `OK`.

```json
{
  "code": "ErrServer",
  "msg": "Internal server error",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 24 36 28

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - —
  - The request body cannot be parsed; this compatibility path returns the `error` field instead of the standard envelope.
  - Submit a JSON object containing a non-empty `id`.
* - `200`
  - `ErrServer`
  - The task does not exist, or the deletion process failed.
  - First query the task details to confirm the ID; when the task is running, please wait for the page to allow deletion.
* - `403`
  - `ErrForbidden`
  - The current identity does not have the permission to delete this task.
  - Request permission to delete the export task.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - Authorization service is temporarily unavailable.
  - Try again later.
```

## Follow-up operations

[Query task list](list-export-tasks.md) to confirm that the task no longer appears.
