# Query task details

Read the definition and current status of an import task. After creating, pausing, resuming or retrying, use this interface to confirm whether the task has entered the expected state.

```text
GET https://api.moi.matrixorigin.cn/v5/task/get?task_id=$TASK_ID
```

## Before you call

Prepare the personal access token, target workspace ID, and task ID that have access to the target workspace.

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 to be queried, passed through the `X-Workspace-ID` Header.
- `$TASK_ID`: Create `data.task_id` in task response.

## Request example

```bash
curl "https://api.moi.matrixorigin.cn/v5/task/get?task_id=$TASK_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Query parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `task_id` | string | Yes | The import task ID to be queried. |

## Successful response

Returns `200` on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "task": {
      "id": "task_01",
      "name": "import_orders",
      "config_type": 1,
      "source_connector_id": "conn_01",
      "connector_name": "orders_mysql",
      "volume_id": "vol_01",
      "status": 2,
      "total_rows": 100,
      "imported_rows": 100,
      "success_file_count": 1,
      "failed_file_count": 0,
      "latest_rows": {
        "read_rows": 100,
        "succeeded_rows": 100,
        "failed_rows": 0,
        "complete": true
      },
      "error_code": "",
      "error_summary": ""
    }
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.task` | object | Task definition and current processing status. See [Import task object fields](import-task-object-fields.md) for each field of this object. |

## Error response

Some deployments can return HTTP `200` with the following generic error for a missing task. HTTP `200` alone does not mean that the task was read. Confirm that `code` is `OK` and `data.task` is present before reading its status.

`ErrServer` can also indicate a service failure; neither the code nor the message confirms that the task is missing. Verify the workspace and task ID, then check the [import task list](list-import-tasks.md#successful-response) for a readable task. If the detail request returns `404`, verify the target before continuing. If the confirmed task still fails, record the HTTP status, response code, and request time and contact support.

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

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `200`
  - `ErrServer`
  - The task does not exist, cannot be read, or the service failed to query the task.
  - Check both HTTP status and `code`, and confirm `task_id` and authorization.
```

## Follow-up operations

Use the task ID [Query task files](list-import-task-files.md) to view file-level results, or [Query running records](list-import-task-runs.md) to view previous runs. When there are many failed files, give the `id` of the failed files to [Retry failed files](retry-failed-import-files.md).
