# Upload to a personal private Catalog volume

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Upload a file and automatically associate it with the current user's private volume, returning the file ID and volume location.

```text
POST https://api.moi.matrixorigin.cn/v5/workspaces/{id}/catalog-files/uploads
```

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`. For private deployments, use the corresponding product API URL.

Prepare a personal access token for the target Workspace. WORKSPACE_ID must match the path Workspace; FILE_ID comes from an actual file result. BASE_URL includes the same environment's product prefix. Example files/IDs are placeholders.

## Request parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --fail-with-body -sS -X POST "$BASE_URL/workspaces/$WORKSPACE_ID/catalog-files/uploads" \
  -H "X-API-Key: $MOI_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -F "file=@$UPLOAD_FILE;type=text/plain"
```

:::::
:::::{tab-item} Parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | file | Yes | Multipart file. |

Success returns HTTP201 with a volume association already created; do not call file-association creation again. File records, storage, and publication associations can fail at separate stages.

:::::
::::::
:::::::

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "file_id": "file-example",
    "original_name": "sample.txt",
    "size": 7,
    "md5": "5177a58dc65c8a14dc90c69db3bf3dd2",
    "catalog_file": {
      "workspace_id": "workspace-example",
      "volume_id": 30,
      "file_id": "file-example",
      "path": "sample.txt",
      "name": "sample.txt",
      "size": 7,
      "md5": "5177a58dc65c8a14dc90c69db3bf3dd2"
    }
  }
}
```

:::::
:::::{tab-item} Fields

Success uses string code=OK and msg=OK. data includes file_id, original_name, size, md5, and catalog_file. catalog_file contains workspace_id, volume_id, file_id, path, name, size, and md5. See [Upload location](objects.md#private-location).

:::::
::::::
:::::::

## Error responses

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "ErrParamInvalid",
  "msg": "示例本地化错误"
}
```

:::::
:::::{tab-item} Fields

Errors use string code/msg. Handle parameter, permission, storage, and dependency failures according to the actual response.

:::::
::::::
:::::::
