# Delete task

Delete an import task record.

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

## Before you call

Prepare the personal access token, target workspace ID, and task ID that have access to the target workspace. Deleting a task will not roll back data that has been written to the target; confirm that the task is no longer needed before deleting it.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: The workspace ID of the task to be deleted, passed through the `X-Workspace-ID` Header.
- `$TASK_ID`: Task ID to be deleted.

## Request example

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

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `task_id` | string | Yes | The ID of the import task to delete. |

## Successful response

Returns `200` on success and `data` is `null`.

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

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | This interface does not return deleted tasks. |

## Error response

```json
{
  "code": "ErrForbidden",
  "msg": "permission denied",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 25 30 33

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - The request body is invalid.
  - Fix JSON and `task_id` and try again.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to delete the task.
  - Check workspace and object authorization.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - The service is temporarily unable to complete the authorization check.
  - Try again later.
* - `200`
  - `ErrServer`
  - The service failed to delete the task.
  - Check both HTTP status and `code`.
```

## Follow-up operations

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