> This page is for version v1.3 (default).
> For other versions, use one of these documentation indexes:
> - v1.3 (default): https://docs.twelvelabs.io/v1.3/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.

# Delete an asset

DELETE https://api.twelvelabs.io/v1.3/assets/{asset_id}

This method deletes the specified asset. This action cannot be undone.

A successful delete also removes the asset from each entity that uses it. To list these entities first, use the [`GET`](/v1.3/api-reference/entities/list-entities-by-asset) method of the `/assets/{asset_id}/entities` endpoint.

The delete fails with a `409 Conflict` error when other resources depend on the asset.

**If the error code is `asset_has_knowledge_store_items`**, knowledge store items use the asset. The request fails even when you set the `force` query parameter to `true`. To delete the asset:

1. **Find the knowledge stores whose items use the asset**: Call the [`GET`](/v1.3/api-reference/knowledge-stores/list) method of the `/knowledge-stores` endpoint with the `asset_id` parameter set to the identifier of the asset.
2. **List the items that use the asset**: Call the [`GET`](/v1.3/api-reference/knowledge-store-items/list) method of the `/knowledge-stores/{knowledge_store_id}/items` endpoint for each knowledge store that step 1 returns. Set the `asset_id` parameter to the identifier of the asset.
3. **Delete the items**: Delete each item with the [`DELETE`](/v1.3/api-reference/knowledge-store-items/delete) method of the `/knowledge-stores/{knowledge_store_id}/items/{item_id}` endpoint.
4. **Delete the asset**: Retry the delete request. If the delete fails with the `asset_has_linked_resources` error code, follow the steps in the next case.

**If the error code is `asset_has_linked_resources`**, indexed assets reference the asset. A delete with the `force` query parameter set to `true` also deletes these indexed assets. To delete both:

1. *(Optional)* **List the indexed assets**: To see which indexed assets the delete removes, call the [`GET`](/v1.3/api-reference/index-content/list-indexed-assets-by-asset) method of the `/assets/{asset_id}/indexed-assets` endpoint.
2. **Delete the asset and its indexed assets**: Retry the delete request with the `force` query parameter set to `true`.

Reference: https://docs.twelvelabs.io/api-reference/manage-assets/delete

## Authentication

- `x-api-key` header (required) — Your API key. You can find your API key on the API Keys page.

## Request

### Path parameters

- `asset_id` (string, required) — The unique identifier of the asset to delete.

### Query parameters

- `force` (boolean, optional, default: false) — Use this parameter to choose how the delete handles indexed assets that reference the asset: - `true`: Deletes the asset and the indexed assets that reference it. - `false` or omitted: Fails with `409 Conflict` if indexed assets reference the asset. If knowledge store items use the asset, the request fails with `409 Conflict` for either value. Delete the items first. **Default**: `false`.

## Errors

### 400 Bad Request Error

The request has failed.

- `code` (string, optional) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, optional) — A human-readable string describing the error, intended to be suitable for display in a user interface.

### 404 Not Found Error

The specified asset does not exist.

- `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface.

### 409 Conflict Error

The delete fails because other resources depend on the asset. Knowledge store items use the asset, or indexed assets reference it and the `force` query parameter is not `true`.

- `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface.

## Examples

**SDK Code**

```python
import requests

url = "https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c"

querystring = {"force":"true"}

headers = {"x-api-key": "<apiKey>"}

response = requests.delete(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true';
const options = {method: 'DELETE', headers: {'x-api-key': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true");
var request = new RestRequest(Method.DELETE);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/assets/6298d673f1090f1100476d4c?force=true")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```