# Delete data release

Delete a data publication. Deletion will affect access to related subscriptions, and you should first confirm that the publication is no longer required by the target workspace.

```text
DELETE https://moi.matrixorigin.cn/newmoi/data-share/publishes/{id}
```

## Preparation before calling

First [query the data release list](list-publications.md) and confirm the release to be deleted. Prepare the personal access token, target workspace ID, and publication 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.
- `$PUBLICATION_ID`: The publication ID to be deleted, taken from the response of [query data publication list](list-publications.md).

## Request example

```bash
curl -X DELETE "https://moi.matrixorigin.cn/newmoi/data-share/publishes/$PUBLICATION_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | Yes | A release ID greater than `0`. |

## Successful response

Returns `200` on success, `data` is `null`. After the deletion is completed, re-query the list to confirm that the release is no longer returned.

```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": "ErrPublishNotFound",
  "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 not an integer greater than `0`.
  - Use the ID from the release list.
* - `403`
  - `ErrPermissionDenied`
  - The current identity does not have permission to delete.
  - Request to grant deletion permission for data release.
* - `404`
  - `ErrPublishNotFound`
  - The publication does not exist or is not visible in the current workspace.
  - Check release ID and workspace.
* - `503`
  - `ErrDataShareWritesPaused`
  - Data publishing writing is temporarily suspended.
  - Try again later.
* - `500`
  - `ErrServer`
  - The server failed to delete the publication.
  - Try again later.
```

## Follow-up operations

[Query data release list](list-publications.md), confirm that the target no longer appears.
