# Delete Catalog

Delete the specified Catalog. Deletion is irreversible; process subordinate databases, volumes, and tables first.

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

## Preparation before calling

First [Query Catalog details](get-catalog.md) to confirm the target, then process subordinate objects. 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 delete.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/delete" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": '"$CATALOG_ID"'
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | Catalog ID to delete. |

## Successful response

Returns `200` on success, `data` is `null`.

```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 deleted successfully. |

## Error response

```json
{
  "code": "ErrCatalogHasChildren",
  "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 or Catalog ID is invalid.
  - Positive integer IDs returned using a list.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to delete.
  - Requesting permission to `catalog.delete`.
* - `409`
  - `ErrReadonlySystemCatalog`
  - The target is a read-only system catalog.
  - Do not delete this catalog.
* - `409`
  - `ErrCatalogHasChildren`
  - Catalog still contains subordinate objects.
  - Delete or migrate subordinate objects first.
* - `409`
  - `ErrKnowledgeBaseCatalogInUse`
  - Catalog is being used by the knowledge base.
  - Process knowledge base dependencies before deleting them.
* - `500`
  - `ErrServer`
  - The server failed to delete the Catalog.
  - Try again later.
```

## Follow-up operations

[Query file products](list-file-artifacts.md), confirm that the target no longer appears.
