# Delete table

Delete the specified table and its data. Deletion cannot be undone.

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

## Preparation before calling

First [Query table information](get-table.md) to confirm the target table. Prepare the personal access token, target workspace ID, and table 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.
- `$TABLE_ID`: Table ID to delete.

This operation deletes the table and its data irreversibly.

## Request example

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

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | Table ID. |

## Successful response

Returns `200` on success, `data` is `null`. This operation deletes the table and its data irreversibly.

```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": "ErrReadonlySystemDatabase",
  "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` is missing or the requested format is invalid.
  - Pass in a valid table ID.
* - `403`
  - `ErrForbidden`
  - The current identity does not have the permission to delete the table.
  - Use credentials with write access, or contact your administrator for authorization.
* - `409`
  - `ErrReadonlySystemDatabase`
  - The table is located in a read-only system database.
  - Select a table in a writable database.
* - `500`
  - `ErrServer`
  - The service cannot delete the table.
  - Record the request time and error message and try again; if it continues to fail, contact support.
```

## Follow-up operations

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