> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete an ML Model

> Delete an ML model by ID or name, with soft/hard delete options

# Delete an ML Model

Delete an ML model by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations.

## Delete by ID

**id** `string` *required*

UUID of the ML model to delete.

**recursive** `boolean` (default: false)

Recursively delete child entities.

**hardDelete** `boolean` (default: false)

Permanently delete the ML model. If `false`, the ML model is soft-deleted and can be restored.

## Delete by Name

Use `DELETE /v1/mlmodels/name/{fqn}` to delete by fully qualified name.

**fqn** `string` *required*

Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`.

**recursive** `boolean` (default: false)

Recursively delete child entities.

**hardDelete** `boolean` (default: false)

Permanently delete the ML model.

## Restore a Soft-Deleted ML Model

Use `PUT /v1/mlmodels/restore` to restore a soft-deleted ML model.

**id** `string` *required*

UUID of the soft-deleted ML model to restore.

```python DELETE /v1/mlmodels/{id} theme={null}
from metadata.sdk import configure
from metadata.sdk.entities import MLModels

configure(
    host="https://your-company.open-metadata.org/api",
    jwt_token="your-jwt-token"
)

# Soft delete by ID
MLModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2")

# Hard delete
MLModels.delete(
    "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
    hard_delete=True
)

# Delete by name
model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation")
MLModels.delete(model.id)

# Delete by name with options
model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation")
MLModels.delete(
    model.id,
    hard_delete=True
)

# Restore a soft-deleted ML model
MLModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2")
```

```java DELETE /v1/mlmodels/{id} theme={null}
import java.util.Map;
import org.openmetadata.schema.entity.data.MlModel;

// client is an initialized OpenMetadataClient.

// Soft delete
client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2");

// Hard delete
client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", Map.of("hardDelete", "true"));

// Delete by name (look up the ID first)
MlModel model = client.mlModels().getByName("mlflow_svc.customer_segmentation");
client.mlModels().delete(model.getId());

// Restore
client.mlModels().restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2");
```

```bash DELETE /v1/mlmodels/{id} theme={null}
# Soft delete by ID
curl -X DELETE "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2" \
  -H "Authorization: Bearer {access_token}"

# Hard delete
curl -X DELETE "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2?hardDelete=true" \
  -H "Authorization: Bearer {access_token}"

# Delete by name
curl -X DELETE "{base_url}/api/v1/mlmodels/name/mlflow_svc.customer_segmentation" \
  -H "Authorization: Bearer {access_token}"

# Restore soft-deleted ML model
curl -X PUT "{base_url}/api/v1/mlmodels/restore" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{"id": "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"}'
```

```json Response (Soft Delete) theme={null}
{
  "id": "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
  "name": "customer_segmentation",
  "fullyQualifiedName": "mlflow_svc.customer_segmentation",
  "displayName": "Customer Segmentation Model",
  "algorithm": "KMeans",
  "version": 0.2,
  "updatedAt": 1769982669247,
  "updatedBy": "admin",
  "service": {
    "id": "ca22d46e-81b9-4e48-85b5-0adc44980da9",
    "type": "mlmodelService",
    "name": "mlflow_svc",
    "fullyQualifiedName": "mlflow_svc"
  },
  "serviceType": "Mlflow",
  "deleted": true,
  "owners": [],
  "tags": [],
  "domains": []
}
```

***

## Returns

Soft delete returns the ML model object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored ML model object.

***

## Error Handling

| Code | Error Type | Description |
| - | - | - |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission to delete this ML model |
| `404` | `NOT_FOUND` | ML model with given ID or FQN does not exist |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.