使用 RedactItemVersion 接口按 versionId 不可逆地清除一个历史版本的路径和内容。脱敏不修改当前文件,也不生成新版本。重复请求幂等,并保留第一次成功操作的审计信息。
前提条件
已创建 AgentStorage 实例且状态为
normal,并获取实例访问地址(endpoint)和实例名。已创建 API Key。
版本操作使用精确 Scope,
scope的四级字段(appId、tenantId、agentId、runId)全部必填,不支持通配符*。公共请求头与认证方式参见使用 API。
请求参数
字段 | 类型 | 必填 | 说明 |
| string | 是 | 要脱敏的历史版本 ID |
| string | 否 | 调用方会话或操作标识 |
请求示例
使用 API Key 认证时,通过 x-ots-instancename 和 x-ots-apikey 请求头传入实例名和 API Key。
curl -X POST https://<endpoint>/RedactItemVersion \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"type": "memoryfile",
"memoryStoreName": "agent_files",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "assistant",
"runId": "session-001"
},
"versionId": "<version-id>",
"sessionId": "privacy-job-001"
}'响应
成功响应扁平返回脱敏后的版本信息,含 redacted、redactedAt、redactedBy 审计字段:
{
"type": "memoryfile",
"versionId": "<version-id>",
"itemId": "mem_01M2Z...",
"scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "run-001" },
"operation": "modified",
"contentSha256": "40556ec6...",
"contentSizeBytes": 37,
"createdAt": "2026-09-20T09:03:24Z",
"redacted": true,
"redactedAt": "2026-09-20T09:10:00Z",
"redactedBy": "<operator>"
}该文章对您有帮助吗?