> Source: https://wexa.ai/docs/context/delete-kb-document

# delete-kb-document

[Can be held for approval](/docs/sdks-and-apis/how-every-tool-call-works#lifecycle-and-governance)

Delete knowledge base documents by file id, by tag, or both. Irreversible: tags remove every document under them. Needs the `fabric:kb.delete` grant.

The shape of `result` for `delete-kb-document` is not recorded here: it was not captured against a live deployment. Call it once and read what comes back rather than assuming a shape.

**Delete by tag**

**Wexa MCP server**

```bash
curl -sS -X POST https://fabric.wexa.ai/mcp/$FABRIC_PROJECT_ID \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "Mcp-Session-Id: $MCP_SESSION_ID" \
  -H "content-type: application/json" -H "accept: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"delete-kb-document","arguments":{"tags":["procurement-policy"]}}}'
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/delete-kb-document \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"tags":["procurement-policy"]}'
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const result = await fabric.deleteKbDocument({
  tags: [ 'procurement-policy' ]
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.delete_kb_document(
    tags=["procurement-policy"],
)
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `file_ids` | array | Optional | Files to delete, by id: the `file_id` `knowledge-base-add` returned, or the id of a file uploaded in the console. A `file_id` not in this project deletes nothing and is a 404. |
| `tags` | array | Optional | Tags whose documents are deleted: every document under any of them, not one. Give at least one of `file_ids` or `tags`. Tags that match no document are a 404. |

**Errors**

- `ValidationError` (422): neither `file_ids` nor `tags` is a non-empty array. An empty selector would name the whole corpus, which this tool will not delete.
- `UpstreamError` (503): `S8:knowledge-base-unavailable`, raised by the lookup that runs before anything is removed, so nothing was deleted.

**More details**

Full description from the tool, as the gateway advertises it:

Delete knowledge base documents from this project, by file id and/or by tag. Any file in the project's Knowledge Base can be named, whether uploaded in the console or created by knowledge-base-add (its `file_id` is in that tool's result). It is removed the way the console removes it: the file, its record, its connector and its vectors. Tags remove EVERY document under any of the tags, not one document. Permanent, no undo, so retrieve first and look at what you are about to lose. A file id not in this project deletes nothing and is a 404; tags matching nothing are a 404, not a cheerful success. Agents with has_knowledge_base stop seeing the removed content immediately.

Marked consequential: it is audited in full, and a policy rule may hold it for a person to approve. See [Policy and approvals](/docs/governance/policy-and-approvals).

Every tool call works the same way: [How every tool call works](/docs/sdks-and-apis/how-every-tool-call-works).
