Skip to content

删除已上传文件 ​

接口说明 ​

删除一个已上传的 Markdown 文件,并从可读取的知识库中移除对应页面。

接口信息 ​

字段值
方法DELETE
路径/openapi/v2/knowledge-bases/{knowledgeBaseId}/source-files/{sourceFileId}
Operation IDdeleteSourceFile
鉴权Bearer OpenAPI key

入参 ​

名称位置必填类型示例说明
knowledgeBaseIdpath是stringknowledge-base-11111111-1111-4111-8111-111111111111知识库 API 返回的知识库标识。
sourceFileIdpath是stringsource-file-11111111-1111-4111-8111-111111111111上传接口或已上传文件列表接口返回的文件标识。
Idempotency-Keyheader是stringmutation-2026-07-10-001客户端为请求生成的幂等键。重试同一请求时复用相同值,可以避免创建重复任务。
If-Matchheader是string"1"API 返回的当前 resourceRevision。如果读取后资源又被修改,请求会返回冲突,避免覆盖较新的修改。

请求体 ​

这个接口没有请求体。

请求示例 ​

bash
curl -X DELETE "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-11111111-1111-4111-8111-111111111111" \
  -H "Authorization: Bearer <openapi-key>" \
  -H "Idempotency-Key: mutation-2026-07-10-001" \
  -H "If-Match: \"1\""

成功响应 ​

202 ​

返回已经提交到后台处理的文件删除请求。

字段必填类型说明
operation是object资源变更记录。
deletion是object已受理删除操作的摘要。

成功响应示例 ​

json
{
  "operation": {
    "operationId": "deletion-33333333-3333-4333-8333-333333333333",
    "knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
    "kind": "source_file_delete",
    "state": "processing",
    "expectedResourceRevision": 1,
    "targetKind": "source_file",
    "targetId": "source-file-11111111-1111-4111-8111-111111111111",
    "candidateRelativePath": "handbook/guide.md",
    "result": null,
    "errorCode": null,
    "retryGuidance": "Check this change again after a short delay.",
    "actions": {
      "self": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/operations/deletion-33333333-3333-4333-8333-333333333333"
    },
    "createdAt": "2026-06-17T00:00:00.000Z",
    "updatedAt": "2026-06-17T00:00:00.000Z",
    "completedAt": null
  },
  "deletion": {
    "sourceFileId": "source-file-11111111-1111-4111-8111-111111111111"
  }
}

错误码 ​

下表列出这个接口已声明的全部错误响应。

HTTP 状态错误码说明
401UNAUTHORIZEDBearer API key 缺失、格式错误、未知、已撤销或已删除。
404NOT_FOUND请求的资源不存在。
409CONFLICT请求与资源当前状态冲突。
422VALIDATION_ERROR请求未通过校验。
429RATE_LIMITED请求超过当前配置的速率限制。
500INTERNAL_ERRORAPI 遇到内部错误。
503DATABASE_REPOSITORY_UNAVAILABLE当前接口所需的数据暂时不可用。

后续操作 ​