# Delete database

Delete the specified database. Before deleting, make sure the database is not used by publishing or subscription.

```text
POST $CLOUDSIGMA_API_BASE/catalog/database/delete
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

First [query the database list](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/catalog/list-databases.html.md) to obtain the database ID.

Set the operation-specific values used in the request:

- `$DATABASE_ID`: Database ID to delete.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/database/delete" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "id": '"$DATABASE_ID"'
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | The ID of the database 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 | `null` when deletion is complete. |

## Error response

```json
{
  "code": "ErrDatabasePublished",
  "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 the database ID returned by the list.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to delete.
  - Use authorized credentials.
* - `409`
  - `ErrDatabasePublished` or `ErrReadonlySubscriptionDatabase`
  - The database is published, is a subscription library, or is subject to read-only restrictions.
  - Handle the publish or subscribe relationship first.
* - `500`
  - `ErrServer`
  - The server failed to delete the database.
  - Log the error message and try again.
```
