---
title: Delete LLM Observability data
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > LLM Observability
---

# Delete LLM Observability data{% #delete-llm-observability-data %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                           |
| ----------------- | ---------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/llm-obs/deletion/data/llmobs      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/llm-obs/deletion/data/llmobs      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/llm-obs/deletion/data/llmobs  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs |

### Overview

Submit a request to delete LLM Observability span data matching a trace ID filter within a specified time range.

### Request

#### Body Data (required)

Data deletion request payload.

{% tab title="Model" %}

| Parent field         | Field                        | Type   | Description                                                                                              |
| -------------------- | ---------------------------- | ------ | -------------------------------------------------------------------------------------------------------- |
|                      | data [*required*]       | object | Data object for an LLM Observability data deletion request.                                              |
| data                 | attributes [*required*] | object | Attributes for an LLM Observability data deletion request.                                               |
| attributes           | delay                        | int64  | Optional delay in seconds before the deletion is executed.                                               |
| attributes           | from [*required*]       | int64  | Start of the deletion time range in milliseconds since Unix epoch.                                       |
| attributes           | query [*required*]      | object | Query filters selecting the data to delete. Must include a `query` key with an `@trace_id` filter.       |
| additionalProperties | <any-key>                    | string |
| attributes           | to [*required*]         | int64  | End of the deletion time range in milliseconds since Unix epoch.                                         |
| data                 | type [*required*]       | enum   | Resource type for an LLM Observability data deletion request. Allowed enum values: `create_deletion_req` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "delay": 0,
      "from": 1705314600000,
      "query": {
        "<any-key>": "string"
      },
      "to": 1705315200000
    },
    "type": "create_deletion_req"
  }
}
```

{% /tab %}

### Response

{% tab title="202" %}
Accepted
{% tab title="Model" %}
Response containing details of a submitted LLM Observability data deletion request.

| Parent field | Field                        | Type      | Description                                                                                            |
| ------------ | ---------------------------- | --------- | ------------------------------------------------------------------------------------------------------ |
|              | data [*required*]       | object    | Data object for an LLM Observability data deletion response.                                           |
| data         | attributes [*required*] | object    | Attributes of a submitted LLM Observability data deletion request.                                     |
| attributes   | created_at [*required*] | date-time | Timestamp when the deletion request was created.                                                       |
| attributes   | created_by [*required*] | string    | UUID of the user who created the deletion request.                                                     |
| attributes   | from_time [*required*]  | int64     | Start of the deletion time range in milliseconds since Unix epoch.                                     |
| attributes   | org_id [*required*]     | int64     | ID of the organization that submitted the deletion request.                                            |
| attributes   | product [*required*]    | string    | Product name for the deletion request.                                                                 |
| attributes   | query [*required*]      | string    | The query string used to select data for deletion.                                                     |
| attributes   | to_time [*required*]    | int64     | End of the deletion time range in milliseconds since Unix epoch.                                       |
| data         | id [*required*]         | string    | Unique identifier of the deletion request.                                                             |
| data         | type [*required*]       | enum      | Resource type for an LLM Observability data deletion response. Allowed enum values: `deletion_request` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "created_at": "2024-01-15T10:30:00Z",
      "created_by": "user-uuid-1234",
      "from_time": 1705314600000,
      "org_id": 12345,
      "product": "llmobs",
      "query": "@trace_id:abc123def456",
      "to_time": 1705315200000
    },
    "id": "msg-abc123",
    "type": "deletion_request"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/llm-obs/deletion/data/llmobs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "from": 1705314600000,
      "query": {
        "query": "@trace_id:abc123def456"
      },
      "to": 1705315200000
    },
    "type": "create_deletion_req"
  }
}
EOF 
                
##### 

```python
"""
Delete LLM Observability data returns "Accepted" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.llm_observability_api import LLMObservabilityApi
from datadog_api_client.v2.model.llm_obs_data_deletion_request import LLMObsDataDeletionRequest
from datadog_api_client.v2.model.llm_obs_data_deletion_request_attributes import LLMObsDataDeletionRequestAttributes
from datadog_api_client.v2.model.llm_obs_data_deletion_request_data import LLMObsDataDeletionRequestData
from datadog_api_client.v2.model.llm_obs_data_deletion_request_type import LLMObsDataDeletionRequestType

body = LLMObsDataDeletionRequest(
    data=LLMObsDataDeletionRequestData(
        attributes=LLMObsDataDeletionRequestAttributes(
            delay=0,
            _from=1705314600000,
            query=dict(
                query="@trace_id:abc123def456",
            ),
            to=1705315200000,
        ),
        type=LLMObsDataDeletionRequestType.CREATE_DELETION_REQ,
    ),
)

configuration = Configuration()
configuration.unstable_operations["delete_llm_obs_data"] = True
with ApiClient(configuration) as api_client:
    api_instance = LLMObservabilityApi(api_client)
    response = api_instance.delete_llm_obs_data(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Delete LLM Observability data returns "Accepted" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.delete_llm_obs_data".to_sym] = true
end
api_instance = DatadogAPIClient::V2::LLMObservabilityAPI.new

body = DatadogAPIClient::V2::LLMObsDataDeletionRequest.new({
  data: DatadogAPIClient::V2::LLMObsDataDeletionRequestData.new({
    attributes: DatadogAPIClient::V2::LLMObsDataDeletionRequestAttributes.new({
      delay: 0,
      from: 1705314600000,
      query: {
        query: "@trace_id:abc123def456",
      },
      to: 1705315200000,
    }),
    type: DatadogAPIClient::V2::LLMObsDataDeletionRequestType::CREATE_DELETION_REQ,
  }),
})
p api_instance.delete_llm_obs_data(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Delete LLM Observability data returns "Accepted" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.LLMObsDataDeletionRequest{
		Data: datadogV2.LLMObsDataDeletionRequestData{
			Attributes: datadogV2.LLMObsDataDeletionRequestAttributes{
				Delay: datadog.PtrInt64(0),
				From:  1705314600000,
				Query: map[string]string{
					"query": "@trace_id:abc123def456",
				},
				To: 1705315200000,
			},
			Type: datadogV2.LLMOBSDATADELETIONREQUESTTYPE_CREATE_DELETION_REQ,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.DeleteLLMObsData", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewLLMObservabilityApi(apiClient)
	resp, r, err := api.DeleteLLMObsData(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `LLMObservabilityApi.DeleteLLMObsData`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `LLMObservabilityApi.DeleteLLMObsData`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Delete LLM Observability data returns "Accepted" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LlmObservabilityApi;
import com.datadog.api.client.v2.model.LLMObsDataDeletionRequest;
import com.datadog.api.client.v2.model.LLMObsDataDeletionRequestAttributes;
import com.datadog.api.client.v2.model.LLMObsDataDeletionRequestData;
import com.datadog.api.client.v2.model.LLMObsDataDeletionRequestType;
import com.datadog.api.client.v2.model.LLMObsDataDeletionResponse;
import java.util.Map;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.deleteLLMObsData", true);
    LlmObservabilityApi apiInstance = new LlmObservabilityApi(defaultClient);

    LLMObsDataDeletionRequest body =
        new LLMObsDataDeletionRequest()
            .data(
                new LLMObsDataDeletionRequestData()
                    .attributes(
                        new LLMObsDataDeletionRequestAttributes()
                            .delay(0L)
                            .from(1705314600000L)
                            .query(Map.ofEntries(Map.entry("query", "@trace_id:abc123def456")))
                            .to(1705315200000L))
                    .type(LLMObsDataDeletionRequestType.CREATE_DELETION_REQ));

    try {
      LLMObsDataDeletionResponse result = apiInstance.deleteLLMObsData(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling LlmObservabilityApi#deleteLLMObsData");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Delete LLM Observability data returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_llm_observability::LLMObservabilityAPI;
use datadog_api_client::datadogV2::model::LLMObsDataDeletionRequest;
use datadog_api_client::datadogV2::model::LLMObsDataDeletionRequestAttributes;
use datadog_api_client::datadogV2::model::LLMObsDataDeletionRequestData;
use datadog_api_client::datadogV2::model::LLMObsDataDeletionRequestType;
use std::collections::BTreeMap;

#[tokio::main]
async fn main() {
    let body = LLMObsDataDeletionRequest::new(LLMObsDataDeletionRequestData::new(
        LLMObsDataDeletionRequestAttributes::new(
            1705314600000,
            BTreeMap::from([("query".to_string(), "@trace_id:abc123def456".to_string())]),
            1705315200000,
        )
        .delay(0),
        LLMObsDataDeletionRequestType::CREATE_DELETION_REQ,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.DeleteLLMObsData", true);
    let api = LLMObservabilityAPI::with_config(configuration);
    let resp = api.delete_llm_obs_data(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Delete LLM Observability data returns "Accepted" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.deleteLLMObsData"] = true;
const apiInstance = new v2.LLMObservabilityApi(configuration);

const params: v2.LLMObservabilityApiDeleteLLMObsDataRequest = {
  body: {
    data: {
      attributes: {
        delay: 0,
        from: 1705314600000,
        query: {
          query: "@trace_id:abc123def456",
        },
        to: 1705315200000,
      },
      type: "create_deletion_req",
    },
  },
};

apiInstance
  .deleteLLMObsData(params)
  .then((data: v2.LLMObsDataDeletionResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
