# Update volume

Update the volume's name and description.

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

## Preparation before calling

First [query the object](list-database-objects.md) in the database to obtain the target volume ID. 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`: Volume ID to be updated.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/volume/update" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": '"$VOLUME_ID"',
    "name": "<VOLUME_NAME>",
    "description": "<VOLUME_DESCRIPTION>"
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | Volume ID. |
| `name` | string | Yes | New name, must be a valid identifier. |
| `description` | string | No | New description. |

## Successful response

Returns `200` and the ID of the updated volume on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": 789
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.id` | integer | The ID of the updated volume. |

## Error response

```json
{
  "code": "ErrAlreadyExists",
  "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`
  - `id`, `name` are missing, or the new names are invalid.
  - Check volume ID and name.
* - `403`
  - `ErrForbidden`
  - The current identity does not have write permissions for the volume.
  - Use credentials with write access, or contact your administrator for authorization.
* - `409`
  - `ErrAlreadyExists`
  - There is already a volume with the same name under the same database.
  - Use another name.
* - `500`
  - `ErrServer`
  - The service cannot update the volume.
  - 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 volume details](get-volume.md) to confirm the update result.
