# Query export files

Lists the files in the export task and the processing status of each file.

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

## Preparation before calling

First [Query task details](get-export-task.md) to confirm the export task you want to view. 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`: To view the export task ID of the file, fill in the `task_id` field in the request body.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/export/task/files" \
  -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 export task ID of the file to be queried. |
| `limit` | integer | No | This page returns the number of items; if not passed, it will be `20`. |
| `offset` | integer | no | Paging offset. |
| `statuses` | integer[] | No | Filter by file status. |
| `order_by` | string | No | Order field: `created_at`, `started_at`, `ended_at` or `status`. |
| `order_direction` | string | No | Sorting direction: `asc` is ascending order; not passed or other values ​​are descending order. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` on success. `data.files` returns each export record and its status; `details` can be used to locate the cause of failure.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "files": [{
      "id": "export-file-001",
      "file_name": "summary.csv",
      "file_type": "csv",
      "status": 3,
      "full_path": ["volume-001", "reports", "summary.csv"],
      "details": "<failure description>",
      "create_time": "2026-08-18T10:00:00Z",
      "start_time": "2026-08-18T10:01:00Z",
      "end_time": "2026-08-18T10:02:00Z"
    }],
    "total": 1,
    "total_success": 0,
    "total_failure": 1,
    "total_files": 1
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.files` | object[] | Export file record list. |
| `data.files[].id` | string | Export record ID; used to specify the retry file. |
| `data.files[].file_name` | string | File name. |
| `data.files[].file_type` | string | The extension identified by the file name. |
| `data.files[].status` | integer | `0` pending, `1` exporting, `2` completed, `3` failed. |
| `data.files[].full_path` | string[] | The full path of the source file. |
| `data.files[].details` | string | Processing details or failure instructions. |
| `data.files[].create_time` | string or null | Creation time. |
| `data.files[].start_time` | string or null | The time to start exporting; `null` if it has not yet started. |
| `data.files[].end_time` | string or null | End time; `null` if not yet ended. |
| `data.total` | integer | The number of matching records on this page. |
| `data.total_success` | integer | Total number of files exported successfully by the task. |
| `data.total_failure` | integer | Total number of files whose export failed in the task. |
| `data.total_files` | integer | The total number of files in the task. |

## Error response

```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 compatible path returns an `error` field.
  - Pass in a valid `task_id` and check for pagination and status filtering types.
* - `200`
  - `ErrServer`
  - The task does not exist or the file record query failed.
  - Check the task ID and try again.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to read the task.
  - Request that read permission be granted to the export task.
```

## Follow-up operations

Use the failed file ID for [Rerun task](rerun-export-task.md); after retrying, [Query task status](get-export-task-state.md) to confirm whether the number of failures is cleared.
