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

# Delete by Intent

> API reference for the delete by intent endpoint

The `/delete_by_intent` endpoint allows you to remove knowledge entries that match a specific intent.

## Base URL

```bash
POST https://osmosis.gulp.dev/delete_by_intent
```

## Authentication

<RequestHeader>
  <HeaderParameter name="Content-Type" required type="string">
    application/json
  </HeaderParameter>

  <HeaderParameter name="x-api-key" required type="string">
    Your API key
  </HeaderParameter>
</RequestHeader>

## Query Parameters

<ParamField query="tenant_id" type="string" required>
  The tenant identifier
</ParamField>

<ParamField query="intent" type="string" required>
  The intent to match against
</ParamField>

<ParamField query="similarity_threshold" type="number" default="0.5">
  Optional similarity threshold for matching documents
</ParamField>

## Example Requests

<CodeGroup>
  ```bash cURL
  curl -X POST 'https://osmosis.gulp.dev/delete_by_intent?tenant_id=api_key&intent=process%20refund&similarity_threshold=0.7' \
    -H "Content-Type: application/json" \
    -H "x-api-key: your-api-key"
  ```

  ```typescript TypeScript
  import axios from 'axios';

  async function deleteByIntent() {
    const apiKey = process.env.OSMOSIS_API_KEY;
    
    const response = await axios.post('https://osmosis.gulp.dev/delete_by_intent', null, {
      params: {
        tenant_id: apiKey,
        intent: 'process refund',
        similarity_threshold: 0.7
      },
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': apiKey
      }
    });
    
    return response.data;
  }
  ```

  ```python Python
  import os
  import requests

  def delete_by_intent():
      api_key = os.getenv('OSMOSIS_API_KEY')
      
      params = {
          "tenant_id": api_key,
          "intent": "process refund",
          "similarity_threshold": 0.7
      }
      
      response = requests.post(
          "https://osmosis.gulp.dev/delete_by_intent",
          params=params,
          headers={
              "Content-Type": "application/json",
              "x-api-key": api_key
          }
      )
      
      return response.json()
  ```

  ```go Go
  package main

  import (
      "encoding/json"
      "net/http"
      "net/url"
      "os"
  )

  func deleteByIntent() ([]byte, error) {
      apiKey := os.getenv("OSMOSIS_API_KEY")
      baseURL := "https://osmosis.gulp.dev/delete_by_intent"
      
      params := url.Values{}
      params.Add("tenant_id", apiKey)
      params.Add("intent", "process refund")
      params.Add("similarity_threshold", "0.7")
      
      req, err := http.NewRequest("POST", baseURL+"?"+params.Encode(), nil)
      if err != nil {
          return nil, err
      }

      req.Header.Set("Content-Type", "application/json")
      req.Header.Set("x-api-key", apiKey)

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          return nil, err
      }
      defer resp.Body.Close()

      return json.Marshal(resp)
  }
  ```
</CodeGroup>

## Response

### Success Response

<ResponseField name="deleted_count" type="number" required>
  Number of documents deleted
</ResponseField>

<ResponseField name="status" type="string" required>
  Operation status message
</ResponseField>

Example success response:

```json
{
  "deleted_count": 5,
  "status": "Successfully deleted matching documents"
}
```

### Error Response

<ResponseField name="detail" type="array" required>
  Array of validation errors
</ResponseField>

Example error response:

```json
{
  "detail": [
    {
      "loc": ["query", "tenant_id"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

## Status Codes

<ResponseStatus code={200} status="OK">
  Documents deleted successfully
</ResponseStatus>

<ResponseStatus code={422} status="Unprocessable Entity">
  Invalid request (validation error)
</ResponseStatus>

## Best Practices

1. **Similarity Threshold**
   * Start with the default threshold of 0.5
   * Increase for more precise matching
   * Decrease for broader matching
   * Test with small deletions first

2. **Intent Formatting**
   * Use clear, specific intents
   * Keep intents concise
