# Query skill files

Lists static file metadata imported with skill packs. This interface only queries the skills in the current workspace and will not fall back to system skills.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/skills/{skill_id}/files
```

## Before you call

First [query the skill list](list-skills.md) or [import the skill package](import-skill-package.md)] to obtain the skill ID. Prepare the personal access token, target workspace ID, and skill 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.
- `$SKILL_ID`: Skill ID.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/skills/$SKILL_ID/files" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | The current workspace ID. |
| `skill_id` | string | Yes | Skill ID. |

## Successful response

Returns `200` on success.

```json
{
  "code": 0,
  "data": {
    "items": [
      {
        "file_path": "references/guide.md",
        "file_kind": "reference",
        "media_type": "text/markdown",
        "sha256": "abc123",
        "size_bytes": 1024
      }
    ],
    "total": 1
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.items` | array | Skill package static file metadata. |
| `data.items[].file_path` | string | The relative path of the file in the skill package. |
| `data.items[].file_kind` | string | File category. |
| `data.items[].media_type` | string | File media type. |
| `data.items[].sha256` | string | SHA-256 digest of the file contents. |
| `data.items[].size_bytes` | integer | File size (bytes). |
| `data.total` | integer | Number of files. |

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


## Error response

```json
{
  "code": 3,
  "message": "<错误信息>",
  "details": {
    "reason": "SKILL_PACKAGE_FILE_NOT_FOUND"
  }
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter is invalid.
  - Check workspace and skill IDs.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `403`
  - `5`（`PERMISSION_DENIED`）
  - The current identity does not have permission to read the skill file.
  - Check workspace authorization.
* - `404`
  - `3`（`NOT_FOUND`）
  - The skill does not exist, or there is no readable file for the skill.
  - Check the skill ID; verify that the skill is imported from a skill pack and contains static files.
* - `503`
  - `15`（`UNAVAILABLE`）
  - Skill pack storage is unavailable.
  - Try again later.
```

## Follow-up operations

After saving the target file identification, you can [Download skill file](download-skill-file.md); when you need overall skill information, [Query skill details](get-skill.md).
