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

# knowledge-base-add

Add a document to this project's knowledge base so knowledge-base-retrieve can find it. 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.

## What it is called on each surface

The wire name is `knowledge-base-add` everywhere: it is what the Wexa MCP server advertises, the REST path is
`POST /v1/knowledge-base-add`, and each SDK exposes it under its own language's naming convention.

| Surface | Name |
| --- | --- |
| Wexa MCP server | `knowledge-base-add` |
| REST API | `POST /v1/knowledge-base-add` |
| TypeScript SDK | `fabric.knowledgeBaseAdd()` |
| Python SDK | `fabric.knowledge_base_add()` |

## Arguments

2 of the 2 arguments are required. Omitting a required one is refused before the tool runs, at the validation stage, so it costs nothing and changes nothing.

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `content` | string | Required | The document text to ingest. Required. |
| `tags` | array | Required | Tags this document is filed under. Required — pass the same tags to knowledge-base-retrieve to read it back, and to an agent's kb_tags to let it read the corpus. |

`project_id`, `projectID`, `organization_id` and `executed_by` are not arguments you pass: the
platform binds all four from the credential you authenticated with, and both SDKs refuse them
before the request leaves your process — see
[server-bound arguments](/docs/get-started/scope-and-server-bound-arguments).

## What it returns

The three surfaces wrap this differently, and code written against one will not read another
correctly — see [return shape](/docs/tools/overview#return-shape).

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.

Keeping the `lifecycle_id` is what lets you ask later why a call was allowed, refused or held.

## Calling it

The same call on all four surfaces. Pick a tab once and every code block in the documentation follows it.

The ids in this example are real, and resolve against the project the documentation is written
against. Swap them for your own. A value in angle brackets is one only you can supply, and the
platform refuses a literal `<...>`.

**Call knowledge-base-add**

**Wexa MCP server**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "knowledge-base-add",
    "arguments": {
      "content": "<content>",
      "tags": []
    }
  }
}
```

**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":"<content>","tags":[]}'
```

**TypeScript SDK**

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

const fabric = new Fabric()
const { result } = await fabric.knowledgeBaseAdd({
  content: "<content>",
  tags: []
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.knowledge_base_add(content="<content>", tags=[])
```

## Errors

Both SDKs raise the same typed errors, chosen from the gateway's own error string first and its
HTTP status second. `knowledge-base-add` checks the `fabric:orchestrate.write` grant, and reaches the seven classes every
tool reaches — listed under [the common set](/docs/tools/errors#the-common-set). These are the ones specific to it:

| Error | Status | Raised when |
| --- | --- | --- |
| `ApprovalRequired` | 202 | A policy held this call for a person to approve. The error carries the approval id; see below. |
| `ConfigurationError` | 5xx | `knowledge-base-add` is not available to you. Retrying will not help. |

## Governance

Every call to `knowledge-base-add` runs through the same ten-stage lifecycle as every other Wexa tool: the
credential is resolved to a scope, the `fabric:orchestrate.write` grant is checked, quota is drawn down, the arguments are
validated, policy rules are evaluated, the call is executed, the result is shaped and redacted, and an audit
record is written. The `lifecycle_id` in the response is the handle to that record.

`knowledge-base-add` is marked consequential, which means it changes something rather than only reading. Two things
follow. It is audited in full rather than lightly, and a policy rule may hold it for human approval — in which
case the call returns `202` and an `ApprovalRequired` error carrying the approval id, and the SDKs can wait for
the decision and resume rather than making you call again.

## See also

[The tool index](/docs/tools/overview) and [errors](/docs/tools/errors).
