> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.privategpt.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server.

# Delete Document Asynchronously

POST /v1/artifacts/delete/async
Content-Type: application/json

Initiates asynchronous deletion of a document and all associated data.

This endpoint queues a deletion task for background processing, making it
suitable for large documents or when non-blocking operation is required.
The task can be monitored using the returned task ID.

If an ingestion task is currently running for the same document, it will
be automatically revoked before initiating the deletion.

Reference: https://docs.privategpt.dev/api-reference/artifacts/delete-ingested-async-v-1-artifacts-delete-async-post

## Request

### Body (application/json)

This endpoint expects a DeleteIngestedDocumentAsyncBody.

- `delete_body` (DeleteIngestedDocumentBody, required) — Document deletion parameters including collection and artifact identifiers
- `callback` (Callback, optional, nullable) — Optional callback configuration for receiving asynchronous task notifications

## Response

### 200

Successfully initiated deletion task

- `task_id` (string, required) — Unique identifier for the asynchronous task, used to track progress and retrieve results

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 422 Unprocessable Entity Error

Invalid request parameters

- `any`

## Types

### DeleteIngestedDocumentBody

Request body for deleting specific ingested documents from the system.

- `collection` (string, required) — Name of the collection containing the document to be deleted
- `artifact` (string, required) — Unique identifier of the document to delete from the specified collection

### Callback

Callback configuration for asynchronous task notifications.

- `amqp` (AMQP, required) — AMQP (Advanced Message Queuing Protocol) configuration for task status notifications
- `properties` (map from string to any, optional, nullable) — Additional properties and metadata to include with callback notifications

### AMQP

AMQP configuration for message queue notifications.

- `exchange` (string, required) — AMQP exchange name where task notifications will be published
- `routing_key_done` (string, optional, nullable) — Routing key used when publishing task completion notifications
- `routing_key_progress` (string, optional, nullable) — Routing key used when publishing task progress update notifications
- `routing_key_error` (string, optional, nullable) — Routing key used when publishing task error notifications

## Examples

**Request**

```json
{
  "delete_body": {
    "collection": "financial_reports",
    "artifact": "obsolete_report_2022"
  },
  "callback": {
    "amqp": {
      "exchange": "deletion_events",
      "routing_key_done": "delete.completed",
      "routing_key_progress": "delete.progress",
      "routing_key_error": "delete.failed"
    }
  }
}
```

**Response**

```json
{
  "task_id": "123e4567-e89b-12d3-a456-426614174000"
}
```

**SDK Code**

```python Artifacts_delete_ingested_async_v1_artifacts_delete_async_post_example
import requests

url = "https://api.example.com/v1/artifacts/delete/async"

payload = {
    "delete_body": {
        "collection": "financial_reports",
        "artifact": "obsolete_report_2022"
    },
    "callback": { "amqp": {
            "exchange": "deletion_events",
            "routing_key_done": "delete.completed",
            "routing_key_progress": "delete.progress",
            "routing_key_error": "delete.failed"
        } }
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Artifacts_delete_ingested_async_v1_artifacts_delete_async_post_example
const url = 'https://api.example.com/v1/artifacts/delete/async';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"delete_body":{"collection":"financial_reports","artifact":"obsolete_report_2022"},"callback":{"amqp":{"exchange":"deletion_events","routing_key_done":"delete.completed","routing_key_progress":"delete.progress","routing_key_error":"delete.failed"}}}'
};

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

```go Artifacts_delete_ingested_async_v1_artifacts_delete_async_post_example
package main

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

func main() {

	url := "https://api.example.com/v1/artifacts/delete/async"

	payload := strings.NewReader("{\n  \"delete_body\": {\n    \"collection\": \"financial_reports\",\n    \"artifact\": \"obsolete_report_2022\"\n  },\n  \"callback\": {\n    \"amqp\": {\n      \"exchange\": \"deletion_events\",\n      \"routing_key_done\": \"delete.completed\",\n      \"routing_key_progress\": \"delete.progress\",\n      \"routing_key_error\": \"delete.failed\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("https://api.example.com/v1/artifacts/delete/async")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"delete_body\": {\n    \"collection\": \"financial_reports\",\n    \"artifact\": \"obsolete_report_2022\"\n  },\n  \"callback\": {\n    \"amqp\": {\n      \"exchange\": \"deletion_events\",\n      \"routing_key_done\": \"delete.completed\",\n      \"routing_key_progress\": \"delete.progress\",\n      \"routing_key_error\": \"delete.failed\"\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/delete/async")
  .header("Content-Type", "application/json")
  .body("{\n  \"delete_body\": {\n    \"collection\": \"financial_reports\",\n    \"artifact\": \"obsolete_report_2022\"\n  },\n  \"callback\": {\n    \"amqp\": {\n      \"exchange\": \"deletion_events\",\n      \"routing_key_done\": \"delete.completed\",\n      \"routing_key_progress\": \"delete.progress\",\n      \"routing_key_error\": \"delete.failed\"\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/delete/async', [
  'body' => '{
  "delete_body": {
    "collection": "financial_reports",
    "artifact": "obsolete_report_2022"
  },
  "callback": {
    "amqp": {
      "exchange": "deletion_events",
      "routing_key_done": "delete.completed",
      "routing_key_progress": "delete.progress",
      "routing_key_error": "delete.failed"
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Artifacts_delete_ingested_async_v1_artifacts_delete_async_post_example
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/delete/async");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"delete_body\": {\n    \"collection\": \"financial_reports\",\n    \"artifact\": \"obsolete_report_2022\"\n  },\n  \"callback\": {\n    \"amqp\": {\n      \"exchange\": \"deletion_events\",\n      \"routing_key_done\": \"delete.completed\",\n      \"routing_key_progress\": \"delete.progress\",\n      \"routing_key_error\": \"delete.failed\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Artifacts_delete_ingested_async_v1_artifacts_delete_async_post_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "delete_body": [
    "collection": "financial_reports",
    "artifact": "obsolete_report_2022"
  ],
  "callback": ["amqp": [
      "exchange": "deletion_events",
      "routing_key_done": "delete.completed",
      "routing_key_progress": "delete.progress",
      "routing_key_error": "delete.failed"
    ]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/delete/async")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```