# Update database

Update database description. This interface does not support renaming.

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

## Preparation before calling

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

Do not pass in `name`; this field will cause the request to fail.

## Request example

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

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | Database ID. |
| `description` | string | No | Updated description. |

## Successful response

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

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

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.id` | integer or null | Updated database ID; `null` if not provided by the server. |

## Error response

```json
{
  "code": "ErrDatabaseRenameUnsupported",
  "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 or database ID is invalid.
  - Use positive integer IDs.
* - `400`
  - `ErrDatabaseRenameUnsupported`
  - The request body contains `name`.
  - Removed `name` and only updated the description.
* - `403`
  - `ErrForbidden`
  - The current identity does not have update permissions.
  - Requesting permission to `database.update`.
* - `409`
  - `ErrReadonlySystemDatabase`、`ErrReadonlyReservedDatabase`
  - Target a read-only system or a reserved database.
  - Do not update this database.
* - `500`
  - `ErrServer`
  - The server failed to update the database.
  - Try again later.
```

## Follow-up operations

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