# Query exportable files

Lists processed files in a volume that can be used to create export tasks.

```text
POST https://moi.matrixorigin.cn/newmoi/export/volumes/$VOLUME_ID/files
```

## Preparation before calling

First confirm that there are exportable processing results in the target volume. Prepare the personal access token, target workspace ID, and volume 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`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$VOLUME_ID`: The volume ID to be queried, fill in the volume ID position in the request address.

This interface only returns files in the volume with vectorized processing results. The MatrixOne file tree of the currently created page can also display the parsed processing results; when you need to select files by page, please refer to the page file tree.

## Request example

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

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `volume_id` | string | Yes | The volume ID to query. |

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `filters.types` | integer[] | No | Filter by file type. |
| `filters.exclude_status` | integer[] | No | Processing status of exclusions. |
| `sorter.sort_by` | string | No | Sort by file creation time when non-null value is passed in. |
| `sorter.is_desc` | boolean | No | `true` means descending order by creation time; do not pass or `false` means ascending order. |
| `offset` | integer | no | Paging offset. |
| `limit` | integer | No | This page returns the number of items; if not passed, it will be `30`. |

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

## Successful response

Returns `200` on success. `data.items` are exportable processed files; use `id` as the value of `files[].file_id` when creating the export task.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "total": 1,
    "items": [{
      "id": "file-001",
      "file_name": "summary.csv",
      "file_status": 2,
      "file_type": 1
    }]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.total` | integer | The total number of files that match the current filter conditions. |
| `data.items` | object[] | List of exportable files. |
| `data.items[].id` | string | File ID. |
| `data.items[].file_name` | string | File name. |
| `data.items[].file_status` | integer | The current processing status of the file. |
| `data.items[].file_type` | integer | File type identifier. |

## 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`
  - —
  - `volume_id` is invalid or the request body cannot be parsed; this compatible path returns the `error` field.
  - Use positive integer volume IDs and check filter and sort field types.
* - `200`
  - `ErrServer`
  - The volume does not exist, or the dependent processing and file listing services are unavailable.
  - Retry after checking the volume and dependent services; if there is no matching file, a successful response returns an empty list.
* - `403`
  - `ErrForbidden`
  - The current identity does not have read permission to the volume.
  - Requesting to grant read permission to the volume.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - Authorization service is temporarily unavailable.
  - Try again later.
```

## Follow-up operations

After selecting the exportable file, go to [Create Task](create-export-task.md) to submit the export.
