# Download skill file

Download a static file imported with the skill pack. The success response is the binary content of the file and does not use a JSON success envelope.

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

## Before you call

First [query the skill file](list-skill-files.md) to obtain `file_path`. 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 -OJ "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/skills/$SKILL_ID/files/content?path=references%2Fguide.md" \
  -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. |

## Query parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `path` | string | Yes | The relative path of the file in the skill package. Cannot be a directory, an absolute path, a path containing `..`, or a backslash. |

## Successful response

Returns `200` and the file contents on success. The response is not a JSON envelope. The response sets the following headers:

| Response header | Description |
| --- | --- |
| `Content-Type` | The actual media type of the file. |
| `Content-Disposition` | `attachment` and provide a UTF-8 encoded file name. |
| `X-Content-Type-Options` | Fixed to `nosniff`. |

## Error response

Returns JSON on error:

```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`）
  - `path` Missing or unsafe skill pack relative path.
  - Use the `file_path` returned as-is by Query Skill File.
* - `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 or specified file does not exist.
  - Check skill ID and `path`.
* - `503`
  - `15`（`UNAVAILABLE`）
  - Skill pack storage is unavailable.
  - Try again later.
```

## Follow-up operations

If you need to continue management after the download is completed, return to [Query skill details](get-skill.md).
