
## Delete asset

URL: https://docs.atlan.com/product/capabilities/build-apps/sdks/python/how-tos/asset-crud/delete-asset

> Delete assets in Atlan using Asset and the Python SDK (pyatlan) — soft-delete (archive) or hard-delete (purge), including bulk deletion via DELETE /api/meta/entity/bulk.

# Asset: delete assets soft or hard

Use `Asset` in the Atlan Python SDK to programmatically delete assets (soft delete by default, or hard purge).

Deleting an [asset](https://docs.atlan.com/llms/platform/python/build-your-first-metadata-workflow/llms.txt) uses a similar pattern to the retrieval operations. For this you can use static methods provided by the `Asset` class.

:::warning[Avoid deleting connections]
If you want to delete a connection and all of its assets, consider using the [connection delete package](https://docs.atlan.com/llms/platform/python/delete-connection/llms.txt) instead. In particular, avoid deleting a connection directly (using the methods below) without first deleting the assets contained within it. Once you delete a connection, you will be unable to delete any assets that were within it.
:::

## Soft-delete asset

Soft-deletes (also called an *archive*) are a reversible operation. The status of the asset is changed to `DELETED` and it no longer appears in the UI, but the asset is still present in Atlan's back-end.

To soft-delete (archive) an asset, you only need to provide the GUID:

### Java

```java showLineNumbers title="Soft-delete an asset"
AssetMutationResponse response =
 Asset.delete(client, "b4113341-251b-4adc-81fb-2420501c30e6"); // (1)
Asset deleted = response.getDeletedAssets().get(0); // (2)
Business Graph glossary;
if (deleted instanceof Business Graph)
```

1. The `delete()` method returns the deleted form of the asset. Because this operation will archive the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
2. You can distinguish what was deleted through the `getDeletedAssets()` method. This lists only the assets deleted by the operation.
3. The `Asset` class is a superclass of all assets. So you need to cast to more specific types (like `Business Graph`) after verifying the object that was actually returned.

### Python

```python showLineNumbers title="Soft-delete an asset"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasBusiness Graph

client = AtlanClient()
response = client.asset.delete_by_guid("b4113341-251b-4adc-81fb-2420501c30e6") # (1)
if deleted := response.assets_deleted(asset_type=AtlasBusiness Graph): # (2)
 term = deleted[0] # (3)
```

1. The `asset.delete_by_guid()` method returns the deleted form of the asset.
2. The `assets_deleted(asset_type=AtlasBusiness Graph)` method returns a list of the assets of the given type that were deleted.
3. If an asset of the given type was deleted, then the deleted form of the asset is available.

### Kotlin

```kotlin showLineNumbers title="Soft-delete an asset"
val response =
 Asset.delete(client, "b4113341-251b-4adc-81fb-2420501c30e6") // (1)
val deleted = response.deletedAssets[0] // (2)
val glossary = if (deleted is Business Graph) deleted else null // (3)
```

1. The `delete()` method returns the deleted form of the asset. Because this operation will archive the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
2. You can distinguish what was deleted through the `deletedAssets` method. This lists only the assets deleted by the operation.
3. The `Asset` class is a superclass of all assets. So you need to cast to more specific types (like `Business Graph`) after verifying the object that was actually returned.

### Raw REST API

```json showLineNumbers title="DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&deleteType=SOFT"
// (1)
```

1. In the case of deleting an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request. To archive an asset, use `deleteType` of `SOFT`.

## Hard-delete asset

Hard-deletes (also called a *purge*) are irreversible operations. The asset is removed from Atlan entirely, so no longer appears in the UI and also no longer exists in Atlan's back-end.

To hard-delete (purge) an asset, you only need to provide the GUID:

### Java

```java showLineNumbers title="Hard-delete (purge) an asset"
AssetMutationResponse response =
 Asset.purge(client, "b4113341-251b-4adc-81fb-2420501c30e6"); // (1)
Asset deleted = response.getDeletedAssets().get(0); // (2)
Business Graph glossary;
if (deleted instanceof Business Graph)
```

1. The `purge()` method returns the purged form of the asset. Because this operation will remove the asset from Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
2. You can distinguish what was purged through the `getDeletedAssets()` method. This lists only the assets deleted by the operation.
3. The `Asset` class is a superclass of all assets. So you need to cast to more specific types (like `Business Graph`) after verifying the object that was actually returned.

### Python

```python showLineNumbers title="Hard-delete (purge) an asset"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasBusiness Graph

client = AtlanClient()
response = client.asset.purge_by_guid("b4113341-251b-4adc-81fb-2420501c30e6") # (1)
if deleted := response.assets_deleted(asset_type=AtlasBusiness Graph): # (2)
 term = deleted[0] # (3)
```

1. The `asset.purge_by_guid()` method returns the deleted form of the asset.
2. The `assets_deleted(asset_type=AtlasBusiness Graph)` method returns a list of the assets of the given type that were deleted.
3. If an asset of the given type was deleted, then the deleted form of the asset is available.

### Kotlin

```kotlin showLineNumbers title="Hard-delete (purge) an asset"
val response =
 Asset.purge(client, "b4113341-251b-4adc-81fb-2420501c30e6") // (1)
val deleted = response.deletedAssets[0] // (2)
val glossary = if (deleted is Business Graph) deleted else null // (3)
```

1. The `purge()` method returns the purged form of the asset. Because this operation will remove the asset from Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
2. You can distinguish what was purged through the `deletedAssets` method. This lists only the assets deleted by the operation.
3. The `Asset` class is a superclass of all assets. So you need to cast to more specific types (like `Business Graph`) after verifying the object that was actually returned.

### Raw REST API

```json showLineNumbers title="DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&deleteType=PURGE"
// (1)
```

1. In the case of deleting an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request. To permanently and irreversibly remove an asset, use `deleteType` of `PURGE`.

## Bulk-delete assets

You can also delete a number of [assets](https://docs.atlan.com/llms/platform/python/build-your-first-metadata-workflow/llms.txt) at the same time:

:::tip[Up to a limit]
You can't send an unlimited number of assets to be deleted in a single request. As you can see from the Raw REST API tab, each GUID will be sent as a query parameter in the URI—so there is a maximum beyond which the URI is too long.

We generally recommend sending no more than 20-50 GUIDs at a time using this approach.
:::

### Java

```java showLineNumbers title="Hard-delete (purge) multiple assets"
AssetMutationResponse response =
 client.assets.delete( // (1)
 List.of("b4113341-251b-4adc-81fb-2420501c30e6", // (2)
 "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
 "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"),
 AtlanDeleteType.PURGE); // (3)
List deleted = response.getDeletedAssets(); // (4)
```

1. The `delete()` method on the endpoint itself can be used to either archive (soft-delete) or purge (hard-delete).
2. You can provide a list of any number of assets to delete (their GUIDs).
3. You need to also specify whether you want to soft-delete (archive) using `AtlanDeleteType.SOFT` or hard-delete (purge) the assets using `AtlanDeleteType.PURGE`.
4. The response will contain details of all of the assets that were deleted.

### Python

```python showLineNumbers title="Hard-delete (purge) multiple assets"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasBusiness Graph

client = AtlanClient()
response = client.asset.purge_by_guid([ # (1)
 "b4113341-251b-4adc-81fb-2420501c30e6",
 "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
 "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"
])
if deleted := response.assets_deleted(asset_type=AtlasBusiness Graph): # (2)
 term = deleted[0] # (3)
```

1. You can alternatively provide either the `asset.purge_by_guid()` or `asset.delete_by_guid()` methods with a list of any number of assets to delete (their GUIDs).
2. The `assets_deleted(asset_type=AtlasBusiness Graph)` method returns a list of the assets of the given type that were deleted.
3. If an asset of the given type was deleted, then the deleted form of the asset is available.

### Kotlin

```kotlin showLineNumbers title="Hard-delete (purge) multiple assets"
val response =
 client.assets.delete( // (1)
 listOf(
 "b4113341-251b-4adc-81fb-2420501c30e6", // (2)
 "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
 "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"
 ),
 AtlanDeleteType.PURGE // (3)
 )
val deleted = response.deletedAssets // (4)
```

1. The `delete()` method on the endpoint itself can be used to either archive (soft-delete) or purge (hard-delete).
2. You can provide a list of any number of assets to delete (their GUIDs).
3. You need to also specify whether you want to soft-delete (archive) using `AtlanDeleteType.SOFT` or hard-delete (purge) the assets using `AtlanDeleteType.PURGE`.
4. The response will contain details of all of the assets that were deleted.

### Raw REST API

```json showLineNumbers title="DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&guid=21e5be62-7a0b-4547-ab7a-6ddf273d0640&guid=a0fb35e5-690d-4a5b-8918-9ee267c8fa55&deleteType=SOFT"
// (1)
```

1. In the case of deleting multiple assets, all necessary information is included in the URL of the request. Each separate asset's GUID should be given after a `guid=` query parameter. There is no payload for the body of the request.

:::warning[Bulk deletion occurs asynchronously]
Be aware that bulk deleting assets occurs asynchronously. The response above will come back indicating the deleted assets; however, there can still be a delay before those assets are fully deleted in Atlan.
:::

---
