# 在向量存储中删除文档

{% openapi src="<https://1371168417-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gvX7KIUy0DhcQETj8Ux%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media&token=cce1ab0d-330f-4bed-b7da-5635aaf25472>" path="/vector-stores/{vector-store-id}/documents/{document-id}/" method="delete" %}
[rememberizer\_openapi.yml](https://1371168417-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gvX7KIUy0DhcQETj8Ux%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=cce1ab0d-330f-4bed-b7da-5635aaf25472)
{% endopenapi %}

## 示例请求

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X DELETE \
  https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/1234/ \
  -H "x-api-key: YOUR_API_KEY"
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}

{% tab title="JavaScript" %}

```javascript
const deleteDocument = async (vectorStoreId, documentId) => {
  const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/${documentId}/`, {
    method: 'DELETE',
    headers: {
      'x-api-key': 'YOUR_API_KEY'
    }
  });
  
  if (response.status === 204) {
    console.log("文档删除成功");
  } else {
    console.error("删除文档失败");
  }
};

deleteDocument('vs_abc123', 1234);
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}

{% tab title="Python" %}

```python
import requests

def delete_document(vector_store_id, document_id):
    headers = {
        "x-api-key": "YOUR_API_KEY"
    }
    
    response = requests.delete(
        f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/{document_id}/",
        headers=headers
    )
    
    if response.status_code == 204:
        print("文档删除成功")
    else:
        print(f"删除文档失败: {response.text}")

delete_document('vs_abc123', 1234)
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}
{% endtabs %}

## 路径参数

| 参数              | 类型  | 描述                    |
| --------------- | --- | --------------------- |
| vector-store-id | 字符串 | **必填。** 包含文档的向量存储的ID。 |
| document-id     | 整数  | **必填。** 要删除的文档的ID。    |

## 响应

成功的请求返回204无内容状态码，且没有响应体。

## 认证

此端点需要使用 `x-api-key` 头中的 API 密钥进行认证。

## 错误响应

| 状态码 | 描述                  |
| --- | ------------------- |
| 401 | 未授权 - 无效或缺失的 API 密钥 |
| 404 | 未找到 - 向量存储或文档未找到    |
| 500 | 内部服务器错误             |

此端点允许您从向量存储中删除文档。一旦删除，该文档及其向量嵌入将不再可用于搜索操作。这对于从知识库中删除过时、不相关或敏感内容非常有用。

{% hint style="warning" %}
警告：文档删除是永久性的，无法撤销。在删除重要文档之前，请确保您有备份。
{% endhint %}
