> ## Documentation Index
> Fetch the complete documentation index at: https://velt.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Knowledge

Use this API to replace a rule-based knowledge source's content. Velt converts the new content, re-extracts its rules, re-embeds them, and bumps the source's version. Knowledge chunks are not re-chunked.

<Note>
  This API applies only to rule-based sources. Velt classifies every source when you ingest it: a source is rule-based when enough of its lines read like rules, meaning bullets, numbered items, or checkboxes that also carry directive wording such as `must`, `never`, or `ensure`. Checklists and guideline documents qualify; prose documents do not, whatever their file type. Calling this API for a source that is not rule-based returns `FAILED_PRECONDITION` with the message `Version diff is only supported for rule-based knowledge sources.`
</Note>

# Endpoint

`POST https://api.velt.dev/v2/memory/knowledge/update`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/docs/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="sourceId" type="string" required>
      The knowledge source to update.
    </ParamField>

    <ParamField body="newContent" type="string" required>
      The replacement content.
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### Replace a source's content

```JSON theme={null}
{
  "data": {
    "sourceId": "src_9a8...",
    "newContent": "# Brand Guidelines v2\n\n- Always cite medical claims..."
  }
}
```

# Response

The response reports a diff of extracted rules (`added`, `removed`, `unchanged`) and the new version number.

#### Success Response

```JSON theme={null}
{
  "result": {
    "diff": {
      "added": ["..."],
      "removed": ["..."],
      "unchanged": 12
    },
    "newVersion": 2
  }
}
```

#### Failure Response

The endpoint returns `NOT_FOUND` for an unknown `sourceId`, `FAILED_PRECONDITION` when the source is not rule-based, and `INVALID_ARGUMENT` when `sourceId` or `newContent` is missing or empty.

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "diff": {
        "added": ["..."],
        "removed": ["..."],
        "unchanged": 12
      },
      "newVersion": 2
    }
  }
  ```
</ResponseExample>
