> Source: https://wexa.ai/docs/context/knowledge-base-add

# knowledge-base-add

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

Add a document to the project's knowledge base so `knowledge-base-retrieve` can find it. Needs the `fabric:orchestrate.write` grant.

The shape of `result` for `knowledge-base-add` 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.

**Add a document**

**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":"knowledge-base-add","arguments":{"content":"Purchases above the approval limit need a second approver.","tags":["procurement-policy"]}}}'
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/knowledge-base-add \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"content":"Purchases above the approval limit need a second approver.","tags":["procurement-policy"]}'
```

**TypeScript SDK**

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

const fabric = new Fabric()
const result = await fabric.knowledgeBaseAdd({
  content: 'Purchases above the approval limit need a second approver.',
  tags: [ 'procurement-policy' ]
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.knowledge_base_add(
    content="Purchases above the approval limit need a second approver.",
    tags=["procurement-policy"],
)
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `content` | string | Required | The document text to ingest. Non-empty. |
| `name` | string | Optional | File name shown in the console's Knowledge Base: `.txt`, `.md`, `.csv` or `.json`; no extension means `.txt`. Derived from the opening words when omitted. |
| `tags` | array | Required | Tags the document is filed under. Required: a document with no tags is unreachable. Pass the same tags to `knowledge-base-retrieve`, and to an agent's `kb_tags`. A non-empty array. |

**Errors**

- `UpstreamError` (503): `S8:knowledge-base-unavailable`: the document store is down or refused the platform's credential. Nothing was stored. When this ends a resumed call, the resume token is already spent (`resume_spent` is true): add the document again, which asks for a fresh approval.

**More details**

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

Add a document to this project's knowledge base so knowledge-base-retrieve can find it. It becomes a file in the project's Knowledge Base, the same as a console upload: the console lists it under the name you give (or one derived from the text), and the returned `file_id` is what delete-kb-document takes to remove exactly this document. Tags are how retrieval scopes its search, so they are required — a document with no tags is unreachable even once stored. There is no knowledge base to create first: a knowledge base IS the project's content filtered by tag, so ingesting with a new tag is all it takes to start one. Agents read this corpus when has_knowledge_base is set on them.

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).
