# Update Catalog

Update the Catalog's name and description.

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

## Preparation before calling

First [query the catalog list](list-catalogs.md) to obtain the target catalog ID. Prepare the personal access token, target workspace ID, and Catalog 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.
- `$CATALOG_ID`: Catalog ID to update.

## Request example

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

## Request body

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

## Successful response

Returns `200` on success, `data` is `null`. Then read the details to confirm the change.

```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 update is successful. |

## Error response

```json
{
  "code": "ErrReadonlySystemCatalog",
  "msg": "系统 Catalog 为只读",
  "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 invalid, the ID is invalid, or the name is not a valid identifier.
  - Check `id` and `name`.
* - `403`
  - `ErrForbidden`
  - The current identity does not have update permissions.
  - Requesting permission to `catalog.update`.
* - `409`
  - `ErrAlreadyExists`
  - The new name is already used by other catalogs.
  - Change the name and try again.
* - `409`
  - `ErrReadonlySystemCatalog`
  - Targets a read-only system catalog.
  - Do not modify this Catalog.
* - `500`
  - `ErrServer`
  - The server failed to update the Catalog.
  - Try again later.
```

## Follow-up operations

[Query Catalog details](get-catalog.md) to confirm the change.
