---
orphan: true
---

# Update file

This interface preserves the request shape for file updates, but the current implementation does not persist changes to `name`. Please do not interpret a successful response as indicating that the file name has been updated.

```text
POST https://moi.matrixorigin.cn/newmoi/catalog/file/update
```

## Preparation before calling

First [query the file list](list-files.md) to obtain the target file ID. Prepare the personal access token, target workspace ID, and file 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.
- `$FILE_ID`: File ID used to locate files and perform permission verification.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/update" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "file_id": "'"$FILE_ID"'",
    "name": "<FILE_NAME>"
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `file_id` | string | Yes | The file ID used to locate the file and perform permission verification. |
| `name` | string | No | The name of the file to be updated; the current implementation does not save this value. |

## Successful response

Returns `200` on success, `data` is `null`. The current implementation returns successfully but does not change the file name or other file attributes.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | Fixed to `null` when the request returns successfully; it does not mean that the file attributes have been changed. |

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - The request body is not valid JSON.
  - Check JSON format.
* - `403`
  - `ErrForbidden`
  - The current identity does not have write permissions on the root volume to which it belongs.
  - Use credentials with write access, or contact your administrator for authorization.
* - `500`
  - `ErrServer`
  - The server failed to process the request.
  - Record the request time and error message and try again; if it continues to fail, contact support.
```

## Follow-up operations

Use the same resource identifier [Query file details](get-file.md) to confirm the update result.
